How best to split layer into groups based on search vector data queries?
kbellis
Global Mapper UserTrusted User
Objective
Thousands of assessors parcels with many land use CAMA codes (MSLANDUSEC), but which can be broken into 9 basic groups. I've been doing this manually, but am now a volunteer on the Ellsworth Broadband Committee and receiving updated parcel files more frequently from the assessor, and would like to automate this process. I would also like to automate the styling of the new layers at the same time.
Manual approach
The manual approach that I've taken was to perform a Search Vector Data query, select all of the results, copy those results, place them on their own new layer, and then style. This would be done all all 9 major land use groups. For example, below is for the first group, 1000 - Residential, using the following query:
%MSLANDUSEC% >= 1000 and %MSLANDUSEC% < 2000
First failures
Before reaching out here on the forum for guidance, I tried and failed:
Thank you in advance for how best to split layer into groups based on search vector data queries.
Kind regards,
Kelly
Tagged:
Answers
-
Hi Kelly,
You can use a command like this for each of your groups, repeating the statement with the desired minimum and maximum values, and output layer name.EDIT_VECTOR FILENAME="%LAYER% "COPY_TO_NEW_LAYER=YES NEW_LAYER_NAME="CAMA - 1000" \
COMPARE_STR="MSLANDUSEC>=1000" COMPARE_STR="MSLANDUSEC<2000" COMPARE_OP="ALL" COMPARE_NUM=YESA more advanced approach would be to use the DEFINE_VAR_TABLE command to create a table of minimum and maximum values, and loop through the table using VAR_LOOP_START and VAR_LOOP_END.
Cheers,
Bob -
Thank you so much Bob, I very much appreciate your help. I will study what you've outlined and the links that you have kindly provided.Kind regards,Kelly
-
Apparently, there can't be any gaps between these:
<attr_name><operator><attr_value>
Because the new layer only resulted after I removed the gaps: -
Hi Kelly,
Oops. I forgot that detail. I have edited the example. Thanks.
Cheers,
Bob -
Seems like the anomalies are always a snag. In trying to deal with non-conforming CAMA coding, in the manual operation using Search Vector Data, I used
%MSLANDUSEC% < 1000 and %MSTYPE% <> 'WATER'
Which resulted in 592 featuresBut when trying to approximate this operation through scripting, there are only 408 featuresNote that I've commented out the COMPARE_NUM=YES. This is because 1) we've got values like 999V, and 2) we've got (null) values. When the COMPARE_NUM=YES is included in the script and allowed to run, the results dropped to 291 features.
-
PS. I tested using <> in the script. It seemed to work, even though it wasn't listed as a legal operator in Global Mapper Scripting Reference, Section 10:Edit Vector Data.
-
EDIT_VECTOR FILENAME="%LAYER%" COPY_TO_NEW_LAYER=YES NEW_LAYER_NAME="CAMA Non-conforming" COMPARE_STR="MSLANDUSEC=999V" COMPARE_STR="MSLANDUSEC<1000" COMPARE_STR="MSTYPE<>WATER" COMPARE_OP="ALL" AREA_TYPE="CAMA Non-conforming"
This results in zero features.But using only:EDIT_VECTOR FILENAME="%LAYER%" COPY_TO_NEW_LAYER=YES NEW_LAYER_NAME="CAMA Non-conforming" COMPARE_STR="MSLANDUSEC=999V" COMPARE_STR="MSTYPE<>WATER" COMPARE_OP="ALL" AREA_TYPE="CAMA Non-conforming"
results in 201 features; i.e., all with MSLANDUSEC=999V
It seems that both COMPARE_STR comparisons; i.e., COMPARE_STR="MSLANDUSEC=999V" and COMPARE_STR="MSLANDUSEC<1000", don't play nice together.
-
Crying uncle, unable to script for the non-conforming (shown in red above) and putting a pin in it, I moved on this afternoon and tried the DEFINE_VAR_TABLE approach.I obviously have no clue what I'm doing. And please don't take this the wrong way, but who ever wrote the Global Mapper Scripting Reference clearly knows what they're talking about; however, it's written as if they are writing for somebody who already knows what they're talking about.
Categories
- 12.7K All Categories
- 5.6K Features Discussion
- 342 Downloading Imagery
- 1.3K Elevation Data
- 380 Georeferencing Imagery Discussion
- 628 GM Script Language
- 53 User Scripts
- 113 GPS Features
- 414 Projection Questions
- 819 Raster Data
- 1.3K Vector Data
- 6.6K Support
- 177 Announcement and News
- 908 Bug Report
- 558 SDK
- 1.2K Suggestion Box
- 3.7K Technical Support
- 562 Other Discussion
- 129 GIS Data Sources
- 27 Global Mapper Showcase
- 233 How I use Global Mapper
- 107 Global Mapper Forum Website