Arcpy Update Geometry Field with Update Cursor

7145
6
02-22-2017 07:15 AM
DEVAPP
by
New Contributor III

Hi,

i have a feature layer with some records that have Shape filed with value None.

I would like update the Shape field with a correct value and i woul take it by other feature class.

I have seen some code posted here on geonet and this is my script

sourceFC = 'fc_lyr'
sourceField = ['ID_VALUE','SHAPE']
valueDict = {r[0]:(r[1:]) for r in arcpy.da.SearchCursor(sourceFC, sourceField)}

updateFieldsList = ["ID_VALUE", "Shape"]
with arcpy.da.UpdateCursor(updateFC, updateFieldsList) as updateRows:
    for updateRow in updateRows:
        keyValue = updateRow[0]
        print(keyValue)
        if keyValue in valueDict:
            updateRow[1] = valueDict[keyValue][0]
            print(valueDict[keyValue][0])
            updateRows.updateRow(updateRow)

whit this script the field Shape is not update, but if i change the field Shape with some other field and try to update it, the update works.

Why the Sahpe field is not update???

Thanks

Tags (1)
6 Replies
JoshuaBixby
MVP Esteemed Contributor

Instead of "SHAPE", use "SHAPE@".

From the SearchCursor documentation:

Geometry properties can be accessed by specifying the token SHAPE@ in the list of fields.

DanPatterson_Retired
MVP Emeritus

and "OID@"

0 Kudos
DEVAPP
by
New Contributor III

Thanks for your replay.

I have added "SHAPE@" and "OID@" but the result is the same.

The Feature Class of SearchCursor is a Multipoint and the Feature Class to Update is a MakeRouteEventLayer Multipoint.

I'm becoming crazy....the result of update is always 'None' for shape field

Any idea???

Thanks

0 Kudos
DEVAPP
by
New Contributor III

Hi,

thanks for your help.

I have found the solution. In my script i have add a tool FeatureToPoint so i conevrt the multipoint to point Feature Class and so the update cursor between point - point works fine.

Why between multipoint - multipoint doesn't work?

Thanks

0 Kudos
MichaelVolz
Esteemed Contributor

I think you might want to get technical support involved with the multipoint to point issue you are having to see if this is expected behavior of the software to fail or if it's a bug with ESRI software.

0 Kudos
JoshuaBixby
MVP Esteemed Contributor

Are you sure both feature classes were MULTIPOINT?

Whereas OGC simple feature LINESTRING and MULTILINESTRING map to Esri POLYLINE, and OGC simple feature POLYGON and MULTIPOLYGON map to Esri POLYGON, POINT and MULTIPOINT map to separate Esri geometry types.  I have found this causes confusion with users because they get used to storing both single- and multi-part linestrings or polygons in an Esri POLYLINE or POLYGON, respectively, but a multi-point can't be stored in a Esri POINT geometry.

I would assume an error would be generated when trying to insert a MULTIPOINT into a POINT feature class, but should doesn't mean it does.

0 Kudos