User GuidesAPI ReferenceRelease Notes
Doc HomeHelp CenterLog In
User Guides

GIS Functions

Geographic Information System (GIS) functions.

GIS.AREA

Computes the area of geospatial objects in square meters.

SYNTAX

gis.area(geometry)

  • geometry
    • Type: {'type': 'record', 'fullySpecified': True, 'fields': [{'name': 'point', 'type': {'type': 'array', 'elementType': 'double'}}, {'name': 'multiPoint', 'type': {'type': 'array', 'elementType': {'type': 'array', 'elementType': 'double'}}}, {'name': 'lineString', 'type': {'type': 'array', 'elementType': {'type': 'array', 'elementType': 'double'}}}, {'name': 'multiLineString', 'type': {'type': 'array', 'elementType': {'type': 'array', 'elementType': {'type': 'array', 'elementType': 'double'}}}}, {'name': 'polygon', 'type': {'type': 'array', 'elementType': {'type': 'array', 'elementType': {'type': 'array', 'elementType': 'double'}}}}, {'name': 'multiPolygon', 'type': {'type': 'array', 'elementType': {'type': 'array', 'elementType': {'type': 'array', 'elementType': {'type': 'array', 'elementType': 'double'}}}}}]}
    • Description: the geospatial object

OUTPUT

double

EXAMPLE

SELECT gis.area(geo) as area
geoarea
{'point': [-71.12109, 42.37392]}0.0
{'multiPoint': [[-71.12109, 42.37392], [-0.09044, 51.51819]]}0.0
{'lineString': [[-71.12109, 42.37392], [-0.09044, 51.51819]]}0.0
{'multiLineString': [[[-71.12109, 42.37392], [-0.09044, 51.51819]], [[-71.12109, 42.37392], [-122.34771, 37.58016]]]}0.0
{'polygon': [[[-71.12109, 42.37392], [-122.34771, 37.58016], [-0.09044, 51.51819], [-71.12109, 42.37392]]]}7918900575524.063
{'multiPolygon': [[[[-71.12109, 42.37392], [-122.34771, 37.58016], [-0.09044, 51.51819], [-71.12109, 42.37392]]], [[[-71.12109, 42.37392], [-73.99332, 40.73897], [-122.34771, 37.58016], [-0.09044, 51.51819], [-71.12109, 42.37392]]]]}16041977719684.082

GIS.CENTROID

Computes a point in degrees longitude and latitude representing the center of the supplied geospatial object.

SYNTAX

gis.centroid(geo)

  • geo
    • Type: {'type': 'record', 'fullySpecified': True, 'fields': [{'name': 'point', 'type': {'type': 'array', 'elementType': 'double'}}, {'name': 'multiPoint', 'type': {'type': 'array', 'elementType': {'type': 'array', 'elementType': 'double'}}}, {'name': 'lineString', 'type': {'type': 'array', 'elementType': {'type': 'array', 'elementType': 'double'}}}, {'name': 'multiLineString', 'type': {'type': 'array', 'elementType': {'type': 'array', 'elementType': {'type': 'array', 'elementType': 'double'}}}}, {'name': 'polygon', 'type': {'type': 'array', 'elementType': {'type': 'array', 'elementType': {'type': 'array', 'elementType': 'double'}}}}, {'name': 'multiPolygon', 'type': {'type': 'array', 'elementType': {'type': 'array', 'elementType': {'type': 'array', 'elementType': {'type': 'array', 'elementType': 'double'}}}}}]}
    • Description: the geospatial object

OUTPUT

{'type': 'record', 'fullySpecified': True, 'fields': [{'name': 'point', 'type': {'type': 'array', 'elementType': 'double'}}, {'name': 'multiPoint', 'type': {'type': 'array', 'elementType': {'type': 'array', 'elementType': 'double'}}}, {'name': 'lineString', 'type': {'type': 'array', 'elementType': {'type': 'array', 'elementType': 'double'}}}, {'name': 'multiLineString', 'type': {'type': 'array', 'elementType': {'type': 'array', 'elementType': {'type': 'array', 'elementType': 'double'}}}}, {'name': 'polygon', 'type': {'type': 'array', 'elementType': {'type': 'array', 'elementType': {'type': 'array', 'elementType': 'double'}}}}, {'name': 'multiPolygon', 'type': {'type': 'array', 'elementType': {'type': 'array', 'elementType': {'type': 'array', 'elementType': {'type': 'array', 'elementType': 'double'}}}}}]}

EXAMPLE

