global mapper 12
+ Reply to Thread
Page 1 of 2 1 2 LastLast
Results 1 to 10 of 13
  1. #1
    timhoman is offline Global Mapper User
    Join Date
    Mar 2008
    Posts
    49
    Thanks
    16
    Thanked 2 Times in 2 Posts

    Post scripting/SDK? - select entities based on attribute value and export a subset to file

    Is it possible to create a subset of entities based on the search criteria for a specific attribute(s)? YES... I've done it within GM manually.

    Now...
    Is it possible to automate this process? Yes/No?
    How? Scripting and/or SDK?

    Specifically, I would like to disassemble an S-57 (ENC) file into individual shapefiles (kml, etc.) based on <feature_type> (or any attribute) values.

    Thanks,
    Tim

  2. #2
    global_mapper is offline Administrator
    Join Date
    Jun 2007
    Posts
    7,500
    Thanks
    2
    Thanked 641 Times in 624 Posts

    Default

    Tim,

    Yes, you can split an export on type/layer or attribute value using the EXPORT_VECTOR command and the following parameters:

    # SPLIT_BY_LAYER (SHAPEFILE only) - specifies that the export should generate a separate Shapefile for each layer/type in the input data
    # SPLIT_BY_ATTR - specifies that the export should generate a separate file for each set of attributes values in the input data. Use the FILENAME_ATTR_LIST and FILENAME_INCLUDE_ATTR_NAME parameters to control which attributes are compared to and in what order and how the filename is generated from those attributes and their values. Use SPLIT_BY_ATTR=YES to split your export so that all features with the same values for each of the specified attributes is in the same file.
    # FILENAME_ATTR_LIST - contains a comma-delimited list of attributes to use when naming files exported when using the SPLIT_BY_ATTR=YES parameter.
    # FILENAME_INCLUDE_ATTR_NAME - specifies that the attribute name specified in the FILENAME_ATTR_LIST parameter should be included as part of the filename when using SPLIT_BY_ATTR=YES to split your export into a separate file for each set of attributes.

    With the SDK of course you can basically do whatever you want, but it requires more programming and an additional purchase.

    Let me know if I can be of further assistance.

    Thanks,

    Mike
    Global Mapper Support
    support@globalmapper.com

  3. The Following User Says Thank You to global_mapper For This Useful Post:

    timhoman (03-23-2010)

  4. #3
    timhoman is offline Global Mapper User
    Join Date
    Mar 2008
    Posts
    49
    Thanks
    16
    Thanked 2 Times in 2 Posts

    Post a little help with a script please

    Mike -
    Thanks - GM Rocks!

    From within GM I select the "export vector data" dialog and chose "Split on Feature Description" and meet with some success. However, I am having difficulty with the script...

    Below is the script I created --- the results are a single file.

    GLOBAL_MAPPER_SCRIPT VERSION=1.00
    UNLOAD_ALL
    IMPORT FILENAME="C:\temp\US5FL11M\US5FL11M.000" \
    TYPE=S57
    EXPORT_VECTOR FILENAME="C:\temp\test1.shp" \
    TYPE=SHAPEFILE \
    // SHAPE_TYPE=AREAS \
    // SHAPE_TYPE=LINES \
    SHAPE_TYPE=POINTS \
    GEN_PRJ_FILE=YES \
    SPLIT_BY_ATTR=YES \
    FILENAME_ATTR_LIST="<Feature Name>" \
    FILENAME_INCLUDE_ATTR_NAME

    I don't believe it likes the value "<Feature Name>".
    Any suggestions?

    Thanks,
    Tim
    Last edited by timhoman; 03-23-2010 at 01:46 AM.

  5. #4
    global_mapper is offline Administrator
    Join Date
    Jun 2007
    Posts
    7,500
    Thanks
    2
    Thanked 641 Times in 624 Posts

    Default

    Tim,

    Actually that looks good for splitting on the display label for features. Do your features actually have display labels though? You also need to use FILENAME_INCLUDE_ATTR_NAME=YES to enable adding the attribute name to the filename, but I'm guessing you actually don't want that for the display label.

    Let me know if I can be of further assistance.

    Thanks,

    Mike
    Global Mapper Support
    support@globalmapper.com

  6. The Following User Says Thank You to global_mapper For This Useful Post:

    timhoman (03-23-2010)

  7. #5
    timhoman is offline Global Mapper User
    Join Date
    Mar 2008
    Posts
    49
    Thanks
    16
    Thanked 2 Times in 2 Posts

    Smile

    Mike,

    When I load the S-57 file and click on the button with the binoculars (search...) the table that is displayed has the 2nd column labeled "<Feature Type>" - this the attribute I would like split by values ... Please note that in my previous replies I was stated the attribute label as "<Feature Name>" to avoid confusion about the entity types (Polygons, Lines, Shapes). The "<Feature Type>" column shows the values by which I wish to name the files... I'm still getting a single file.


    --
    Thanks,
    Tim

  8. #6
    global_mapper is offline Administrator
    Join Date
    Jun 2007
    Posts
    7,500
    Thanks
    2
    Thanked 641 Times in 624 Posts

    Default

    Tim,

    You should be able to use "<Feature Desc>" or "<Feature Type>" to split by the type or description. Can you maybe post your actual .gms file so that I can take a look? Also can you remove the two comment lines from the EXPORT_VECTOR command? They might be causing issues inside of a command, although I don't think so. Finally, if you run your script with the File->Run Script command do you get any errors?

    Thanks,

    Mike
    Global Mapper Support
    support@globalmapper.com

  9. The Following User Says Thank You to global_mapper For This Useful Post:

    timhoman (03-23-2010)

  10. #7
    timhoman is offline Global Mapper User
    Join Date
    Mar 2008
    Posts
    49
    Thanks
    16
    Thanked 2 Times in 2 Posts

    Post

    Mike,

    GM v11.02

    The result for each of the three SHAPE_TYPE's is a single shapefile.

    ---------------------------------------------------------
    Here is the actual script:

    GLOBAL_MAPPER_SCRIPT VERSION=1.00
    UNLOAD_ALL
    IMPORT FILENAME="C:\temp\US5FL11M\US5FL11M.000" \
    TYPE=S57
    EXPORT_VECTOR FILENAME="C:\temp\test1.shp" \
    TYPE=SHAPEFILE \
    SHAPE_TYPE=AREAS \
    GEN_PRJ_FILE=YES \
    SPLIT_BY_ATTR=YES \
    FILENAME_ATTR_LIST="<Feature Type>"

    ---------------------------------------------------------
    Here are the "script results" when I run the script:

    Removed all loaded overlays.
    Importing file C:\temp\US5FL11M\US5FL11M.000...
    Exporting vector data to file C:\temp\test1.shp...
    Exporting vector data from feature to file C:\temp\TEST1.shp...
    Script processing COMPLETED.

    --
    Tim
    Last edited by timhoman; 03-23-2010 at 05:06 AM.

  11. #8
    global_mapper is offline Administrator
    Join Date
    Jun 2007
    Posts
    7,500
    Thanks
    2
    Thanked 641 Times in 624 Posts

    Default

    Tim,

    I took a look and discovered the problem when splitting from a script against a feature name, type, or description and was able to fix it. I have placed a new build at http://www.globalmapper.com/global_mapper11.zip with the change for you to try. Simply download that file and extract the contents into your existing v11.xx installation folder to give it a try. If you are using the 64-bit version, there is a new build available at http://www.globalmapper.com/global_mapper11_64bit.zip .

    Let me know if I can be of further assistance.

    Thanks,

    Mike
    Global Mapper Support
    support@globalmapper.com

  12. The Following User Says Thank You to global_mapper For This Useful Post:

    timhoman (03-23-2010)

  13. #9
    timhoman is offline Global Mapper User
    Join Date
    Mar 2008
    Posts
    49
    Thanks
    16
    Thanked 2 Times in 2 Posts

    Smile

    Mike,

    IT WORKS!

    Thank you very much.

    --
    Tim

  14. #10
    timhoman is offline Global Mapper User
    Join Date
    Mar 2008
    Posts
    49
    Thanks
    16
    Thanked 2 Times in 2 Posts

    Default Update! - "2 out of 3 ain't bad"

    Mike,

    It appears that I am able to successfully apply the EXPORT_VECTOR with SPLIT_BY_ATTR to <Feature Name> and <Feature Type>.

    However, when applying the script to <Description> only a single file is generated.

    --
    Tim

Similar Threads

  1. Select area shapes based on attribute
    By Kyle Estes in forum Technical Support
    Replies: 1
    Last Post: 01-22-2010, 08:29 PM
  2. Apply colors to vector shapes based on attribute value
    By Kyle Chandler in forum Technical Support
    Replies: 1
    Last Post: 10-07-2009, 01:17 PM
  3. Replies: 2
    Last Post: 09-14-2009, 01:37 PM
  4. Scripting - Export package file
    By kartoone76 in forum Technical Support
    Replies: 2
    Last Post: 06-18-2009, 01:21 AM
  5. Changing colours based on attribute name/values
    By therooster in forum Technical Support
    Replies: 2
    Last Post: 05-19-2008, 03:48 PM

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts