EXPORT_VECTOR - only entities with specific attribute values?

timhomantimhoman Global Mapper UserPosts: 49Trusted User
edited March 2010 in Technical Support
Is it possible, through scripting and the EXPORT_VECTOR command, to apply the SPLIT_BY_ATTR option to not only generate a collection of separate files for each set of attributes values in the input data... BUT to be able generate a subset of files filtered by the individual attribute values you designate for exporting?

Thanks,
Tim

Comments

  • global_mapperglobal_mapper Administrator Posts: 17,238
    edited March 2010
    Tim,

    I'm not quite sure what you mean, you should already get a separate file for each attribute value found. Can you provide an example?

    Thanks,

    Mike
    Global Mapper Support
    support@globalmapper.com
  • tjhbtjhb Global Mapper User Posts: 454Trusted User
    edited March 2010
    Mike,

    I think Tim means: can you export just the subset of objects having value X for the given attribute, and skip all objects having other values?

    Other Tim
  • timhomantimhoman Global Mapper User Posts: 49Trusted User
    edited March 2010
    @tjbh - thanks!

    That is what I was trying to ask.

    @Mike - apologies about the confusion.
  • global_mapperglobal_mapper Administrator Posts: 17,238
    edited March 2010
    Tim,

    Ok I understand now. I think what I can do is add support for you specifying 'ATTR_NAME=ATTR_VAL' in the SPLIT_BY_ATTR parameter. If the equal sign is present then only those features with a matching attribute value will be used. Would that work?

    Thanks,

    Mike
    Global Mapper Support
    support@globalmapper.com
  • timhomantimhoman Global Mapper User Posts: 49Trusted User
    edited March 2010
    Mike,

    I believe that would work...

    So... currently when I run a script and SPLIT_BY_ATTR=YES and FILENAME_ATTR_LIST="<Feature Name>" I get a bunch of files: one file, for each unique attribute value, which contains one or more entities.

    What you are proposing would enable me to narrow the files generated to a subset based on attribute values specified. I would get one file, for each of the different attribute values specified (assuming I could specify more than one in comma separated list), which contains one or more entities.

    One thing... if you where to permit a comma separated list of values for input... what happens when the value itself contains a comma? Perhaps each value would need to be in double quotes (eg; "value 1", "value,big 2") ...

    For now - being able to specify one value would be a great start.

    Thanks,
    Tim
  • global_mapperglobal_mapper Administrator Posts: 17,238
    edited March 2010
    Tim,

    I think each COMPARE_STR would be limited to one attribute and corresponding value. I would use separate EXPORT_VECTOR commands if you need to filter by multiple values. I'll let you know when I've got a new build with this support ready.

    Thanks,

    Mike
    Global Mapper Support
    support@globalmapper.com
  • global_mapperglobal_mapper Administrator Posts: 17,238
    edited March 2010
    I have updated the SPLIT_BY_ATTR to support providing a value that is must be equal to. 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
  • tjhbtjhb Global Mapper User Posts: 454Trusted User
    edited March 2010
    I think this will be really useful. One attribute per export has the virtue of simplicity.

    A possible extension, equally simple to use, would be to add "ATTR_NAME<>ATTR_VAL", to filter objects having the given value out.
  • global_mapperglobal_mapper Administrator Posts: 17,238
    edited March 2010
    I have updated the support to also allow using '!=' in addition to '=' in the FILENAME_ATTR_LIST. 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
  • tjhbtjhb Global Mapper User Posts: 454Trusted User
    edited March 2010
    That's going to be really handy.
  • timhomantimhoman Global Mapper User Posts: 49Trusted User
    edited March 2010
    Mike,

    thanks for the update...

    I'm having a little difficulty getting the script syntax correct for the new features.

    Could you please provide an example?

    Thanks,
    Tim
  • global_mapperglobal_mapper Administrator Posts: 17,238
    edited March 2010
    Tim,

    Try using something like FILENAME_ATTR_LIST="<Feature Name>=My Label,ATTR_1=My Attr Val". This should export any features with a display label of 'My Label' and an ATTR_1 value of 'My Attr Val'.

    Let me know if I can be of further assistance.

    Thanks,

    Mike
    Global Mapper Support
    support@globalmapper.com
  • timhomantimhoman Global Mapper User Posts: 49Trusted User
    edited March 2010
    Mike,

    Tests & Results using the EXPORT_VECTOR command updates applied to the ENC file "US5FL11M.000":

    ---
    #1.) FILENAME_ATTR_LIST="<Feature Desc>"

    GREAT... a file was created for every attribute value, including those containing ",". It even generated the following file: "US5F11M_PTS_BEACON, LATERAL.shp"

    #2.) FILENAME_ATTR_LIST="SORIND - SOURCE INDICATION"

    GOOD ... a file was created for (nearly) every attribute value. It even generated the following file: "US5F11M_PTS_US, US, REPRT, 7THCGD, LNM 35_94.shp"

    BAD ... A file was not created for the following attribute value "US, US, reprt, 7thCGD, LNM 35/94"

    #3.) FILENAME_ATTR_LIST="<Feature Desc>=Light"

    GOOD... a single file was created for just the "Light" values.

    #4.) FILENAME_ATTR_LIST="<Feature Desc>=Beacon, lateral"

    BAD ... no files created for the "Beacon, lateral" value.

    #5.) FILENAME_ATTR_LIST="SORIND - SOURCE INDICATION=US, US, REPRT, 7THCGD, LNM 35_94"

    BAD ... no files created for the "US, US, REPRT, 7THCGD, LNM 35_94" value.
    ---

    I realize that the problems may be due to the "/" and "," contained within the values.
    Within the ENC (S-57) files, numerous attributes have values containing one or more "," and "/".

    Any chance the syntax could be modified to permit specifying values containing one or more "," and "/" ?
    Of course, file generation would need to substitute "/" and other invalid file name characters with "_".

    Thanks again,
    Tim
  • global_mapperglobal_mapper Administrator Posts: 17,238
    edited March 2010
    Tim,

    I'll take a look and see what I can do. I'll probably add a new FILENAME_ATTR parameter that just allows one attribute to be specified, that way commas in the values won't be an issue.

    Thanks,

    Mike
    Global Mapper Support
    support@globalmapper.com
  • global_mapperglobal_mapper Administrator Posts: 17,238
    edited March 2010
    Tim,

    I have updated the EXPORT_VECTOR command to support using a FILENAME_ATTR parameter in addition to (or instead of) the FILENAME_ATTR_LIST parameter. It just take a single attribute name and optional value, so values with commas should work fine with this. 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 .

    If you still have any that don't work, can you provide details?

    Thanks,

    Mike
    Global Mapper Support
    support@globalmapper.com
  • timhomantimhoman Global Mapper User Posts: 49Trusted User
    edited March 2010
    Mike,

    Thanks for the update - I will test it.

    btw - One important thing should be considered. From within GM and you can chose to export vector data as follows:

    File->Export Vector Data->Export Shapefile->Split on Feature Type -OR- Split on Feature Description.

    This built-in GM capability may not generate an collection of files that is all inclusive of the various Types or Descriptions values due to the same file naming constraint using "/" and "," or other special characters as part of the value/file name.

    --
    Tim
  • global_mapperglobal_mapper Administrator Posts: 17,238
    edited March 2010
    Tim,

    Do you have a situation where there are multiple description/type values that end up the same after replacing all of the special characters not allowed in filenames with an underscore? You should still get all of the features exported, there would just be a single file containing all of those features rather than separate files for the two types with different names prior to transformation to be a filename.

    Thanks,

    Mike
    Global Mapper Support
    support@globalmapper.com
Sign In or Register to comment.