What is the cause for the degradation of environment?
Capitalism, corruption, consuming society? - OVERPOPULATION!
Please, save the Planet - kill yourself...

Thursday, July 25, 2013

A Note About proj4 in R

It's been a long time since I had to transform some coordinates 'manually'. I mean I had a list of coordinates that I needed to [re]project. There are some nice proprietary tools for it, but who needs them when the opensource is everywhere?

Proj4 is an obvious tool for this task. And using it from within R is somewhat a natural approach when you need to process a csv-file. There is a package called... 'proj4' that provides a simple interface to proj4. It has only two functions: project and ptransform. The first one is meant to provide transition between unprojected and projected coordinate reference systems and the second - between different projected coordinate reference systems.

Look closely at description of the project function: "Projection of lat/long coordinates or its inverse". Ok... here is a huge setup which made me write this post. If you would try to use coordinates in lat/long format here you would screw up! Your points would fly thousands of miles away from initial position. Actually you have to use coordinates in long/lat format to get the result you need. Don't trust manuals ;-)

Oh, I really hate the guy who started this practice of placing longitude before latitude in GIS...

2 comments :

  1. package rgdal contains also proj4-based projection functionality, and is integrated with the rest of the spatial packages in R; see also the spatial task view on CRAN. rgdal contains also a simple project() function, with less ambiguous documentation...

    ReplyDelete
  2. RE: "Oh, I really hate the guy who started this practice of placing longitude before latitude in GIS..."

    Placing the X coordinate before the Y coordinate in an ordered pair (X, Y) certainly predates GIS by many millennia. Colloquially referring to "lat, lon" must be the anomaly.

    ReplyDelete