Introduction to PostGIS

35. Appendix A: PostGIS Functions

35.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.

35.2. Outputs

Returns a geometry in a human-readable text format.
Returns a geometry in standard OGC GML format.
Returns a geometry to a standard GeoJSON format.

35.3. Measurements

Returns the area of the geometry in the units of the spatial reference system.
Returns the length of the geometry in the units of the spatial reference system.
Returns the perimeter of the geometry in the units of the spatial reference system.
Returns the number of vertices in a linestring.
Returns the number of rings in a polygon.
Returns the number of geometries in a geometry collection.

35.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.

Continue Reading

Previous: 34. Software Upgrades

Next: 36. Appendix B: Glossary

About Boundless

Boundless provides commercial open source software for internet mapping and geospatial application development. We are dedicated to the growth and support of open source software.


This work is licensed under a Creative Non Commercial-Commons Attribution-Share Alike 3.0 United States License. Feel free to use this material, but we ask that you please retain the Boundless branding, logos and style.

Creative Commons License