Script for adding new attribute to areas based on existing attribute

I have shape file of building shapes, each with a maximum elevation attribute (MAX_ELEV_M). Typically, I will perform a search to find the areas that have a maximum height within a certain range and then add a new attribute to indicate the number of storeys. So, everything between 6.001m and 9m will get a new attribute called "Height Range" with a value "2 Storeys"

I have tried to make a script to do that but I keep getting errors. Could someone have a look and see what I am doing wrong?

GLOBAL_MAPPER_SCRIPT VERSION="1.00"

EDIT_VECTOR COMPARE_STR=MAX_ELEV_M>=6.001 COMPARE_STR=MAX_ELEV_M<=9 NEW_ATTR="Height Range" VALUE="2storeys" 

Thanks!

p.s. This script should work on loaded data, which is why I have not specified in file to import.

Best Answers

  • bmg_bobbmg_bob Global Mapper Programmer Posts: 2,070
    Answer ✓
    Hello,

    You need to use the ATTR_VAL parameter instead of NEW_ATTR and VALUE, which are not valid parameters on the EDIT_VECTOR command.  For example:
    EDIT_VECTOR COMPARE_STR="MAX_ELEV_M>=6.001" COMPARE_STR="MAX_ELEV_M<=9" ATTR_VAL="HEIGHT RANGE=2STOREYS"
    Cheers,
    Bob
  • bmg_bobbmg_bob Global Mapper Programmer Posts: 2,070
    Answer ✓
    UIMapper said:
    Now I have discovered another problem. When I run the COMPARE_STR commands as below, the script returns values which are outside the range specified.
    So, it will return everything between 6 and 9, but also everything between 60 and 90. Is there something wrong with the syntax of the script? 

    Copied below again for reference.

    EDIT_VECTOR COMPARE_STR="MAX_ELEV_M>=6.001" COMPARE_STR="MAX_ELEV_M<=9" ATTR_VAL="HEIGHT RANGE=2STOREYS"
    Hello,

    Add COMPARE_NUM=YES to the EDIT_VECTOR command. This will use numeric comparisons instead of text comparisons.

    Cheers,
    Bob

Answers

  • UIMapperUIMapper Posts: 10
    bmg_bob said:
    Hello,

    You need to use the ATTR_VAL parameter instead of NEW_ATTR and VALUE, which are not valid parameters on the EDIT_VECTOR command.  For example:
    EDIT_VECTOR COMPARE_STR="MAX_ELEV_M>=6.001" COMPARE_STR="MAX_ELEV_M<=9" ATTR_VAL="HEIGHT RANGE=2STOREYS"
    Cheers,
    Bob
    Thank you, this works now!
  • UIMapperUIMapper Posts: 10
    Now I have discovered another problem. When I run the COMPARE_STR commands as below, the script returns values which are outside the range specified.
    So, it will return everything between 6 and 9, but also everything between 60 and 90. Is there something wrong with the syntax of the script? 

    Copied below again for reference.

    EDIT_VECTOR COMPARE_STR="MAX_ELEV_M>=6.001" COMPARE_STR="MAX_ELEV_M<=9" ATTR_VAL="HEIGHT RANGE=2STOREYS"
  • UIMapperUIMapper Posts: 10
    bmg_bob said:
    Hello,

    You need to use the ATTR_VAL parameter instead of NEW_ATTR and VALUE, which are not valid parameters on the EDIT_VECTOR command.  For example:
    EDIT_VECTOR COMPARE_STR="MAX_ELEV_M>=6.001" COMPARE_STR="MAX_ELEV_M<=9" ATTR_VAL="HEIGHT RANGE=2STOREYS"
    Cheers,
    Bob
    Thanks so much. Script is working beautifully now.
Sign In or Register to comment.