Select to view content in your preferred language

Spatial Queries, Spatially Enabled DataFrames

1734
4
Jump to solution
01-16-2019 06:39 AM
OisinSlevin
Occasional Contributor

Hi Guys, 

Attempting to use the new "Spatially Enabled DataFrame " after getting familiar with Spatial Dataframes.
The new version seems to have some functionality of "Spatial" queries stripped out ? There's no "within", "contains", "touches" etc. at a DataFrame level only at Series level?

example:

gis = GIS("url", "user", password)
content=gis.content.get("ID") 

layers=content.layers

points=pd.DataFrame.spatial.from_layer(layers[0])

polygons=pd.DataFrame.spatial.from_layer(layers[1])

if I try to take a polygon and find what points are within it I can no longer run a single query
as such :

Using SpatialDataFrame I Can use this piece of code:

a_polygon=polygons.ix[0]

result = points.within(a_polygon.SHAPE) ## returns true/false for each point denoting if inside the polygon.
points_inside_polygon= points.loc[result] ## gives total list of points inside of the polygon.

is there still a way to run a group query as I can only run a one by one test ?

Ex: 

points.ix[0].SHAPE.within(polygons.ix[0].SHAPE) ## returns true/false if single point is within the polygon 

Using version 1.5.2 of ArcGis.

Also all the examples using the spatially Enabled DataFrame from your documentation are using simple SQL queries on the text fields. Spatial queries should be based on the geometries not the fields associated with geometries.

0 Kudos
1 Solution

Accepted Solutions
by Anonymous User
Not applicable

Try doing something like:

// polygons that contain a point
contains = dataframe["SHAPE"].geom.contains(some_point_geometry)

View solution in original post

4 Replies
by Anonymous User
Not applicable

Try doing something like:

// polygons that contain a point
contains = dataframe["SHAPE"].geom.contains(some_point_geometry)
OisinSlevin
Occasional Contributor

Thanks Aaron. Is there anywhere where these types of spatial queries are documented, or examples as I can only find SQL queries on Spatially enabled Dataframes 

0 Kudos
by Anonymous User
Not applicable

Oisin, I believe they are documented here arcgis.features module — arcgis 1.5.2 documentation 

I'm not sure about any examples, beyond Introduction to the Spatially Enabled DataFrame | ArcGIS for Developers  which doesn't seem to show using the geom accessor. 

OisinSlevin
Occasional Contributor

Thanks all the same, its seems crazy to me to have a spatial system and only show examples of data queries using sql. I've been digging through the docs arcgis.features module — arcgis 1.5.2 documentation  already. and the introduction piece is utterly useless of spatial data.