Is it possible to trim the field used for a label?

Griffon
Global Mapper UserTrusted User
I'm using Global Mapper 14.2.
I have these parcel IDs in the first column of an area shapefile that have a repetitive element in almost every record (such as "22-") that I'd like to trim so that the parcel ID labels are more meaningful and less cluttered when I print out a map.
Exporting the area overlay to a SHP file and opening the DBF in Excel, I can create a new column for the trimmed label, then use an Excel formula such as the following:
=IF(LEFT(A2,3)="22-",MID(A2,4,100),A2)
so that every parcel ID that begins with "22-" will have the first three characters removed. (Some parcel do not begin "22-" so I'd just use the whole parcel ID in those cases.) Then I increase the defined database name to include the new column and open the SHP file in my project, selecting the new Label column for my Selected Attribute Value for Name choice.
Is there a script or allowed formula commands for the Use Custom Formatting String for Name option, so that I don't have to go through this process?
Thanks in advance.
I have these parcel IDs in the first column of an area shapefile that have a repetitive element in almost every record (such as "22-") that I'd like to trim so that the parcel ID labels are more meaningful and less cluttered when I print out a map.
Exporting the area overlay to a SHP file and opening the DBF in Excel, I can create a new column for the trimmed label, then use an Excel formula such as the following:
=IF(LEFT(A2,3)="22-",MID(A2,4,100),A2)
so that every parcel ID that begins with "22-" will have the first three characters removed. (Some parcel do not begin "22-" so I'd just use the whole parcel ID in those cases.) Then I increase the defined database name to include the new column and open the SHP file in my project, selecting the new Label column for my Selected Attribute Value for Name choice.
Is there a script or allowed formula commands for the Use Custom Formatting String for Name option, so that I don't have to go through this process?
Thanks in advance.
Tagged:
Answers
-
Hello,
The Attribute Calculator in Global Mapper 21 supports this functionality via a set of functions that are similar to Excel functions. You can use the Attribute Calculator to create a new attribute formatted as you desire, then use that attribute as the label. I am pretty sure that nothing similar exists in Global Mapper 14.
Cheers,
Bob -
Hi Griffon,
Bob beat me to the punch, but just to amplify what he wrote, as far as I know, there's no way to do this in Global Mapper 14 without resorting to external tools. The Attribute Calculator was added a couple of years later than the version that you're using, if I recall correctly. The formula that you cite -- IF(LEFT(A2,3)="22-",MID(A2,4,100),A2) -- would work as-is in the attribute calculator; Excel formulas were expressly used as a model for the Attribute Calculator formula language. Global Mapper did have (and retains) a simple tool to modify existing attributes (or create new ones), but really only it supports appending text or siingle arithmetic operations, with no conditional operations like IF(), etc.
For what it's worth, the older version was scriptable in GM 14 ising the CALC_ATTR command; the newer formula-based version was scriptable from the version in which it first appeared, using the CALC_ATTR_FORMULA command.
Best regards,
~Jeff -
Thanks Bob and Jeff!
I found a work around, a simple tool I'd never used before:: Search and Replace. I search for 22-* and replaced with *. The cases such as 22-122-2 were not bothered, and the ones not containing any 22- were left alone.
I'm trying to figure out how to write a script for 14.2, but I'm not sure I'm going to get very far on that one. I need some more examples of String handling and IF statements to use as a guide.
Categories
- 12.4K All Categories
- 5.4K Features Discussion
- 314 Downloading Imagery
- 1.3K Elevation Data
- 377 Georeferencing Imagery Discussion
- 603 GM Script Language
- 49 User Scripts
- 112 GPS Features
- 394 Projection Questions
- 800 Raster Data
- 1.3K Vector Data
- 6.5K Support
- 161 Announcement and News
- 890 Bug Report
- 556 SDK
- 1.2K Suggestion Box
- 3.7K Technical Support
- 537 Other Discussion
- 128 GIS Data Sources
- 26 Global Mapper Showcase
- 224 How I use Global Mapper
- 104 Global Mapper Forum Website