Global Mapper Pro

Adding attributes

Alex404
Alex404 Global Mapper UserTrusted User
edited September 2010 in GM Script Language
Hi all,

I am evaluating GM for a larger project, where I need to generate shapefiles with a defined set of attributes and a specific naming convention.

Is there the possibility to add / remove / rename attributes via GM script?

Thanks in advance for your reply,
Alex

Comments

  • global_mapper
    global_mapper Administrator
    edited July 2010
    Alex,

    We have recently added an EDIT_VECTOR script command (replacing the less capable ASSIGN_TYPE command) that allows adding and updating attribute values in loaded features from a script. It could be extended to delete attributes as well if needed. Here is the User's Manual entry for this new command:

    EDIT_VECTOR

    The EDIT_VECTOR command allows you to assign feature types (classifications), add/update attributes and display labels, or delete features based on one or more attribute or label values. You can choose to update area, line, and/ or point features with a single operation. You can also supply multiple COMPARE_STR parameters to apply multiple criteria, all of which must be true, in order to edit a feature.

    The following parameters are supported by the command:

    * FILENAME - filename of the layer to update. If an empty value is passed in, all loaded vector layers will be updated. You can also pass in the value 'USER CREATED FEATURES' when running a script in the context of the main map view or loading a workspace to have the 'User Created Features' layer updated.
    * AREA_TYPE - specifies the name of the Global Mapper area type to assign to matching area features.
    * LINE_TYPE - specifies the name of the Global Mapper line type to assign to matching line features.
    * POINT_TYPE - specifies the name of the Global Mapper point type to assign to matching point features.
    * ATTR_VAL - specifies a the attribute value to updated and what value to assign to it. The format is attr_name=attr_value. For example if you want to set the value of an attribute named CFCC to A34, use ATTR_VAL="CFCC=A34". You can add multiple ATTR_VAL parameters to a single command to provide multiple attribute/value pairs (or labels) to add/update. If you would like to update the feature label rather than an attribute, use <Feature Name> for your attribute name.
    * COMPARE_STR - specifies a comparison operation to perform to see if a feature is one that needs to be updated. The format is attr_name=attr_value. For example if you have an attribute named CFCC and you want to match when the value of that attribute starts with an 'A', you can use COMPARE_STR="CFCC=A*" as your parameter. You can add multiple COMPARE_STR parameters to a single command to combine multiple criteria for your search. If you would like to compare against a feature label rather than an attribute, use <Feature Name> for your attribute name. To compare against a feature type name rather than an attribute, use <Feature Type> for your attribute name. To compare against the feature description, use <Feature Desc> for your attribute name.
    * CASE_SENSITIVE - specifies whether or not text comparisons are case sensitive or not. Use CASE_SENSITIVE=YES to enable, by default comparisons are not case sensitive.
    * DELETE_FEATURES - specifies whether or not to mark matching features as deleted. Use DELETE_FEATURES=YES to enable.

    Would this work for you? I can provide some instructions to try out v12 if you want.

    Thanks,

    Mike
    Global Mapper Support
    support@globalmapper.com
  • Alex404
    Alex404 Global Mapper User Trusted User
    edited July 2010
    Mike,

    I am not sure, if I understood correctly. Assuming I have a dataset of lake shapes. They do not have the attribute "Waterquality"

    I could then add a new attribute "Waterquality" with a default value of "something" with the script command?

    ATTR_VAL="Waterquality=something"

    Best regards,
    Alex
  • global_mapper
    global_mapper Administrator
    edited July 2010
    Alex,

    Yes, you could do exactly that to add that attribute to all features or even just those matching some list of criteria.

    Let me know if I can be of further assistance.

    Thanks,

    Mike
    Global Mapper Support
    support@globalmapper.com
  • Alex404
    Alex404 Global Mapper User Trusted User
    edited July 2010
    Mike,

    thank you. This is what I am looking for, as it is not testable in the trial version. It would be perfect, if I could also delete unwanted attributes.
    I can provide some instructions to try out v12 if you want
    I would appreciate this...

    Thanks,
    Alex
  • global_mapper
    global_mapper Administrator
    edited July 2010
    Alex,

    I forgot that this is in a v11 build so that you can test it now. 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 v11 version there is a new build at http://www.globalmapper.com/global_mapper11_64bit.zip .

    You can do everything so far except deleting attributes. I will have to add that option (it would be in a v12 build). Let me know if this is critical and I can prioritize it.

    Thanks,

    Mike
    Global Mapper Support
    support@globalmapper.com
  • Alex404
    Alex404 Global Mapper User Trusted User
    edited September 2010
    Hi,

    I have been testing version 11 and now version 12. Global Mapper seems to fit perfecly.

    My data manipulation process could be automated to 80%. There are only two steps, where I need another software product.
    • Deduplication (same type, same nodes)
    • Merge Islands of polygons

    or can this be done with scripting, and I simply overlooked it?

    When will verson 12 be launched? (as I want to buy it)

    Best regards,
    Alex
  • global_mapper
    global_mapper Administrator
    edited September 2010
    Alex,

    So for de-duplication would you want an option to find duplicate areas, lines, and/or points and remove them?

    For merging islands, would that be an operation to merge overlapping islands within areas or something like that?

    We plan on officially releasing v12 later this week.

    Thanks,

    Mike
    Global Mapper Support
    support@globalmapper.com
  • Alex404
    Alex404 Global Mapper User Trusted User
    edited September 2010
    So for de-duplication would you want an option to find duplicate areas, lines, and/or points and remove them?

    Yes.
    For merging islands, would that be an operation to merge overlapping islands within areas or something like that?

    No, it is the "create single vertex list area..." function, which I would like to apply to all loaded polygons per script.

    Best regards,
    Alex
  • global_mapper
    global_mapper Administrator
    edited September 2010
    Alex,

    I have been able to add the option to "create single vertex list" from the area easily. The EDIT_VECTOR command in v12 now supports adding CONNECT_ISLANDS=YES as a parameter to do this in a script. I have placed a new build at http://www.globalmapper.com/global_mapper12.zip with the change for you to try. Simply download that file and extract the contents into your existing v12.xx installation folder to give it a try. If you are using the 64-bit v12 version there is a new build at http://www.globalmapper.com/global_mapper12_64bit.zip .

    Let me know if I can be of further assistance.

    Thanks,

    Mike
    Global Mapper Support
    support@globalmapper.com
  • Alex404
    Alex404 Global Mapper User Trusted User
    edited September 2010
    :cool: wowh!! Thanks! I will test it and let you know.
  • global_mapper
    global_mapper Administrator
    edited September 2010
    Alex,

    More good news, I was able to add support for DELETE_DUPLICATES=YES parameter to the EDIT_VECTOR command so you can now automatically find and delete duplicate features within the same layer from a script. I have placed a new build at http://www.globalmapper.com/global_mapper12.zip with the change for you to try. Simply download that file and extract the contents into your existing v12.xx installation folder to give it a try. If you are using the 64-bit v12 version there is a new build at http://www.globalmapper.com/global_mapper12_64bit.zip .

    Let me know if I can be of further assistance.

    Thanks,

    Mike
    Global Mapper Support
    support@globalmapper.com
  • tjhb
    tjhb Global Mapper User Trusted User
    edited September 2010
    CONNECT_ISLANDS and DELETE_DUPLICATES both very useful additions Mike. Thanks.
  • tjhb
    tjhb Global Mapper User Trusted User
    edited September 2010
    Have you ever thought of adding a module to the GUI, which would offer the user a list of checkboxes, each representing a topology-oriented function like these (you have quite a number built in now; I haven't got an exhaustive list of them in my head but for example joining lines which touch and share attributes; finding/closing small gaps between unconnected lines; other functions directed at areas and their holes). An alterative word for such a function is topology rule.

    Pressing OK on such a module might do one of two things (with an option to choose between them): (a) perform all of the checked functions (in a topologically sensible order or, to be fancier, in an order adjustable by the user) and deliver the result in a new user-created features layer; or (b) treat the functions/rules only as checks, and deliver the objects which fail one or more of the conditions (those which would be changed by application of one of the rules) unchanged into a new layer. More rules could be added to the module as they were added to GM generally; this module would make a convenient place to find them (even when you only wanted to apply/test one of the rules).

    I'm not sure this would be worth the effort—thinking out loud.
  • global_mapper
    global_mapper Administrator
    edited September 2010
    That might be something useful to consider as the Digitizer Tool right-click menu is becoming pretty busy, so moving some of those things to a single option with checkboxes or something might make sense to avoid the clutter in the Digitizer Tool, especially as more functionality is added. I'll add that to the todo list to look at.

    Thanks,

    Mike
    Global Mapper Support
    support@globalmapper.com
  • Alex404
    Alex404 Global Mapper User Trusted User
    edited September 2010
    Thanks for implementing this.

    I tested it and it works fine. But when using these commands a user needs to ensure, that:

    1. CONNECT_ISLANDS=YES and DELETE_DUPLICATES=YES is not used in one command, as an object will be changed and therfore its duplicate will not be found.

    2. When using multiple EDIT_VECTOR commands, the DELETE_DUPLICATES is the last one, otherwise the script will not work as no objects will be found.

    Examples:
    GLOBAL_MAPPER_SCRIPT VERSION=1.00
    // Only some duplicates will be deleted (only objects without islands)
    EDIT_VECTOR CONNECT_ISLANDS=YES DELETE_DUPLICATES=YES
    

    GLOBAL_MAPPER_SCRIPT VERSION=1.00
    // Duplicates will be deleted, but no objects will be found to check for islands
    EDIT_VECTOR DELETE_DUPLICATES=YES
    EDIT_VECTOR CONNECT_ISLANDS=YES 
    
    GLOBAL_MAPPER_SCRIPT VERSION=1.00
    //Works fine. Connects Islands and then deletes the duplicates
    EDIT_VECTOR CONNECT_ISLANDS=YES 
    EDIT_VECTOR DELETE_DUPLICATES=YES
    

    Best regards,
    Alex
  • Alex404
    Alex404 Global Mapper User Trusted User
    edited September 2010
    Hi,

    after having tested the functionality, I licensed the Version 12 today and set up the productive environment.

    My normal batch process uses sets of shapefiles of about 150-200 MB each. I tried a test run with a small subset of 80 MB. I started the script about half an hour ago...

    The merging islands function was finished in some seconds, but the call of the delete duplicates somehow really takes time.

    The status bar stopped on 34%
    5276873.jpg

    My PC is bored. 7 of 8 cpu cores are idling around and 10GB memory is free. GM only uses one cpu core.
    5276874.jpg

    I have a 64bit Win7 and GM 64bit. Why is this so slow?

    (by the way the process is still running...:()

    Best regards,
    Alex
  • global_mapper
    global_mapper Administrator
    edited September 2010
    Global Mapper will currently only make use of a single core. The duplicate finding process can take a while sometimes, especially if you have a large number of features to check against. I did go ahead and add a progress bar for it so you can at least tell how much is left. I have placed a new build at http://www.globalmapper.com/global_mapper12.zip with the change for you to try. Simply download that file and extract the contents into your existing v12.xx installation folder to give it a try. If you are using the 64-bit v12 version there is a new build at http://www.globalmapper.com/global_mapper12_64bit.zip .

    Let me know if I can be of further assistance.

    Thanks,

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