AnsweredAssumed Answered

ArcGIS Python API Set Geometry Column of Spatially Enabled Data Frame

Question asked by natevatt_2n on Oct 26, 2018
Latest reply on Nov 2, 2018 by natevatt_2n

I am trying to

1. connect to a PostGIS database

2. Create a Spatially Enabled Data Frame

3. Export out to a feature layer

4. Push to AGOL.  

Of those steps, I have succeeded at number one, but I am getting a error in the process of setting a geometry column in the DataFrame.

 

I have the function `set_geomerty()` does not like the format of the data that i am putting in, which has been text and shapely format.  Is there an ESRI specific format that i should be using or a function that can put the geometry into that format?

 

IDE: Jupyter Notebook

python: 3.6

ArcGIS Python Api: 1.5.0

 

import pandas as pd
from shapely.wkt import loads

conn = config.conn
df = pd.read_sql("select id, ST_AsText(geom) AS geometry from table where group_id = 63 limit 1", con=conn)
df['geometry'] = df['geometry'].apply(lambda x: loads(x))
sdf = df.set_geometry('geometry')


bmp_id geometry
0 Lot_5_78 POINT (-121.799248349 36.6987788232)


~/.virtualenv/esri/lib/python3.6/site-packages/arcgis/features/_data/geodataset/geodataframe.py in set_geometry(self, col, drop, inplace, sr)
1799 # Check that we are using a listlike of geometries
1800 if not all(isinstance(item, GEOM_TYPES) or not item for item in level):
-> 1801 raise TypeError("Input geometry column must contain valid geometry objects.")
1802 #if isinstance(frame[geo_column_name], pd.Series):
1803 # frame[geo_column_name] = GeoSeries(frame[geo_column_name])

TypeError: Input geometry column must contain valid geometry objects.

 

 

Gracias

Outcomes