I have a data table with a column 'names' that have street names with street type (Road, Lane, Street etc.). I need to get the names in a format like in column 'new_names'using field calculator in ArcGIS.
How can I do this?
Geographic Information Systems Stack Exchange is a question and answer site for cartographers, geographers and GIS professionals. It only takes a minute to sign up.
Sign up to join this communityI have a data table with a column 'names' that have street names with street type (Road, Lane, Street etc.). I need to get the names in a format like in column 'new_names'using field calculator in ArcGIS.
How can I do this?
Use a dictionary and if/else with list comprehension to replace the words:
Pre-logic:
def replacename( names, new_names):
d = {'Lane':'Ln', 'Road':'Rd', 'Street':'St'}
return ' '.join([d[word] if word in d else word for word in names.split()])
Call with:
replacename( !names!, !new_names!)
If you only want to use the abbreviations for labelling then you could investigate Using an abbreviation dictionary and the About abbreviating and truncating words page:
Abbreviation dictionaries allow the Maplex Label Engine to shorten long labels to fit within small spaces. When you use an abbreviation dictionary, the Maplex Label Engine first attempts to place the full text of the label, then abbreviates any words found in the dictionary for labels that could not be placed.
Abbreviation dictionaries are applied to individual label classes. The abbreviation is applied to a freestanding word or groups of words, not parts of words, with the exception of certain non-English words. Individual words, such as Road and Street, can be abbreviated as Rd or St, or longer strings, such as Post Office, can be abbreviated as PO. Portions of words are not abbreviated. For example, if you have a dictionary entry mapping Road as Rd, the label Roadrunner Road is abbreviated as Roadrunner Rd, not Rdrunner Rd. Labels containing text formatting tags are not abbreviated by the Maplex Label Engine.
Don't know a way to this through ArcMap whithout using python. But you can do it through excel. Use Table to Excel tool, then in excel use Find and Replace. And in arcmap join the excel back to the original table. If you don't have excel you can export the table to csv using Export Feature Attribute to ASCII tool, and then use OpenOffice.