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.637714 41.887275)

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 coordiate 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.seattle.gov/resource/n99g-k8uj.json?$where=intersects(the_geom, 'POINT (-122.4218242 47.662893)')

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 North Seattle:

https://data.seattle.gov/resource/n99g-k8uj.json?$where=intersects(the_geom, 'POLYGON((-122.34649658203125 47.70171863436363,-122.39524841308594 47.6559500873343,-122.29568481445312 47.6559500873343,-122.34649658203125 47.70171863436363))')