Closed DShokes closed 8 years ago
I found that my workaround results in wrong geometries when the feature object has a different spatial reference. Here is an example: I'd like to add a feature with
"spatialReference":{"wkid":102100,"latestWkid":3857}
to a layer with a different spatial reference, such as
"spatialReference":{"wkt":"PROJCS[\"HENNEPIN COUNTY\",GEOGCS[\"GCS_User_Defined\",DATUM[\"D_User_Defined\",SPHEROID[\"User_Defined_Spheroid\",6378418.941,298.2572242549207]],PRIMEM[\"Greenwich\",0.0],UNIT[\"Degree\",0.0174532925199433]],PROJECTION[\"Lambert_Conformal_Conic\"],PARAMETER[\"False_Easting\",500000.0],PARAMETER[\"False_Northing\",100000.0],PARAMETER[\"Central_Meridian\",-93.38333333333334],PARAMETER[\"Standard_Parallel_1\",44.88333333333333],PARAMETER[\"Standard_Parallel_2\",45.13333333333333],PARAMETER[\"Latitude_Of_Origin\",44.79111111111111],UNIT[\"Foot_US\",0.3048006096012192]]"}
The REST API allows you to add features like
[{"attributes":{"OBJECTID":1,"LASTUPDATE":1461686409131},"geometry":{"x":-10400546.7493,"y":5605711.085699998,"spatialReference":{"wkid":102100,"latestWkid":3857}}}]
The service automatically projects the geometry to its own spatial reference. Here is the resulting added feature with adjust geometry:
{"objectIdFieldName":"OBJECTID","globalIdFieldName":"GlobalID","geometryType":"esriGeometryPoint","spatialReference":{"wkt":"PROJCS[\"HENNEPIN COUNTY\",GEOGCS[\"GCS_User_Defined\",DATUM[\"D_User_Defined\",SPHEROID[\"User_Defined_Spheroid\",6378418.941,298.2572242549207]],PRIMEM[\"Greenwich\",0.0],UNIT[\"Degree\",0.0174532925199433]],PROJECTION[\"Lambert_Conformal_Conic\"],PARAMETER[\"False_Easting\",500000.0],PARAMETER[\"False_Northing\",100000.0],PARAMETER[\"Central_Meridian\",-93.38333333333334],PARAMETER[\"Standard_Parallel_1\",44.88333333333333],PARAMETER[\"Standard_Parallel_2\",45.13333333333333],PARAMETER[\"Latitude_Of_Origin\",44.79111111111111],UNIT[\"Foot_US\",0.3048006096012192]]"},"fields":[{"name":"LASTUPDATE","type":"esriFieldTypeDate","alias":"Last Update Date","sqlType":"sqlTypeOther","length":8,"domain":null,"defaultValue":null}],"features":[{"attributes":{"LASTUPDATE":1461766044828},"geometry":{"x":487983.95996925281,"y":139517.29996988285}}]}
ArcREST feature objects returned from a query have a feature._wkid
, but feature.geometry.spatialReference
is None and not editable.
This might explain some of the trouble copying/inserting geometries that I'm seeing.
I tried
feature1.set_value('geometry', feature2.get_value('geometry'))
and it returnedTrue
. I was expecting to see the feature1 object updated, butfeature1.get_value('geometry')
didn't change. This works for attribute fields.Could this be fixed by adding an elif to the set_value function? Such as:
The alternative is accessing private variables:
feature1._dict['geometry'] = feature2.get_value('geometry')