in ,

Step by step instructions to Capitalize the First Letter in a Field Using Python in ArcGIS

Capitalize words using Python

If your letters and words are all uppercase or lowercase in a field, and you need to underwrite the main letter of each word.

We have some straight-forward Python code only for you.

And all you’ll require in the field adding machine 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 principal character to a capital letter. Different letters in the word will be lower case.

For instance:

 SAN FRANCISCO will become San Francisco

 san Francisco will become San Francisco

 saN Francisco will become San Francisco

So the first letter will be capitalized using some Python code.

Stage 1 Create a new text field called “Capitals”


This text field will be used to store the capitalized words. Make the text length property large enough to hold all of the text from the other field.

add field

Now, there should be a new text field called capitals in your table:

capitals new field

Step 2 Use field calculator

Right-click the new field “Capitals”.

Select the ‘Field Calculator’ option.

field calculator

Step 3 Enter Python code

First, 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.

Here’s an example of the field calculator code block:

python code title

If you see the result, it has a new field with capital letters.

capitals field calculator result

If you’re 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 string with all the cases characters converted to uppercase.

From titles to lowercase to uppercase….

Use these handy Python string operators as huge time-savers for your big data sets.

READ MORE: 10 Python Libraries for GIS and Mapping


Introduction to Python in ArcGIS Pro


For More Latest Articles Click on Below Link

https://www.worldofitech.com/category/analysis/

salman khan

Written by worldofitech

3 Comments

Leave a Reply
  1. Whats up very nice site!! Guy .. Beautiful .. Wonderful ..
    I’ll bookmark your site and take the feeds also? I’m glad to search out numerous useful information right
    here in the publish, we’d like work out more techniques in this regard, thank you for sharing.

    . . . . .

Leave a Reply

Step by step instructions to Fill NoData for Raster Data

Step by step instructions to Calculate Root Mean Square Error (RMSE) in Excel