geo.ST_Contains() function

The geo.ST_Contains() function is experimental and subject to change at any time. By using this function, you accept the risks of experimental functions.

The geo.ST_Contains() function tests if the specified region contains the specified geographic information system (GIS) geometry and returns true or false.

*Function type: Test*

  1. import "experimental/geo"
  2. geo.ST_Contains(
  3. region: {lat: 40.7, lon: -73.3, radius: 20.0},
  4. geometry: {lon: 39.7515, lat: 15.08433}
  5. )
  6. // Returns false

Parameters

region

The region to test. Specify record properties for the shape. See Region definitions.

*Data type: Record*

geometry

The GIS geometry to test. Can be either point or linestring geometry. See GIS geometry definitions.

*Data type: Record*

Examples

Test if geographic points are inside of a region
  1. import "experimental/geo"
  2. region = {
  3. minLat: 40.51757813,
  4. maxLat: 40.86914063,
  5. minLon: -73.65234375,
  6. maxLon: -72.94921875
  7. }
  8. data
  9. |> geo.toRows()
  10. |> map(fn: (r) => ({
  11. r with st_contains: geo.ST_Contains(region: region, geometry: {lat: r.lat, lon: r.lon})
  12. }))
Test if tracks are inside of a region
  1. import "experimental/geo"
  2. region = {
  3. minLat: 40.51757813,
  4. maxLat: 40.86914063,
  5. minLon: -73.65234375,
  6. maxLon: -72.94921875
  7. }
  8. data
  9. |> geo.toRows()
  10. |> geo.asTracks()
  11. |> geo.ST_LineString()
  12. |> map(fn: (r) => ({
  13. r with st_contains: geo.ST_Contains(region: region, geometry: {linestring: r.st_linestring})
  14. }))

Related articles

functions geo GIS