ST_Within(g1,g2)
Returns 1 (TRUE)
or 0 (FALSE)
to indicate whether the first geometry, g1
, is spatially within
a second geometry, g2
.
Parameters
Parameter | Type | Description |
---|---|---|
g1 |
geometry |
Defines a geospatial area using the WKT notation |
g2 |
geometry |
Defines a geospatial area using the WKT notation |
Returns
Boolean
Example
SELECT * FROM geospock.default.largetable AS large
WHERE ST_Within(ST_Point(large.latitude, large.longitude), ST_GeometryFromText('POLYGON((10 10, 10 20, 20 10, 10 10))'));
Usage
To test whether an event is within a geometry as defined in a POI table, your query might look something like this:
SELECT * FROM geospock.default.eventtable AS event
JOIN geospock.default.poitable AS poi ON ST_Within(ST_Point(event.latitude, event.longitude), ST_GeometryFromText(poi.geometry));