Spatial Data Frame to Feature Layer - Spatial Reference

05-30-2019 08:58 AM
Occasional Contributor

I am trying to create a new feature layer from an existing one using this code,

This works but when I look at the REST endpoint in AGOL the Spatial Reference is 102100.

Then I tried to project the newly created feature layer as a spatial data frame, then save it as a new projected feature layer, the project function returns true, still the Spatial Reference is 102100.

When the spatial data frame is created in the first line, it is still 102698, I beloeve the to_featurelayer function is creating the data as 102100.

Oddly, when I download the file geodatabase that is used to create the feature layer, and look at it is Arc Catalog the feature class is on 102698.

addrSDF = fl.query(where=whr, out_fields=flds, out_sr=102698).sdf

newItem = addrSDF.spatial.to_featurelayer('NewAddresses',gis)
SR = SpatialReference(iterable={"wkid":102698})
newfl = FeatureLayerCollection.fromitem(newItem).layers[0]

newSDF = pd.DataFrame.spatial.from_layer(newfl)

retVal = newSDF.spatial.project(SR,None)


newFlPrj = newSDF.spatial.to_featurelayer('NewAddresses_Prj',gis)
0 Kudos
1 Reply
New Contributor III

Far as I can tell, publishing from SEDF to feature layer ignores the SR set in the SEDF.  I haven't yet found a way to explicitly set the SR when publishing.  Seems that the only option is to re-project the feature layer after it's published.  (I'm still trying to figure that out.) 

I hope someone will post here with a happier alternative.

0 Kudos