Geographic Information Systems Asked by hherrmann on January 23, 2021
I am very new to Python and my first attempt hasn’t gone too well. I’m trying to overwrite a field that is a spatial join of a couple of features in order to, in the end, generate a beginning and ending street intersections listing.
Here is a link to my table. The field I’m trying to overwrite is the IntersectionList
field.
As you can see, the IntersectionList
has the SECONDARYN
field names included due to the spatial join. All I need now, are those streets that are not in the SECONDARYN
field in order to create a beginning/ending street listing.
Here is a visual example of what I’m trying to accomplish.
This is the code I tried to use via the Calculate Field tool:
fixUpIntersections(!IntersectionList!, !FULLNAME!)
def fixUpIntersections(listAsString, streetname):
names = listAsString.split(" & ")
uniqueNames = list(set(names))
if len(uniqueNames) == 1:
return uniqueNames[0]
uniqueNames.remove(streetname)
return ' & '.join(sorted(uniqueNames))
I thought with the error I received, it meant that maybe I should !FULLNAME!
to !SECONDARYN!
, in order to get rid of those streets in the IntersectionList
but when I tried that, it just deleted all data in the IntersectionList
. Running the tool with the code exactly as shows above without changing !FULLNAME!
, it resulted in the following error: ERROR 000539: Invalid field FULLNAME
I’ve dug around the site here but haven’t been able to figure out my problem. I have a long way to go to learn Python.
The first thing that I would check is whether your feature class has a field called FULLNAME
.
The error message that you are receiving suggests that it does not.
Correct answer by PolyGeo on January 23, 2021
Get help from others!
Recent Questions
Recent Answers
© 2024 TransWikia.com. All rights reserved. Sites we Love: PCI Database, UKBizDB, Menu Kuliner, Sharing RPP