How to plot a specific geometry column of Spatial enabled DataFrames?

178
4
11-26-2022 06:27 AM
Labels (2)
TomGeo
by
Occasional Contributor III

I am just getting started with SeDF and I was wondering on how I can actually visualize objects with multiple geometries.

Following the introduction, a buffer geometry is added to the dataframe. The map widget of my notebook is however, only showing the points. How can I visualize the buffer geometries?

Is there a way to specify what geometry column should be used for the visualization?

 

 

# generates map widget visulizing the points, though info widgets places two objects there, when I click on a point
point_df.spatial.plot()
# AttributeError: 'Series' object has no attribute 'spatial'
point_df.Buffer_2.spatial.plot()
# Since plot generates a MapView, the object is not subscriptable
point_df.spatial.plot()['Buffer_2']
# or has no attribute 'Buffer_2'
point_df.spatial.plot().Buffer_2

 

 

- We are living in the 21st century.
GIS moved on and nobody needs a format consisting out of at least three files! No, nobody needs shapefiles, not even for the sake of an exchange format. Folks, use GeoPackage to exchange data with other GIS!
0 Kudos
4 Replies
DavidAnderson_1701
Occasional Contributor

In theory the set_geometry method of the spatial data frame should work.

https://developers.arcgis.com/python/api-reference/arcgis.features.toc.html

However, my testing shows that it does not work.   For example this works

sedf['buffer_2'] = sedf.SHAPE.geom.buffer(distance=200)

sedf.spatial.set_geometry('buffer_2',inplace=True)

This command 

sedf.spatial.geometry_type

returns 

['polygon']

 

However this command 

ap_sedf[0:100].spatial.area

returns

0.0

Which for a polygon feature should not be a not zero value.  The plot function also fails to plot big circles.

My take on this is that the spatially enabled dataframe implementation has some issues and bugs.

 

TomGeo
by
Occasional Contributor III

Yes, together with a colleague I tried today the set_geometry method and we experienced the same, also the issues with plotting the geometry into the map widget we can confirm. 

Thanks for looking into it and the test with geometry_type and testing against the geometries area. 

- We are living in the 21st century.
GIS moved on and nobody needs a format consisting out of at least three files! No, nobody needs shapefiles, not even for the sake of an exchange format. Folks, use GeoPackage to exchange data with other GIS!
0 Kudos
DavidAnderson_1701
Occasional Contributor

As a followup, I tried creating the data using the Pro toolbox,then importing as a SEDF.  That worked.   A bit more experimentation showed that it was the number of colums in the dataframe.  Subsetting the test dataframe to use the X and Y columns then creating the SEDF worked.

0 Kudos
DavidAnderson_1701
Occasional Contributor

Welcome. 

BTW, I agree with your tag line about geopackages.  

0 Kudos