Python

1790
5
Jump to solution
03-03-2021 03:31 AM
KalSsin
New Contributor III

Hi~~~

I want to fill in the Location field.

 

I want to write the country name in "Europe_city" in a specific polygon.

Python Window, please~~~

 

Thank You~~~

 

import arcpy

arcpy.env.workspace = 'D:/Europe/Europe21.gdb'

feature_class = 'Europe_city'

feature_class = 'nation4'

 

 

gg.jpg

0 Kudos
1 Solution

Accepted Solutions
DavidPike
MVP Frequent Contributor

I'm not sure this is a problem where Python is really the best way, unless you had some sort of existing table or dictionary where the cities were mapped against the country (I appreciate this is only an example you have provided for another problem).

I would suggest a Spatial Join to add a new field 'Country' or 'Location' to your cities FC, whereby if the Cities FC intersects a Country polygon, the name of that country is transferred from the Country FC to the Cities FC. Spatial Join (Analysis)—ArcGIS Pro | Documentation

You would of-course need a Countries FC but that data is widely available.

View solution in original post

5 Replies
KalSsin
New Contributor III

What I'm trying to do is something else. It's hard to explain as an example, so I ask you a question on a European map.

0 Kudos
DavidPike
MVP Frequent Contributor

I'm not sure this is a problem where Python is really the best way, unless you had some sort of existing table or dictionary where the cities were mapped against the country (I appreciate this is only an example you have provided for another problem).

I would suggest a Spatial Join to add a new field 'Country' or 'Location' to your cities FC, whereby if the Cities FC intersects a Country polygon, the name of that country is transferred from the Country FC to the Cities FC. Spatial Join (Analysis)—ArcGIS Pro | Documentation

You would of-course need a Countries FC but that data is widely available.

KalSsin
New Contributor III

Thank you.
However, it is a problem that cannot be solved with a special join.

What I'm doing is not the above.
It's just an example of Europe, which is easy to explain to find an answer.

0 Kudos
DavidPike
MVP Frequent Contributor

Probably best to attempt to explain the actual problem.

0 Kudos
KalSsin
New Contributor III

I lacked understanding of the special join.
I got the answer I wanted.

I'm sorry and thank you very much.