Select to view content in your preferred language

WHAT I HAVE PROBLEM WITH THIS EXPRESSION

1244
6
Jump to solution
01-11-2020 11:38 AM
ArmandoFreites
Occasional Contributor

I NEED PUT THE COORDINATE AND THE WORD : NOMBRE, LIKE: 57485.258 NOMBRE

0 Kudos
1 Solution

Accepted Solutions
JoeBorgione
MVP Emeritus

POINT_X and POINT_Y are both numeric type fields.  You will need to add two new fields of String type in order to concatenate the word NOMBRE to it.

Add two new string type field, naming them as you wish.

Then in the field calculator you can copy and paste the following for each of the new fields:

str(!POINT_X!)+' '+'NOMBRE'

str(!POINT_Y!)+' '+'NOMBRE'

This casts the value of each variable to a string and then puts a space between the value and NOMBRE.  You may need to set the format of the POINT_X and POINT_Y fields to the number of decimal places you want to display.

That should just about do it....

View solution in original post

6 Replies
JoeBorgione
MVP Emeritus

POINT_X and POINT_Y are both numeric type fields.  You will need to add two new fields of String type in order to concatenate the word NOMBRE to it.

Add two new string type field, naming them as you wish.

Then in the field calculator you can copy and paste the following for each of the new fields:

str(!POINT_X!)+' '+'NOMBRE'

str(!POINT_Y!)+' '+'NOMBRE'

This casts the value of each variable to a string and then puts a space between the value and NOMBRE.  You may need to set the format of the POINT_X and POINT_Y fields to the number of decimal places you want to display.

That should just about do it....
ArmandoFreites
Occasional Contributor

thanks for your fast and effective answer

0 Kudos
DanPatterson_Retired
MVP Emeritus

To avoid whether you need cast things to strings, learn the python "format" mini-language.  It can all be done on 1 line and is even more powerful than its sibling the f-string.

"{}

 "{} {}".format('a string', 1)  # ---- implicit order
'a string 1'

"{1} {0}".format('a string', 1) # ---- explicit order 
'1 a string'

"{}{}{}".format('stuff', " in between "*3, ['a, b', 1, 2.0])  # ---- it can do anything
"stuff in between  in between  in between ['a, b', 1, 2.0]"
ArmandoFreites
Occasional Contributor

Very good, it´s working. Thanks 

0 Kudos
JoshuaBixby
MVP Esteemed Contributor

Armando Freites‌, please mark one of the responses as Correct to close out your question.  If multiple people gave you good answers, pick the one that helped the most and mark it correct while marking the others as helpful.

ArmandoFreites
Occasional Contributor

Ok ok

0 Kudos