arcgis-python-api icon indicating copy to clipboard operation
arcgis-python-api copied to clipboard

SEDF creation using from_df fails if geometry column contains Shapely geometries (instead of strings)

Open cgpeltier opened this issue 3 years ago • 1 comments

Describe the bug A common workflow I use is to create spatially enabled dataframes (SEDFs) from Shapely geometries in a Pandas DataFrame. However, if the geometry column is left as Shapely geometries when trying to convert to an SEDF, then from_df will fail with an error similar to: TypeError: argument of type 'Point' is not iterable.

To Reproduce Steps to reproduce the behavior:

from shapely.geometry import Point, LineString
from arcgis.features import GeoAccessor

points = [Point(40, 40), Point(30,30)]
# points = [str(x) for x in points] ## works if this line is included

df = pd.DataFrame({
    'id' : ['point1', 'point2'],
    'points' : points
})

sedf = pd.DataFrame().spatial.from_df(df, geometry_column = 'points')

error:

TypeError: argument of type 'Point' is not iterable

Screenshots If applicable, add screenshots to help explain your problem.

Expected behavior Ideally we can just check whether the DataFrame column contains Shapely geometries, and if so, then convert those Shapely geometries to strings before trying to make the SEDF from a geometry column.

Platform (please complete the following information):

  • OS: Windows
  • Browser Chrome
  • Python API Version 1.9.1

Additional context Add any other context about the problem here, attachments etc.

cgpeltier avatar Feb 15 '22 19:02 cgpeltier

Hello, we do not currently support this so it is an enhancement request rather than a bug.

For now we recommend: passing the shapely geometry in arcgis.geometry.Geometry() class

The enhancement will be taken into consideration for future releases.

nanaeaubry avatar Mar 14 '22 18:03 nanaeaubry