I'm using the UK crime dataset provided by https://data.police.uk/
My question is about coordinate systems/map projections. The crime locations are stored with the projection EPSG 4326 which uses degrees as units. But to do some distance calculations, I would like to use meters.
From what I could research there are many projections and depending on the use-case, some are better than others. In this case, I encountered the British National Grid(EPSG: 27700) which gives accurate distances as long as it’s within the United Kingdom. In PostGIS, I can transform geometries that are EPSG 4326 to 27700 using ST_Transform(https://postgis.net/docs/ST_Transform.html ) and calculate that way. However if I want to display in a Web Map, which usually uses EPSG:3857 to display the map, I need to convert the output of the query to EPSG:3857?
In a nutshell, convert from 4326 to 27700 to do calculations, then convert the output to 3857 to display on the map. Do you think this procedure makes sense? If not, can you explain what I should know/do to tackle this problem?
Based on this assumption I would do something like this:
-- get all streets within a radius of 100 meters
-- where the center is a crime point with ID=1
SELECT street_id, ST_Transform(street_geom, 3857)
FROM streets
INNER JOIN crimes_street as cst
ON ST_DWithin(ST_Transform(street_geom, 27700), ST_Transform(cst.longlat_point, 27700), 100)
WHERE cst.crime_street_id = 1
GEOGRAPHY
to calculate distances and, if needed, transform to 3857 - some web map client libraries expect data in 4326, too, and transform internally.GEOGRAPHY
arguments, so it's only necessary to convert theGEOMETRY
toGEOGRAPHY
and the distances would be calculated correctly I assume. If the case of a function not accepting aGEOGRAPHY
type, what should be done?