Geometric Functions
Studio Functions for Working with Geometries
Studio provides a set of functions for working with geometries.
| Function | Description |
|---|---|
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
JavaScript
buffer(lat: number, lng: number, bufferDistance: number, distanceUnit?: string, pointsPerArc?: number): Feature
Parameters
| Parameter | Type | Description |
|---|---|---|
lat |
number |
Required. A column containing latitude coordinates. |
lng |
number |
Required. A column containing longitude coordinates. |
bufferDistance |
number |
Required. The length of the buffer surrounding the point. |
distanceUnit |
string |
The distance unit to use for the buffer, either Meter/Meters, or Mile/Miles (not case-sensitive). Default: Mile |
pointsPerArc |
number |
The 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
Create a smoothed 40-meter buffer surrounding each point on the map:
JavaScript
buffer(lat, lng, 40, "meter", 40);
bufferFeature
Create buffer polygons surrounding a set of GeoJSON features/objects, such as polygons or multi-polygons.
Method
JavaScript
bufferFeature(feature: Feature, bufferDistance: number, distanceUnit?: string, pointsPerArc?: number): Feature
Parameters
| Parameter | Type | Description |
|---|---|---|
feature |
GeoJSON feature |
Required. The name of the GeoJSON feature column to surround with buffer polygons. |
bufferDistance |
number |
Required. The length of the buffer from the edge of each feature. |
distanceUnit |
string |
The distance unit to use for the buffer, either Meter/Meters, or Mile/Miles (not case-sensitive). Default: Mile |
pointsPerArc |
number |
The 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
Create a 50-meter buffer surrounding each road on the map:
JavaScript
bufferFeature(roads, 50, "Meter");
bufferH3
Create buffer polygons surrounding each H3 cell.
Method
JavaScript
bufferH3(h3: string, bufferDistance: number, distanceUnit?: string, pointsPerArc?: number): Feature
Parameters
| Parameter | Type | Description |
|---|---|---|
h3 |
string |
Required. A column containing H3 cell strings to surround with buffer polygons. |
bufferDistance |
number |
Required. The length of the buffer from the edge of each cell. |
distanceUnit |
string |
The distance unit to use for the buffer, either Meter/Meters, or Mile/Miles (not case-sensitive). Default: Mile |
pointsPerArc |
number |
The 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
Create a 2-mile buffer surrounding each H3 cell in h3:
JavaScript
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
JavaScript
centroid(geo: Feature): Feature<Point>
Parameters
| Parameter | Type | Description |
|---|---|---|
geo |
GeoJSON 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
Find the centroid for each GeoJSON Geometry feature/object in _geojson:
JavaScript
centroid(_geojson);
latLngToPoint
Creates a GeoJSON Point feature for each set of coordinates.
Method
JavaScript
latLngToPoint(lat: number, lng: number): Feature<Point>
Parameters
| Parameter | Type | Description |
|---|---|---|
lat |
number |
Required. A column containing latitude coordinates. |
lng |
number |
Required. A column containing longitude coordinates. |
Returns
Returns a GeoJSON Point feature for each set of coordinates.
Example
Create a GeoJSON Point feature for a set of coordinates:
JavaScript
latLngToPoint(lat, lng);
pointLat
Get the latitude value of a GeoJSON Point feature.
Method
JavaScript
pointLat(pt: Feature<Point>): number
Parameters
| Parameter | Type | Description |
|---|---|---|
pt |
A GeoJSON Point feature/object | Required. A column containing GeoJSON Points to derive latitude from. |
Returns
Returns a numeric latitude value for each Point feature.
Example
Retrieve the latitude values for each GeoJSON Point:
JavaScript
pointLat(_geojson);
pointLng
Get the longitude value of a GeoJSON Point feature.
Method
JavaScript
pointLng(pt: Feature<Point>): number
Parameters
| Parameter | Type | Description |
|---|---|---|
pt |
A GeoJSON Point feature/object | Required. A column containing GeoJSON Points to derive longitude from. |
Returns
Returns a numeric longitude value for each Point feature.
Example
Retrieve the longitude values for each GeoJSON Point:
JavaScript
pointLng(_geojson);
Note:
pointLat()andpointLng()can be used to create new latitude and longitude columns for a Point layer.