TransWikia.com

ArcMap adds decimal to string conversion

Geographic Information Systems Asked by Ron Campbell on August 9, 2021

ArcMap dropped the leading zero from the census block ID for California. When I added a new text field, GEOID, in the field calculator with the formula,

GEOID = "0" + str(!BLOCK_2020!)

ArcMap created the text field but populated it with one decimal place — for example, 060014001001001.0.

Any idea what I’m doing wrong?

One Answer

Always use str.format() to control formatting (vice a str cast), then you can do something like:

geoid = "{:015d}".format(long(!block_2020!))

Under Python3 (ArcGIS Pro) that "long" becomes "int":

geoid = "{:015d}".format(int(!block_2020!))

Answered by Vince on August 9, 2021

Add your own answers!

Ask a Question

Get help from others!

© 2024 TransWikia.com. All rights reserved. Sites we Love: PCI Database, UKBizDB, Menu Kuliner, Sharing RPP