Sunday, August 17, 2014

what is the proper map projection for calculating distance

Getting distance from point A to point B can be as easy as using the postgis function ST_Distance and leaving the EPSG with whatever your users submit. For finer calculations there is no perfect solution, really the best you can do is hope that your users wont know. 

Most of the data by GPS drivin sites I've encountered have big problems moving away from the poles. Which tells me, while the site may be great they really just threw something together and didnt look at the algorithms that could have made their job easier, although just slapping gmaps into a site is easy, it's just not accurate. While some may know this, others may not... ArcMap will not let you use the EPSG codes 4326 or 900913 to do distance calculations. You might think you are but in the background it's transforming them and spitting it all back to you correctly(ish).

What did I figure was the best?... plate carrée.

Info: WGS 84 / Plate Carree is a projected CRS last revised on 11/06/2001 and is suitable for use in World. WGS 84 / Plate Carree uses the WGS 84 geographic 2D CRS as its base CRS and the World Equidistant Cylindrical (Sphere) (Equidistant Cylindrical (Spherical)) as its projection. WGS 84 / Plate Carree is a CRS for Graticule coordinates expressed in simple Cartesian form. It was defined by information from OGP. Origin is at intersection of equator and Greenwich meridian. Note: this is not the same as plotting unrectified graticule coordinates on a computer display using the so-called pseudo Plate Carre method: here the grid units are metres.


Projected CRS Details
NAME:WGS 84 / Plate Carree
CODE:32662
CRS TYPE:projected
AREA OF USE:WorldOpen
COORDINATE SYSTEM:Cartesian 2D CS. Axes: easting, northing (X,Y). Orientations: east, north. UoM: m.
BASE GEOGRAPHIC CRS:WGS 84 Open
PROJECTION:World Equidistant Cylindrical (Sphere)Open in New Tab


Meridians: Equally spaced straight parallel lines half as long as the Equator.
Parallels: Equally spaced straight parallel lines, perpendicular to and having same spacing as meridians
Poles: Straight lines equal in length to the Equator
Symmetry: About any meridian or the Equator


How I got my data into Postgres 9.1 with PostGis 1.5

SELECT AddGeometryColumn( 'public', 'zctas', 'thepoint_lonlat', 32662, 'POINT', 2 );
UPDATE zctas SET thepoint_lonlat = ST_SetSRID(ST_Point( longitude, latitude),4269);