global mapper 12
+ Reply to Thread
Results 1 to 6 of 6
  1. #1
    Alex404 is offline Global Mapper User
    Join Date
    Jul 2010
    Posts
    3
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Question Adding attributes

    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

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

    Default

    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

  3. #3
    Alex404 is offline Global Mapper User
    Join Date
    Jul 2010
    Posts
    3
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default

    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

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

    Default

    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

  5. #5
    Alex404 is offline Global Mapper User
    Join Date
    Jul 2010
    Posts
    3
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default

    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

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

    Default

    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

Similar Threads

  1. Adding to 3D Features
    By Mike Truly in forum Technical Support
    Replies: 2
    Last Post: 04-07-2010, 05:50 PM
  2. Adding attributes from point feature to area feature
    By mirlz in forum Technical Support
    Replies: 2
    Last Post: 03-10-2010, 01:19 PM
  3. Adding attributes to features from a text file
    By mirlz in forum GIS Data Sources
    Replies: 5
    Last Post: 03-09-2010, 08:39 AM
  4. Adding new layers
    By geophysguy in forum Technical Support
    Replies: 3
    Last Post: 07-29-2009, 04:12 PM
  5. Adding to a Layer in a WorkSpace
    By mnlovell in forum Technical Support
    Replies: 1
    Last Post: 08-27-2008, 01:23 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