-
VPF - Script Convert DNCs to Shapefiles
Hello,
I am looking to get some help on how to batch / script convert any edition of DNC data to Shapefiles.
What I would like to do is open the DNC folder (at c:\Data\DNCs\DNCxx\), and recurse through all of the subfolders (the approach, coastal, general, and harbour folders), open the LHT associated with each, the export those as shaperfiles to the following location (c:\Data\SHPs\DNCxx\) and then the appropriate subfolder name from which the data came from.
In the end I would like to have a mirror of the DNC folder structure with Shapefiles.
Also, when doing this manually, I split the shapefiles by type and would like to continue doing that. For each vector type, I would like to use the prefixes: A, L & P for areas, lines and points.
This is not functional yet... but this is what I have so far:
GLOBAL_MAPPER_SCRIPT VERSION=1.00
UNLOAD_ALL
DIR_LOOP_START DIRECTORY="C:\DATA\DNCs\DNC17" FILENAME_MASKS="LHT" RECURSE_DIR=YES
IMPORT FILENAME="%FNAME_W_DIR%" TYPE="VPF"
EXPORT_VECTOR FILENAME="%FNAME_W_DIR%\A" TYPE=SHAPEFILE SHAPE_TYPE=AREAS SPLIT_BY_LAYER
EXPORT_VECTOR FILENAME="%FNAME_W_DIR%\L" TYPE=SHAPEFILE SHAPE_TYPE=LINES SPLIT_BY_LAYER
EXPORT_VECTOR FILENAME="%FNAME_W_DIR%\P" TYPE=SHAPEFILE SHAPE_TYPE=POINTS SPLIT_BY_LAYER
UNLOAD_ALL
DIR_LOOP_END
I am using GM v13.1.
Thanks for any help.
-
-
You are close, I think you just want to change your output filenames to look like:
FILENAME="%DIR%A\.SHP"
So if your layer was "ocean" it would end up like "c:\data\DNCs\DNC12\A\ocean.shp". The one piece that is missing is the changing of the path tree. You can't currently do that, but I think I could add support for some kind of output path replace string, like PATH_REPLACE="DNCs=SHPs" or something like that to replace one string in your path with another. Would that work?
Thanks,
Mike
Global Mapper Guru
gmsupport@bluemarblegeo.com
http://www.globalmapper.com
-
-
Yes I think the PATH_REPLACE option you suggested would work very well.
Also, thanks for the help with the script but it is not quite working right. I would like to run the script on the root of the directory and have it output the shapefiles for every layer and split them. For example, I would like to load all of the features in the A1731740 subfolder that the LHT file is located in and then split the export into every different type. Manually when I load the files into GM I can export vectors and choose the "Split Export based on:" and choose <Feature Type> from the drop down menu.
-
-
Ooops solved the problem... I needed to say SPLIT_BY_LAYER=YES instead of just SPLIT_BY_LAYER.
Also, how can I get this script to run and load all of the VPF layers automatically for each without prompting the user for that detail. I tried:
IMPORT FILENAME="%FNAME_W_DIR%" TYPE="VPF" PROMPT_IF_TYPE_UNKNOWN=NO
but that did not work.
I assume there must be a way in the IMPORT FILENAME to have it auto load all types.
-
-
I have updated the DEFINE_VAR script command to support a REPLACE_STR parameter, so inside your loop you can define a variable whose value is the path you want with the path replaced, like the following:
DEFINE_VAR NAME="OUT_FNAME" VALUE="%FNAME_WO_DIR%" REPLACE_STR="DNCs=SHPs"
I have placed a new build at http://www.globalmapper.com/global_mapper13.zip with the latest changes for you to try. Simply download that file and extract the contents into your existing v13.xx installation folder to give it a try. If you are using the 64-bit v13 version there is a new build at http://www.globalmapper.com/global_mapper13_64bit.zip .
For VPF to load with everything, try adding LOAD_FLAGS="COVERAGES=*" to your IMPORT command.
Let me know if I can be of further assistance.
Thanks,
Mike
Global Mapper Guru
gmsupport@bluemarblegeo.com
http://www.globalmapper.com
-
-
Mike,
Thanks for all your help...
I tried your script suggestion but when the script ran I received the following error:
WARNING: Error loading VPF library data.
No library with the name COVERAGES=* found.
I also tried LOAD_FLAGS="COVERAGES='*'" and LOAD_FLAGS="COVERAGES-ALL" to no avail.
I haven't tried the new build yet but will soon.
Thank you.
-
-
Hi Mike,
I installed the new build and ran the script:
GLOBAL_MAPPER_SCRIPT VERSION=1.00
UNLOAD_ALL
DIR_LOOP_START DIRECTORY="C:\DATA\MAPS\DNCs\DNC20" FILENAME_MASKS="LHT" RECURSE_DIR=YES
IMPORT FILENAME="%FNAME_W_DIR%" TYPE="VPF"
DEFINE_VAR NAME="OUT_FNAME" VALUE="%FNAME_WO_DIR%" REPLACE_STR="DNCs=SHPs"
EXPORT_VECTOR FILENAME="%OUT_FNAME%\A_.SHP" TYPE=SHAPEFILE SHAPE_TYPE=AREAS SPLIT_BY_LAYER=YES
EXPORT_VECTOR FILENAME="%OUT_FNAME%\L_.SHP" TYPE=SHAPEFILE SHAPE_TYPE=LINES SPLIT_BY_LAYER=YES
EXPORT_VECTOR FILENAME="%OUT_FNAME%\P_.SHP" TYPE=SHAPEFILE SHAPE_TYPE=POINTS SPLIT_BY_LAYER=YES
UNLOAD_ALL
DIR_LOOP_END
and ended up with the files in a directory called:
C:\Data\Maps\%FNAME_WO_DIR%
that had the shapefiles in them. Am I doing something wrong?
Thanks.
-
-
Sorry my sample is bad. There is no loop variable named %FNAME_WO_DIR%, it is just %DIR%.
Thanks,
Mike
Global Mapper Guru
gmsupport@bluemarblegeo.com
http://www.globalmapper.com
-
-
Sorry I forgot you have to add some extra stuff in there to simulate quotes in the load flags. Try LOAD_FLAGS="COVERAGES=''*''". Note that there are 2 consecutive ' characters inside the value around the * and not direct quote marks.
-
-
You rock Mike. That works perfectly. Thank you.
-
Similar Threads
-
By Roger Edrinn in forum Bug Report
Replies: 2
Last Post: 06-10-2011, 05:03 PM
-
By agenteh2o in forum Vector Data
Replies: 6
Last Post: 05-09-2011, 06:34 PM
-
By seager in forum Raster Data
Replies: 7
Last Post: 01-23-2011, 05:11 PM
-
By redbeard in forum Vector Data
Replies: 1
Last Post: 09-14-2009, 07:20 PM
-
By mitchelljj in forum Vector Data
Replies: 3
Last Post: 03-25-2009, 07:10 PM
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
Powered by
vBulletin® Version 4.2.1
Copyright © 2013 vBulletin Solutions, Inc. All rights reserved.
Content Relevant URLs by
vBSEO 3.6.1

Copyright 2008-2012 Globalmapperforum.com
All times are GMT. The time now is 11:55 AM.
Bookmarks