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?
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.
Thanks!
p.s. This script should work on loaded data, which is why I have not specified in file to import.
Tagged:
Answers
-
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!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 -
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,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"
Add COMPARE_NUM=YES to the EDIT_VECTOR command. This will use numeric comparisons instead of text comparisons.
Cheers,
Bob -
Thanks so much. Script is working beautifully now.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
Categories
- 13K All Categories
- 5.8K Features Discussion
- 350 Downloading Imagery
- 1.3K Elevation Data
- 385 Georeferencing Imagery Discussion
- 652 GM Script Language
- 56 User Scripts
- 115 GPS Features
- 421 Projection Questions
- 835 Raster Data
- 1.4K Vector Data
- 6.7K Support
- 181 Announcement and News
- 939 Bug Report
- 562 SDK
- 1.2K Suggestion Box
- 3.7K Technical Support
- 579 Other Discussion
- 132 GIS Data Sources
- 27 Global Mapper Showcase
- 244 How I use Global Mapper
- 110 Global Mapper Forum Website


