3857 - Simple Spherical Mercator projection coordinate system
4326 - Geographic coordinate system
- ST_Transform: Return a new geometry with its coordinates transformed to a different spatial reference.
ST_Transform(geometry, 4326)
- ST_SetSRID: Set the SRID on a geometry to a particular integer value.
ST_SetSRID(ST_MakePoint(longitude, latitude), 4326)
- ST_AsText: Return the Well-Known Text (WKT) representation of the geometry/geography without SRID metadata.
ST_AsText(geometry)
- ST_MakePoint: Creates a 2D,3DZ or 4D point geometry.
ST_MakePoint(longitude, latitude)
- ST_GeomFromText: Return a specified ST_Geometry value from Well-Known Text representation (WKT).
ST_GeomFromText('POINT(-115.993052 43.645232)', 4326)
- <->: Returns the 2D distance between A and B
ST_Transform(geometry, 4326) <-> ST_GeomFromText('POINT(-115.993052 43.645232)', 4326)
- ST_Distance: For geometry type Returns the 2D Cartesian distance between two geometries in projected units (based on spatial ref). For geography type defaults to return minimum geodesic distance between two geographies in meters.
ST_Distance(geometry, ST_Transform(ST_GeomFromText('POINT(-115.993052 43.645232)',4326), 3857))
- ST_Distance_Sphere: Returns minimum distance in meters between two lon/lat geometries. Uses a spherical earth and radius of 6370986 meters. Faster than ST_Distance_Spheroid ST_Distance_Spheroid, but less accurate. PostGIS versions prior to 1.5 only implemented for points.
ST_Distance_Sphere(geometry, ST_GeomFromText('POINT(-115.993052 43.645232)',4326))
- ST_DWithin: Returns true if the geometries are within the specified distance of one another. For geometry units are in those of spatial reference and For geography units are in meters and measurement is defaulted to use_spheroid=true (measure around spheroid), for faster check, use_spheroid=false to measure along sphere.
ST_DWithin(geography, ST_GeomFromText('POINT(-115.993052 43.645232)',4326)::geography, 1000)
-
ST_X: Return the X coordinate of the point, or NULL if not available. Input must be a point.
-
ST_Y: Return the Y coordinate of the point, or NULL if not available. Input must be a point.
- Extract latitude and longitude from point
SELECT ST_X(ST_TRANSFORM(geometry, 4326)) AS longitude,
ST_Y(ST_TRANSFORM(geometry, 4326)) AS latitude
- Print geometry point as geographical coordinate
ST_AsText(ST_Transform(geometry, 4326))
- Transform coordinates into simple mercator projection
ST_Transform(ST_GeomFromText('POINT(longitude latitude)', 4326), 3857)