SELECT gis.centroid(geo) as centroid
geocentroid
{'point': [-71.12109, 42.37392]}{'point': [-71.12109, 42.37391999999999]}
{'multiPoint': [[-71.12109, 42.37392], [-0.09044, 51.51819]]}{'point': [-39.10152000607361, 52.69688466499584]}
{'lineString': [[-71.12109, 42.37392], [-0.09044, 51.51819]]}{'point': [-39.10152000607361, 52.69688466499584]}
{'multiLineString': [[[-71.12109, 42.37392], [-0.09044, 51.51819]], [[-71.12109, 42.37392], [-122.34771, 37.58016]]]}{'point': [-69.39187404549496, 51.97025922215934]}
{'polygon': [[[-71.12109, 42.37392], [-122.34771, 37.58016], [-0.09044, 51.51819], [-71.12109, 42.37392]]]}{'point': [-72.22351438117408, 54.5919087542993]}
{'multiPolygon': [[[[-71.12109, 42.37392], [-122.34771, 37.58016], [-0.09044, 51.51819], [-71.12109, 42.37392]]], [[[-71.12109, 42.37392], [-73.99332, 40.73897], [-122.34771, 37.58016], [-0.09044, 51.51819], [-71.12109, 42.37392]]]]}{'point': [-72.84900918851707, 54.08981154383138]}

GIS.GEOMETRY_ERROR

Tries to decode a field as a geospatial object. It returns null if the argument is valid, and the error message otherwise

SYNTAX

gis.geometry_error(geo)

  • geo
    • Type: {'type': 'record', 'fullySpecified': True, 'fields': [{'name': 'point', 'type': {'type': 'array', 'elementType': 'double'}}, {'name': 'multiPoint', 'type': {'type': 'array', 'elementType': {'type': 'array', 'elementType': 'double'}}}, {'name': 'lineString', 'type': {'type': 'array', 'elementType': {'type': 'array', 'elementType': 'double'}}}, {'name': 'multiLineString', 'type': {'type': 'array', 'elementType': {'type': 'array', 'elementType': {'type': 'array', 'elementType': 'double'}}}}, {'name': 'polygon', 'type': {'type': 'array', 'elementType': {'type': 'array', 'elementType': {'type': 'array', 'elementType': 'double'}}}}, {'name': 'multiPolygon', 'type': {'type': 'array', 'elementType': {'type': 'array', 'elementType': {'type': 'array', 'elementType': {'type': 'array', 'elementType': 'double'}}}}}]}
    • Description: the geospatial object

OUTPUT

string

EXAMPLE

SELECT gis.geometry_error(geo) as error
geoerror
nullnull
{}GeoDecodeException: Geometry struct must have exactly 1 non-null field, but found 0
{'point': [-71.12109, 42.37392], 'multiPoint': [[-71.12109, 42.37392]]}GeoDecodeException: Geometry struct must have exactly 1 non-null field, but found 2
{'point': []}GeoDecodeException: Position must have 2 or 3 coordinates, but found 0
{'point': [null, 0.0]}GeoDecodeException: The first position coordinate must be non-null
{'point': [0.0, null]}GeoDecodeException: The second position coordinate must be non-null
{'point': [181.0, 0.0]}GeoDecodeException: Longitude must be between -180 and 180 degrees, but found 181.0
{'point': [0.0, 91.0]}GeoDecodeException: Latitude must be between -90 and 90 degrees, but found 91.0
{'multiPoint': []}IllegalArgumentException: Multi-geometries must contain at least one input geometry
{'multiPoint': [null]}GeoDecodeException: Inner arrays must not contain null
{'lineString': [[-71.12109, 42.37392]]}IllegalArgumentException: A line string has to contain at least two positions. Found positions are [PositionLongLat{longitude=-1.2412971881072137, latitude=0.7395644209766755}].
{'polygon': []}IllegalArgumentException: Exterior ring is not found.
{'polygon': [[]]}IllegalArgumentException: Cannot have less than 3 positions in a ring. Found positions are [].

GIS.PERIMETER

Computes the total length in meters of all line segments in a geospatial object. Point and multi-points have a perimeter of zero. For polygons and multi-polygons, the perimeter includes the segments of the interior rings, as well as those of the exterior rings

SYNTAX

gis.perimeter(geo)

  • geo
    • Type: {'type': 'record', 'fullySpecified': True, 'fields': [{'name': 'point', 'type': {'type': 'array', 'elementType': 'double'}}, {'name': 'multiPoint', 'type': {'type': 'array', 'elementType': {'type': 'array', 'elementType': 'double'}}}, {'name': 'lineString', 'type': {'type': 'array', 'elementType': {'type': 'array', 'elementType': 'double'}}}, {'name': 'multiLineString', 'type': {'type': 'array', 'elementType': {'type': 'array', 'elementType': {'type': 'array', 'elementType': 'double'}}}}, {'name': 'polygon', 'type': {'type': 'array', 'elementType': {'type': 'array', 'elementType': {'type': 'array', 'elementType': 'double'}}}}, {'name': 'multiPolygon', 'type': {'type': 'array', 'elementType': {'type': 'array', 'elementType': {'type': 'array', 'elementType': {'type': 'array', 'elementType': 'double'}}}}}]}
    • Description: the geospatial object

OUTPUT

double

EXAMPLE

