39. Appendix A: PostGIS Functions

39.1. Constructors

ST_MakePoint(Longitude, Latitude)

Returns a new point. Note the order of the coordinates (longitude then latitude).

ST_GeomFromText(WellKnownText, srid)

Returns a new geometry from a standard WKT string and srid.

ST_SetSRID(geometry, srid)

Updates the srid on a geometry. Returns the same geometry. This does not alter the coordinates of the geometry, it just updates the srid. This function is useful for conditioning geometries created without an srid.

ST_Expand(geometry, Radius)

Returns a new geometry that is an expanded bounding box of the input geometry. This function is useful for creating envelopes for use in indexed searches.

39.2. Outputs

ST_AsText(geometry)

Returns a geometry in a human-readable text format.

ST_AsGML(geometry)

Returns a geometry in standard OGC GML format.

ST_AsGeoJSON(geometry)

Returns a geometry to a standard GeoJSON format.

39.3. Measurements

ST_Area(geometry)

Returns the area of the geometry in the units of the spatial reference system.

ST_Length(geometry)

Returns the length of the geometry in the units of the spatial reference system.

ST_Perimeter(geometry)

Returns the perimeter of the geometry in the units of the spatial reference system.

ST_NumPoints(linestring)

Returns the number of vertices in a linestring.

ST_NumRings(polygon)

Returns the number of rings in a polygon.

ST_NumGeometries(geometry)

Returns the number of geometries in a geometry collection.

39.4. Relationships

ST_Distance(geometry, geometry)

Returns the distance between two geometries in the units of the spatial reference system.

ST_DWithin(geometry, geometry, radius)

Returns true if the geometries are within the radius distance of one another, otherwise false.

ST_Intersects(geometry, geometry)

Returns true if the geometries are not disjoint, otherwise false.

ST_Contains(geometry, geometry)

Returns true if the first geometry fully contains the second geometry, otherwise false.

ST_Crosses(geometry, geometry)

Returns true if a line or polygon boundary crosses another line or polygon boundary, otherwise false.