3

I have a grid file in a certain coordinate system. I'd like to change it so I have the same grid in geographic lat/long based on WGS84. This seems like something that gdal can tackle quite easily (maybe with gdalwarp or gdal_translate) but for some reason I can't find the proper way to do it.

I'm trying to run the following:

gdalwarp -s_srs '+proj=cass +lat_0=31.73409694444445 +lon_0=35.21208055555556 
+x_0=170251.555 +y_0=1126867.909 +a=6378300.789 +b=6356566.435
+towgs84=-275.722,94.7824,340.894,-8.001,-4.42,-11.821,1 +units=m +no_defs'
-t_srs EPSG:4326 thick.grd thick2.grd

The proj4 definition taken from spatialreference.org. I get the following error message:

Warning: The target file has a 'grd' extension, which is normally used by the GSAG, GSBG, GS7BG, NWT_GRD drivers,
but the requested output driver is GTiff. Is it really what you want ?
ERROR 6: Unable to load PROJ.4 library (libproj.so), creation of
OGRCoordinateTransformation failed.

So I have two problems here. First, how do I let gdalwarp know what is the input format (in this case, Surfer grid) and the output format? Also, why can't it load the PROJ.4 library if I have it installed? Is there an alternative to PROJ.4 that will work on my system?

3

For the first part of your question:

GDAL can guess the format of the input file from the file extension. The output format is defined by the -f option. If it is missing, Geotiff is assumed, but you get that warning if the file extension is not .tif.

For a .grd output, you can select between

GS7BG (rw+v): Golden Software 7 Binary Grid (.grd)
GSAG (rwv): Golden Software ASCII Grid (.grd)
GSBG (rw+v): Golden Software Binary Grid (.grd)

The second part might depend on your operating system, and where you got the binaries from.

  • I'm on openSUSE. Binaries from the openSUSE repo. – Gimelist Nov 16 '14 at 16:09
  • 1
    I have not much experience with openSUSE. I added your suggested edit to your own answer. – AndreJ Nov 16 '14 at 17:21
2

In addition to AndreJ's answer, the gdalwarp command can be simplified as this:

gdalwarp -s_srs EPSG:28193 -t_srs EPSG:4326 -of GS7BG in.grd out.grd

No need to specify the entire proj.4 definition.

On Linux systems this might work, as root:

ln -s /usr/lib64/libproj.so.0 /usr/lib64/libproj.so

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.