SELECT gis.perimeter(geo) as perimeter
geoperimeter
{'point': [-71.12109, 42.37392]}0.0
{'multiPoint': [[-71.12109, 42.37392], [-0.09044, 51.51819]]}0.0
{'lineString': [[-71.12109, 42.37392], [-0.09044, 51.51819]]}5269410.74226513
{'multiLineString': [[[-71.12109, 42.37392], [-0.09044, 51.51819]], [[-71.12109, 42.37392], [-122.34771, 37.58016]]]}9600626.05565118
{'polygon': [[[-71.12109, 42.37392], [-122.34771, 37.58016], [-0.09044, 51.51819], [-71.12109, 42.37392]]]}18232796.4197822
{'multiPolygon': [[[[-71.12109, 42.37392], [-122.34771, 37.58016], [-0.09044, 51.51819], [-71.12109, 42.37392]]], [[[-71.12109, 42.37392], [-73.99332, 40.73897], [-122.34771, 37.58016], [-0.09044, 51.51819], [-71.12109, 42.37392]]]]}36565745.70318055

GIS.RELOCATE_TO_ORIGIN

Relocates the given geospatial object such that the center is at 0 degrees longitude, 0 degrees latitude.

SYNTAX

gis.relocate_to_origin(geo)

  • geo
    • Type: {'type': 'record', 'fullySpecified': True, 'fields': [{'name': 'point', 'type': {'type': 'array', 'elementType': 'double'}}, {'name': 'multiPoint', 'type': {'type': 'array', 'elementType': {'type': 'array', 'elementType': 'double'}}}, {'name': 'lineString', 'type': {'type': 'array', 'elementType': {'type': 'array', 'elementType': 'double'}}}, {'name': 'multiLineString', 'type': {'type': 'array', 'elementType': {'type': 'array', 'elementType': {'type': 'array', 'elementType': 'double'}}}}, {'name': 'polygon', 'type': {'type': 'array', 'elementType': {'type': 'array', 'elementType': {'type': 'array', 'elementType': 'double'}}}}, {'name': 'multiPolygon', 'type': {'type': 'array', 'elementType': {'type': 'array', 'elementType': {'type': 'array', 'elementType': {'type': 'array', 'elementType': 'double'}}}}}]}
    • Description: the geospatial object

OUTPUT

{'type': 'record', 'fullySpecified': True, 'fields': [{'name': 'point', 'type': {'type': 'array', 'elementType': 'double'}}, {'name': 'multiPoint', 'type': {'type': 'array', 'elementType': {'type': 'array', 'elementType': 'double'}}}, {'name': 'lineString', 'type': {'type': 'array', 'elementType': {'type': 'array', 'elementType': 'double'}}}, {'name': 'multiLineString', 'type': {'type': 'array', 'elementType': {'type': 'array', 'elementType': {'type': 'array', 'elementType': 'double'}}}}, {'name': 'polygon', 'type': {'type': 'array', 'elementType': {'type': 'array', 'elementType': {'type': 'array', 'elementType': 'double'}}}}, {'name': 'multiPolygon', 'type': {'type': 'array', 'elementType': {'type': 'array', 'elementType': {'type': 'array', 'elementType': {'type': 'array', 'elementType': 'double'}}}}}]}

EXAMPLE

SELECT gis.relocate_to_origin(geo) as relocated
georelocated
{'point': [-71.12109, 42.37392]}{'point': [-0.0, 0.0]}
{'multiPoint': [[-71.12109, 42.37392], [-0.09044, 51.51819]]}{'multiPoint': [[-23.159189364951295, -5.151924764987099], [23.159189364951295, 5.151924764987099]]}
{'lineString': [[-71.12109, 42.37392], [-0.09044, 51.51819]]}{'lineString': [[-23.159189364951295, -5.151924764987099], [23.159189364951295, 5.151924764987099]]}
{'multiLineString': [[[-71.12109, 42.37392], [-0.09044, 51.51819]], [[-71.12109, 42.37392], [-122.34771, 37.58016]]]}{'multiLineString': [[[-0.9838272008140787, -9.625759823754697], [36.65714604255592, 19.074057915502816]], [[-0.9838272008140787, -9.625759823754697], [-39.656420455744026, -1.360436107390433]]]}
{'polygon': [[[-71.12109, 42.37392], [-122.34771, 37.58016], [-0.09044, 51.51819], [-71.12109, 42.37392]]]}{'polygon': [[[0.7798447126797393, -12.268355901581819], [-37.53365543632313, -3.957733861898786], [38.2818165715597, 16.350424908443067], [0.7798447126797393, -12.268355901581819]]]}
{'multiPolygon': [[[[-71.12109, 42.37392], [-122.34771, 37.58016], [-0.09044, 51.51819], [-71.12109, 42.37392]]], [[[-71.12109, 42.37392], [-73.99332, 40.73897], [-122.34771, 37.58016], [-0.09044, 51.51819], [-71.12109, 42.37392]]]]}{'multiPolygon': [[[[1.2039312886523057, -11.766906209372387], [-37.09581596622342, -3.8809686608924236], [38.67944159412384, 16.6434499031423], [1.2039312886523057, -11.766906209372387]]], [[[1.2039312886523057, -11.766906209372387], [-1.004360817519001, -13.412434219781353], [-37.09581596622342, -3.8809686608924236], [38.67944159412384, 16.6434499031423], [1.2039312886523057, -11.766906209372387]]]]}