Select to view content in your preferred language

Large Point Feature Class: Fastest Way To Transfer Field Values From Overlapping Polygon

106
4
16 hours ago
Labels (3)
Philip_Sarnecki
Emerging Contributor

I have a large point feature class (<2Mill features) and a polygon feature class consisting of multiple polygon features.

The points and polygons overlap.

I'd like to write the polygon field values into their overlapping point features.

Example:

Point feature A lies within polygon feature B -> Write respective value from polygon field "name" into point field "area_name".

What is the fastest way to do this with a python script?

So far i have tried two python scripts:

- Spatial Join (Intersect) -> Join the output with the point feature class -> transfer values using field calculator (from joined field "name" to field "area_name") -> remove join

- Iterate over the polygon (using cursor), in each iteration create a new layer of the current polygon (in memory) -> select overlapping points using location based selection -> write values into selected points

Both methods take too long.

I was thinking about using a Spatially Enabled Dataframe, would this get my task done faster?

0 Kudos
4 Replies
DanPatterson
MVP Esteemed Contributor

How does a standard

Intersect (Analysis)—ArcGIS Pro | Documentation 

or

Pairwise Intersect (Analysis)—ArcGIS Pro | Documentation

compare speed-wise?  

You would get a new featureclass with both sets of fields.  Rather than using a field calculator to update a field, perhaps deleting unnecessary fields might be faster (with a rename if it is really necessary)

Delete Field (Data Management)—ArcGIS Pro | Documentation

Alter Field (Data Management)—ArcGIS Pro | Documentation


... sort of retired...
0 Kudos
Philip_Sarnecki
Emerging Contributor

Oh sorry, i forgot to mention, the original point feature class cannot be replaced. It may be edited but the file itself cannot be deleted or replaced

0 Kudos
JakeSkinner
Esri Esteemed Contributor

@Philip_Sarnecki you may get better performance using an Update Cursor rather than the field calculator.  Ex:

import arcpy

pointFC = r"C:\temp\test.gdb\points"
polygonFC = r"C:\temp\test.gdb\polygons"

# Perform Spatial Join
spatialJoinFC = arcpy.SpatialJoin_analysis(.....)

# Create lookup dictionary
nameDict = {}
with arcpy.da.SearchCursor(spatialJoinFC, ["uniqueId", "area_name"]) as cursor:
    for row in cursor:
        nameDict[row[0]] = row[1]
del cursor

# Update point feature class
with arcpy.da.UpdateCursor(pointFC, ["uniqueId", "name"]) as cursor:
    for row in cursor:
        row[1] = nameDict[row[0]]
        cursor.updateRow(row)
del cursor
Clubdebambos
MVP Regular Contributor

Dictionaries and Update Cursors are also my preferred approach when updating a dataset based on another, avoiding joins and field calculator. 

~ learn.finaldraftmapping.com
0 Kudos