Esri / Esri/arcgis-python-api

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

Offen
#1,180 2 Kommentare 1 Reaktion 1 zugewiesene Person Beansprucht von @nanaeaubry Auf GitHub ansehen
enhancement on-hold
Vorherrschende Sprache
Python
Sterne
2.2k
Forks
1.2k
Ø Merge
2 Std. 40 Min.
Gemergte PRs (30 T.)
2

Beschreibung

**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:
```python
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:
```python
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.

Beitragsleitfaden

Beitragsleitfaden öffnen

Bewertung

Dieses Issue wurde noch nicht bewertet.

Neue Issues direkt in Ihr Postfach

Eine kurze Übersicht über anfängerfreundliche GitHub-Issues.