You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Spatially enabled dataframe (SEDF) cant be inserted as a featurelayer into an existing feature service when created without gis context in the first place (result in AttributeError: 'GeoAccessor' object has no attribute '_gis')
#2068
Open
vmarquar opened this issue
Sep 24, 2024
· 3 comments
Describe the bug
When creating a SEDF from a dict without having a gis-context there in the first place (or by creating a SEDF with any other method, e.g. derived from a pd.merge()), following bug occurs: AttributeError: 'GeoAccessor' object has no attribute '_gis'
To Reproduce
Steps to reproduce the behavior:
importpandasaspdfromarcgis.featuresimportGeoAccessor, GeoSeriesAccessorfromarcgis.geometryimportGeometryfromarcgis.gisimportGIS# Convert dictionary to DataFramedata= {
'name': ['Location A', 'Location B'],
'latitude': [34.05, 40.71],
'longitude': [-118.24, -74.01]
}
df=pd.DataFrame(data)
# Create a geometry column using latitude and longitudedf['SHAPE'] = [{'x': lon, 'y': lat} forlon, latinzip(df['longitude'], df['latitude'])]
# Convert DataFrame to a Spatially Enabled DataFrame (SeDF)sedf=pd.DataFrame.spatial.from_xy(df, x_column='longitude', y_column='latitude', sr=4326)
# Set the spatial reference (optional)sedf.spatial.set_geometry('SHAPE')
# Check if its really a SEDFasserttype(sedf) ==pd.DataFrame, "not a pd.Dataframe class!"asserttype(sedf.spatial) ==GeoAccessor, "there is no 'spatial' namespace. Not a valid SEDF!"# Print the SeDFprint(sedf)
# Insert the SEDF to an existing feature serviceFEATURE_SERVICE_ITEM_ID="<<<ADD A VALID ITEM ID HERE>>>"gis=GIS("home")
feature_service_item=gis.content.get(FEATURE_SERVICE_ITEM_ID)
new_sublayer_name="my new featurelayer name from a example sedf"feature_service_item=sedf.spatial.insert_layer(feature_service=feature_service_item,
gis=gis,
service_name=new_sublayer_name)
#<<< OR ALTERNATIVELY BY OMITTING THE gis=gis argument>>>feature_service_item=sedf.spatial.insert_layer(feature_service=feature_service_item,
service_name=new_sublayer_name)
both variations of sedf.spatial.insert_layer() result in this
error:
Expected behavior
The newly created sedf should be added as a new feature layer inside the existing featureservice.
Platform (please complete the following information):
OS: Windows 11, Linux ArcGIS Notebooks Basic
Python API Version 2.3.0.3 (both on Windows and Linux / Notebook)
Additional context
The abovemention error was tested using a default / basic ArcGIS Notebook inside AGOL and additionally inside a custom windows 11 conda environment.
The text was updated successfully, but these errors were encountered:
Describe the bug
When creating a SEDF from a dict without having a gis-context there in the first place (or by creating a SEDF with any other method, e.g. derived from a
pd.merge()
), following bug occurs:AttributeError: 'GeoAccessor' object has no attribute '_gis'
To Reproduce
Steps to reproduce the behavior:
both variations of
sedf.spatial.insert_layer()
result in thiserror:
Expected behavior
The newly created sedf should be added as a new feature layer inside the existing featureservice.
Platform (please complete the following information):
Additional context
The abovemention error was tested using a default / basic ArcGIS Notebook inside AGOL and additionally inside a custom windows 11 conda environment.
The text was updated successfully, but these errors were encountered: