An SRID is a numeric code identifying the coordinate reference system associated with spatial data. In PostGIS, it determines how coordinates are interpreted and which units spatial calculations use. SRID 3857 identifies Web Mercator, commonly used by OpenStreetMap and Google Maps, where geometry calculations use meters. section 10.1.2
Use SRIDs consistently when creating, transforming, and measuring geometries:
- Use ST_SetSRID to assign reference-system metadata; it does not transform coordinates. section 10.5.1
- Use ST_Transform to convert coordinates between systems, such as from Web Mercator 3857 to WGS 84 latitude and longitude 4326. section 10.5.1
- Remember that distance and area units follow the geometry’s spatial reference system. section 10.3.3
Creating a point with SRID 3857
For coordinates already expressed in Web Mercator, assign the correct SRID when constructing a point: ST_SetSRID(ST_MakePoint(-9178356.224987695, 3242002.0503882724), 3857). This lets ST_DWithin and ST_Distance compare the point with nearby restaurant geometries and report distances in meters.
