[GIS] How to use GDAL to convert from an arbitrary projection/datum into Equirectangular/WGS84

coordinate systemdatumgdalraster

I've been trying to use GDAL to convert from an arbitrary projection/datum into Equirectangular (aka Plate Caree, aka Equidistant Cylindrical, aka Geographic, aka Lat/Long) with WGS84 datum. All of my input files have an associated PRJ file that I've been using with GDAL with this statement:

gdalwarp -s_srs Input.prj -t_srs Output.prj Input.xyz Output.tif

So far, I've had mixed results. I've been able to successfully transform a Lambert Equal Area projection in WGS84 to Geographic/WGS84, but performing a transform on LEA in RT90 projection causes an error of ~1km.

Stranger still, I tried to transform two Sinusoidal projections in RT90 and in WGS84, both of which resulted in an error of 16km! I suspect that these errors are largely due to some sort of ellipsoid/sphere discrepancy.

I'm very confused as to why these errors are so random, but more concerned that they are happening at all. Shouldn't gdalwarp take any ellipsoid information about the source and target from the PRJ files and transform between them?

What can I do to correct my issue?

Best Answer

I've solved my problem.

RT90 is not a defined datum in Proj4. As such, GDAL just up and ignores the datum entry and applies the ellipsoid and projection correction.

It'd be nice if a warning was thrown at some point ("WARNING: datum 'RT90' not recognized" would be enough, but I digress).

The sinusoidal projection in WGS84 datum was transforming incorrectly because the Sinusoidal projection wasn't being set properly when export from Global Mapper. When I hand-rolled my own SRS to be "+proj=sinu +datum=WGS84" everything worked out fine.

To get proj4 to list various types of datums/projections/ellipsoids that it supports:

proj -ld    //lists known datums
proj -le    //lists known ellipsoids
proj -l     //lists known projections (use -lP for an expanded view)

If you want GDAL to work with unknown datum types, you must specify "+towgs84=" in your source SRS, and you must also specify "+towgs84=" in your target SRS if your target datum is not WGS84. These tags must be followed by 3 or 7 parameter transformation values, which can be found with some google-fu. More info on this tag can be found here:

http://trac.osgeo.org/proj/wiki/GenParms#towgs84-DatumtransformationtoWGS84

Hopefully anyone that runs into a similar problem will now be able to do so.