transformations
This module contains functions that compute geometric constructions, or alter geometry size or shape.
ST_BUFFER
ST_BUFFER(geog, distance [, segments])Description
Calculates a buffer for the input features for a given distance.
geog:GEOGRAPHYinput to be buffered.distance:DOUBLEdistance of the buffer around the input geography. The value is in meters. Negative values are allowed.segments(optional):INTEGERnumber of segments used to approximate a quarter circle. The default value is8.
Return type
GEOGRAPHY
Example
SELECT CARTO.CARTO.ST_BUFFER(ST_POINT(-74.00, 40.7128), 1000);
-- { "coordinates": [ [ [ -73.98813543746913, 40.712799392649444 ], ...SELECT CARTO.CARTO.ST_BUFFER(ST_POINT(-74.00, 40.7128), 1000, 10);
-- { "coordinates": [ [ [ -73.98813543746913, 40.712799392649444 ], ...ST_CENTERMEAN
Description
Takes a Feature or FeatureCollection and returns the mean center (average of its vertices).
geom:GEOGRAPHYfor which to compute the mean center.
Return type
GEOGRAPHY
Example
ST_CENTERMEDIAN
Description
Takes a FeatureCollection of points and computes the median center. The median center is understood as the point that requires the least total travel from all other points.
geog:GEOGRAPHYfor which to compute the center.
Return type
GEOGRAPHY
Example
ST_CENTEROFMASS
Description
Takes any Feature or a FeatureCollection and returns its center of mass (also known as centroid).
geog:GEOGRAPHYfeature to be centered.
Return type
GEOGRAPHY
Example
ST_CONCAVEHULL
Description
Takes a set of points and returns a concave hull Polygon or MultiPolygon. In case that a single or a couple of points are passed as input, the function will return that point or a segment respectively.
geojsons:ARRAYarray of features in GeoJSON format casted to STRING.maxEdge(optional):DOUBLEthe maximum length allowed for an edge of the concave hull. HighermaxEdgevalues will produce more convex-like hulls. If not provided, the default valueinfinityis used and it would be equivalent to a Convex Hull.units(optional):STRINGunits of length, the supported options are: miles, kilometers, degrees or radians. By defaultunitsiskilometers.
Return type
GEOGRAPHY
Examples
If points are stored in a table, a query like the one below can be used (multiple polygons are generated in this case, one for each cluster_id value):
ST_CONVEXHULL
Description
Computes the convex hull of the input geography. The convex hull is the smallest convex geography that covers the input. It returns NULL if there is no convex hull.
This is not an aggregate function. To compute the convex hull of a set of geography, use ST_COLLECT to aggregate them into a collection.
geog:GEOGRAPHYinput to compute the convex hull.
Return type
GEOGRAPHY
Examples
warning
The aggregate function ST_COLLECT has an output limit of 16 MB. This is equivalent, approximately, to 300K points.
ST_DESTINATION
Description
Takes a Point and calculates the location of a destination point given a distance in degrees, radians, miles, or kilometers; and a bearing in degrees. This uses the Haversine formula to account for global curvature.
origin:GEOGRAPHYstarting point.distance:DOUBLEdistance from the origin point in the units specified.bearing:DOUBLEranging from -180 to 180 (e.g. 0 is North, 90 is East, 180 is South, -90 is West).units(optional):STRINGunits of length, the supported options are:miles,kilometers,degreesorradians. IfNULLthe default valuekilometersis used.
Return type
GEOGRAPHY
Examples
ST_GREATCIRCLE
Description
Calculate great circle routes as LineString or MultiLineString. If the start and end points span the antimeridian, the resulting feature will be split into a MultiLineString.
startPoint:GEOGRAPHYsource point feature.endPoint:GEOGRAPHYdestination point feature.npoints(optional):INTnumber of points. By defaultnpointsis100.
Return type
GEOGRAPHY
Examples
ST_LINE_INTERPOLATE_POINT
Description
Takes a LineString and returns a Point at a specified distance along the line.
geog:GEOGRAPHYinput line.distance:DOUBLEdistance along the line.units(optional):STRINGunits of length, the supported options are:miles,kilometers,degreesandradians. By defaultunitsiskilometers.
Return type
GEOGRAPHY
Examples
ST_POINTONSURFACE
Description
Takes any Feature or a FeatureCollection and returns a point that is granted to be inside one of the polygons.
geog:GEOGRAPHYfeature to be centered.
Return type
GEOGRAPHY
Example
Last updated
Was this helpful?
