Geometric Functions

Studio provides a set of functions for working with geometries.

FunctionDescription
buffer()Creates a buffer polygon surrounding a point on the map.
bufferFeature()Creates a buffer polygon surrounding a GeoJSON Geometry feature.
bufferH3()Creates a polygon surrounding an H3 cell.
centroid()Returns the center point of a GeoJSON Geometry feature.
latLngToPoint()Creates a GeoJSON Point from latitude/longitude coordinates.
pointLat()Returns the latitude of a GeoJSON Point.
pointLng()Returns the longitude of a GeoJSON Point.


buffer

Create buffer polygons surrounding each set of latitude/longitude coordinates.

Method

buffer(lat: number, lng: number, bufferDistance: number, distanceUnit?: string, pointsPerArc?: number): Feature

Parameters

ParameterTypeDescription
latnumberRequired. A column containing latitude coordinates.
lngnumberRequired. A column containing longitude coordinates.
bufferDistancenumberRequired. The length of the buffer surrounding the point.
distanceUnitstringThe distance unit to use for the buffer, either Meter/Meters, or Mile/Miles (not case-sensitive). Default: Mile
pointsPerArcnumberThe number of points to create the rounded corner of the buffered shape. A higher number of points generates a smoother buffer corner. Default: 10

Returns

Returns a GeoJSON feature buffer for each set of coordinates.

Example

Suppose lat and lng contain latitude and longitude coordinates, respectively.

Create a smoothed 40-meter buffer surrounding each point on the map:

buffer(lat, lng, 40, "meter", 40);
Left: pointPerArc = 10; Right: pointsPerArc = 40

Left: pointPerArc = 10; Right: pointsPerArc = 40



bufferFeature

Create buffer polygons surrounding a set of GeoJSON features/objects, such as polygons or multi-polygons.

Method

bufferFeature(feature: Feature, bufferDistance: number, distanceUnit?: string, pointsPerArc?: number): Feature

Parameters

ParameterTypeDescription
featureGeoJSON featureRequired. The name of the GeoJSON feature column to surround with buffer polygons.
bufferDistancenumberRequired. The length of the buffer from the edge of each feature.
distanceUnitstringThe distance unit to use for the buffer, either Meter/Meters, or Mile/Miles (not case-sensitive). Default: Mile
pointsPerArcnumberThe number of points to create the rounded corner of the buffered shape. A higher number of points generates a smoother buffer corner. Default: 10

Returns

Returns a GeoJSON feature buffer for each existing GeoJSON feature.

Example

Suppose roads is a column containing a set of GeoJSON polygons representing roads.

Create a 50-meter buffer surrounding each road on the map:

bufferFeature(roads, 50, "Meter");


bufferH3

Create buffer polygons surrounding each H3 cell.

Method

bufferH3(h3: string, bufferDistance: number, distanceUnit?: string, pointsPerArc?: number): Feature

Parameters

ParameterTypeDescription
h3stringRequired. A column containing H3 cell strings to surround with buffer polygons.
bufferDistancenumberRequired. The length of the buffer from the edge of each cell.
distanceUnitstringThe distance unit to use for the buffer, either Meter/Meters, or Mile/Miles (not case-sensitive). Default: Mile
pointsPerArcnumberThe number of points to create the rounded corner of the buffered shape. A higher number of points generates a smoother buffer corner. Default: 10

Returns

Returns a GeoJSON feature buffer for each H3 cell.

Example

Suppose h3 is a column containing H3 indexes.

Create a 2-mile buffer surrounding each H3 cell in h3:

bufferh3(h3, 2);


centroid

Get the centroid of a GeoJSON Geometry object. The geometry type could be Point/MultiPoint, LineString/MultiLineString, or Polygon/MultiPolygon. A geometry's geometric center of mass is computed and returned.

Method

centroid(geo: Feature): Feature<Point>

Parameters

ParameterTypeDescription
geoGeoJSON Geometry feature/object or a WKT string.Required. The column containing the polygons to derive centroid from.

Returns

Returns a GeoJSON Point feature for each polygon provided.

Example

Suppose there is a _geojson column in the dataset table.

Find the centroid for each GeoJSON Geometry feature/object in _geojson:

centroid(_geojson);


latLngToPoint

Creates a GeoJSON Point feature for each set of coordinates.

Method

latLngToPoint(lat: number, lng: number): Feature<Point>

Parameters

ParameterTypeDescription
latnumberRequired. A column containing latitude coordinates.
lngnumberRequired. A column containing longitude coordinates.

Returns

Returns a GeoJSON Point feature for each set of coordinates.

Example

Suppose lat and lng contain latitude and longitude coordinates, respectively.

Create a GeoJSON Point feature for a set of coordinates:

latLngToPoint(lat, lng);


pointLat

Get the latitude value of a GeoJSON Point feature.

Method

pointLat(pt: Feature<Point>): number

Parameters

ParameterTypeDescription
ptA GeoJSON Point feature/objectRequired. A column containing GeoJSON Points to derive latitude from.

Returns

Returns a numeric latitude value for each Point feature.

Example

Suppose there is a _geojson column in the dataset table.

Retrieve the latitude values for each GeoJSON Point:

pointLat(_geojson);


pointLng

Get the longitude value of a GeoJSON Point feature.

Method

pointLng(pt: Feature<Point>): number

Parameters

ParameterTypeDescription
ptA GeoJSON Point feature/objectRequired. A column containing GeoJSON Points to derive longitude from.

Returns

Returns a numeric longitude value for each Point feature.

Example

Suppose there is a _geojson column in the dataset table.

Retrieve the longitude values for each GeoJSON Point:

pointLng(_geojson);

Note: pointLat() and pointLng() can be used to create new latitude and longitude columns for a Point layer.