[GRASS5] [bug #3302] (grass) cs2cs with GRASS and NTv2 grid fails

Request Tracker grass-bugs at intevation.de
Mon May 30 06:39:35 EDT 2005


this bug's URL: http://intevation.de/rt/webrt?serial_num=3302
-------------------------------------------------------------------------

Subject: cs2cs with GRASS and NTv2 grid fails

Hi,

see PROJ.4 bug # 834:
  http://bugzilla.remotesensing.org/show_bug.cgi?id=834


When trying to use cs2cs to reproject some points from WGS84 to the current
location's projection (which uses a NTv2 distortion grid for datum shift):

GRASS 6.1> IN_PROJ="+proj=longlat +towgs84=0.000,0.000,0.000"
GRASS 6.1> OUT_PROJ="`g.proj -jf`"
GRASS 6.1> echo "176 -45" | cs2cs -f %.7f $IN_PROJ +to $OUT_PROJ
*       * -0.0000002

The reason it fails is that cs2cs can't find the grid file.



GRASS 6.1> g.proj -p
-PROJ_INFO-------------------------------------------------
name       : New Zealand Map Grid
datum      : nzgd49
nadgrids   : nzgd2kgrid0005.gsb
proj       : nzmg
ellps      : international
a          : 6378388.0000000000
es         : 0.0067226700
f          : 297.0000000000
lat_0      : -41.0000000000
lon_0      : 173.0000000000
x_0        : 2510000.0000000000
y_0        : 6023150.0000000000
-PROJ_UNITS------------------------------------------------
unit       : meter
units      : meters
meters     : 1.0

GRASS 6.1> g.proj -jf
+proj=nzmg +lat_0=-41.0000000000 +lon_0=173.0000000000 +x_0=2510000.0000000000
+y_0=6023150.0000000000 +a=6378388 +rf=297 +no_defs +nadgrids=nzgd2kgrid0005.gsb


PROJ.4 is from the debian package (4.4.9-1) and the grids it comes with are
stored in /usr/share/proj

symlinking the GRASS supplied grid file into that directory solves the problem
in the short term.


The cs2cs manual states that you can set the PROJ_LIB enviro variable:

   The environment parameter PROJ_LIB establishes the default 
   directory for a file reference without an absolute path.
   This is also used for supporting files like datum shift files.


But this makes cs2cs fail, presumably because it can't expand +proj=nzmg who's
definition is stored in the epsg or esri file in /usr/share/proj ?

GRASS 6.1> export PROJ_LIB="$GISBASE/etc/nad"
GRASS 6.1> echo "176 -45" | cs2cs -f %.7f $IN_PROJ +to $OUT_PROJ
Using from definition: proj=longlat towgs84=0.000,0.000,0.000
Rel. 4.4.9, 29 Oct 2004
<cs2cs>:
projection initialization failure
cause: major axis or radius = 0 or not given
program abnormally terminated


Trying to make PROJ_LIB check two directories with "dir1 dir2" or "dir1:dir2"
doesn't work.

unsetting PROJ_LIB gets things back to normal.
GRASS 6.1> unset PROJ_LIB

What does work is setting the absolute path to the grid file, i.e.
$GISBASE/etc/nad

GRASS6.1> echo "176 -45" | cs2cs -f %.7f $IN_PROJ +to +proj=nzmg
+lat_0=-41.0000000000 +lon_0=173.0000000000 +x_0=2510000.0000000000
+y_0=6023150.0000000000 +a=6378388 +rf=297 +no_defs
+nadgrids="$GISBASE/etc/nad/nzgd2kgrid0005.gsb"
2746698.0511985 5574185.5657139 -0.0000002


A solution seems to be changing the output of 'g.proj -j' to prepend
"$GISBASE/etc/nad/" to the grid file name? Is this the prefered way?



thanks,
Hamish


-------------------------------------------- Managed by Request Tracker




More information about the grass-dev mailing list