intersects(...)

intersects(...)

Allows you to compare two geospatial types to see if they intersect or overlap each other

Works with the following datatypes:

This function works with 2.1 endpoint(s). What does this mean? »

The intersects(...) function is most commonly used in the $where parameter or WHERE clause as a filter for Point , Line , and Polygon fields, to identify records that intersect or overlap with another. It accepts two parameters:

WKT is a standard way of encoding geospatial data in a textual manner, and is more compact than GeoJSON. For example, a Point would be encoded as:

POINT (-87.6174045 41.8669236)

Heads up! Contrary to the normal convention of "latitude, longitude" ordering in the coordinates property, Well-known text orders the coordinates as "longitude, latitude" (X coordinate, Y coordinate), as other GIS coordinate systems are encoded.

The intersects(...) method is frequently used to identify what Polygon a given point is within. For example, the below query will identify what park a given point is within:

https://data.cityofchicago.org/resource/ejsh-fztr.json?$where=intersects(the_geom, 'POINT (-87.6174045 41.8669236)')

It’s also useful for intersecting polygons with other polygons. For example, the following will return all of the parks that intersect with an arbitrary triangle in Chicago:

https://data.cityofchicago.org/resource/ejsh-fztr.json?$select=label,park,location,park_class&$where=intersects(the_geom, 'POLYGON((-87.6174045 41.8669236, -87.6300497 41.866433, -87.6552725 41.8787461, -87.6174045 41.8669236))')