If you letters and words are all uppercase or lowercase in a field, and you want to capitalize the fist letter of each word. We have some straight-forward Python code just for you.
And all you'll need is the field calculator in ArcGIS(ArcMap) combined with a bit of Python.
This step-by-step guide will help you get started:
What this Tutorial will accomplish
We will simply take any field, and change the first character to a capital letter. The other letters in the word will be lower case.
For Example:
- BANTEAY MEAN CHEY will become Banteay Mean Chey
- Banteay mean chey will become Banteay Mean Chey
Capitalize Words Python ArcMap Tutorial
STEP1: Create a new text field called 'Eng_Name'. This text field will be used to store the capitalized words. Make the text length property large enough to hold all of text from the other field.
Now, there should be a new text field called Eng_Name in your table:
STEP2: Right-click the new field 'Eng_Name'. Select the 'Field Calculator' option.
STEP3: Select the Python radio button. In the expression text box, double-click the field with the existing text field that you want to capitalize the first letter. Type .title() after the field and press OK. Type it exactly like that. Here's an example of the field calculator code block:
See the result - a new field with capital letters:
If you are getting an error, try to the following:
- Run this python code block by selecting the records first.
- Do not capitalize .title() with a capital 'T'
Capital Letter Results with ArcMap and Python
Python has a simple solution to capitalize the first letter in a text field.
You can also convert strings to all lowercase in a text field using the .lower() property. The .upper() returns a copy of a strong with all the cases characters converted to uppercase.
From titles to lowercase to uppercase...
Use these handy python string operators as huge time-saves for your big data sets.
Resource : GISGeography
0 comments:
Post a Comment