OGR format conversion

OGR format conversion #


Find/Replace/Append #

From time to time I need to edit attributes in the MAPublisher MAP Attributes table. Typically this is for formatting the names of features before generating labels. This example is working with the WPDA dataset and labeling a subset of the polygons. In this case I wanted to label all of the National Parks. Some of the values in the NAME field had “National Park” somewhere in the name, sometimes at the beginning, sometimes at the end.

Attributes in Question: Some values have “National Park”, others don’t

So, we need an expression that looks to see if the string “National” exists. If it does, leave the NAME value alone, if it doesn’t, then append “National Park” to the end of the existing value. Without further ado, the expression:

IF(CONTAINS(NAME,"National"),NAME,NAME & " " & "National Park")

This expression says:

  1. If the value in NAME contains “National”…
  2. then replace with NAME (ie-leave it alone),
  3. if it doesn’t contain “National”, replace the value with the existing NAME value and append the string “National Park”.

Apply the expression via the “Apply Expression” option in the flyout menu of the MAP Attributes table:

And the features in question have the correct string, “National Park”, applied to them:


Select Empty Fields #

The key here is to have an empty space between the quote marks

COLUMN_NAME=" "

Concatenate two fields #

(column 1)& " " &(column 2)

#importing via sql SELECT * FROM streets WHERE streets.RTETYP = 5400

Explain this code
![sql explanation](../../images/mp-attribs-explain.png) 1. If the value in NAME contains “National”... 2. then replace with NAME (ie-leave it alone), 3. if it doesn’t contain “National”, then replace the value with the existing NAME value and append the string “National Park”.