Projecting with GDAL
I find myself using gdalwarp in preference to ArcGIS ProjectRaster more and more often. Historically I’ve just used gdal when speed is important, large batch jobs for example, but now I’m finding it more reliable as well. For instance this morning I tried for 20 minutes to project a small DEM from geobase.ca but kept getting error messages which didn’t tell me the nature of the problem, “An error was encountered while executing ProjectRaster. Failed to execute (ProjectRaster_3)”. The projection should only have taken 30 seconds or so, including defining all the parameters.
The difficulty with gdalwarp is that I’m always forgetting the correct syntax and options so I have to go look it up again; a 30 second job takes 5 minutes. So the purpose of this post is not really slag arcgis, again, it’s too easy, but to record the options I frequently use so I can reduce a 5 minute job to 1.
:: -t_srs = target coordinate system\ :: -rc = cubic resampling\ :: -wm = RAM to use (default is much too small, like 40mb)\ :: -multi = multithreaded\ :: rest are self explanatory
gdalwarp -t_srs z:\Arcutils\prj\YkAlbers.proj4 *.dem albers\114o.tif -rc -wm 1024 -multi -srcnodata -32767 -dstnodata -9999 -co compress=lzw
PROJ4 definition for Yukon Albers projection:
+proj=aea +lat_1=61.66666666666666 +lat_2=68.0 +lat_0=59.0 +lon_0=-132.5 +x_0=500000 +y_0=500000 +ellps=GRS80 +datum=NAD83 +units=m +no_defs