Mon, May 30 2005
12:39:35
|
|
Request created by hbowman
|
|
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
|
|
Wed, Jun 8 2005
12:09:11
|
|
Mail sent by hbowman
|
|
`g.proj -jf` fails to report path to GRASS's grid files, so using it in a
cs2cs command string fails.
> A solution seems to be changing the output of 'g.proj -j' to prepend
> "$GISBASE/etc/nad/" to the grid file name
g.proj uses PROJ.4's pj_get_def() to get the string, then loops through it
printing one char at a time & replacing ' ' with '\n' if you didn't chose the
-f flat output flag. How to parse for "+nadgrids=" within the string and
replace with "+nadgrids=$GISBASE/etc/nad/"? (verbatim) Then we can use cs2cs
automatically in scripts, etc.
cs2cs needs the full path to the grid file if it isn't in PROJ's PROJ_LIB dir.
Setting the enviro variable to anything but PROJ's default pretty much breaks
PROJ. If the full path to the grid file is given, this isn't a problem.
Finding & placing the GRASS grid files in wherever PROJ is doesn't seem like
a
robust solution.
"$GISBASE/etc/nad/" is obviously a GRASSism, so it has to be changed in GRASS
and not PROJ.4. (?)
thanks,
Hamish
|
|
Wed, Jun 8 2005
12:46:59
|
|
Comments added by pkelly
|
|
Cc: grass5@grass.itc.it
Yes the reason $GISBASE/etc/nad/ doesn't need to be included in the nadgrids
definition in the PROJ_INFO file is that the functions which prepare the
GRASS co-ordinate system definitions for use by PROJ (pj_get_kv() and
pj_get_string() in lib/proj/get_proj.c) call the PROJ function pj_set_finder
() to specify a name of a "finder function", which is provided by GRASS
(actually set_proj_lib() in get_proj.c; should really be re-written using
G_asprintf() if it is staying) and returns the location of the datum
gridshift files in $GISBASE/etc/nad/. PROJ then calls this function whenever
it wants during the transformation if it needs to find the files.
At the time we were putting the datum transformation support into GRASS,
Frank indicated that this was the preferred solution.
But looks like we've hit a limitation.
My peferred solution would be, as long as specifying the full path to the
gridshift file is supposed to work and isn't an undocumented feature of
PROJ, would be to change pj_get_kv() (which is called by g.proj) to prepend
$GISBASE/etc/nad/ to the name of the gridshift file when it prepares the
PROJ string, and to do away with pj_set_finder().
|
|
Wed, Jun 8 2005
14:28:31
|
|
Mail sent by hamish_nospam@yahoo.com
|
|
Return-Path |
<hamish_nospam@yahoo.com>
|
Delivered-To |
grass-bugs@lists.intevation.de
|
Date |
Thu, 9 Jun 2005 00:28:15 +1200
|
From |
Hamish <hamish_nospam@yahoo.com>
|
To |
Paul Kelly via RT <grass-bugs@intevation.de>
|
Cc |
grass5@grass.itc.it
|
Subject |
Re: [GRASS5] [bug #3302] (grass) cs2cs with GRASS and NTv2 grid fails
|
Message-Id |
<20050609002815.179da00b.hamish_nospam@yahoo.com>
|
In-Reply-To |
<20050608104659.E5C6310016A@lists.intevation.de>
|
References |
<20050608104659.E5C6310016A@lists.intevation.de>
|
X-Mailer |
Sylpheed version 1.0.4 (GTK+ 1.2.10; i386-pc-linux-gnu)
|
X-Face |
M<EoB)"*Z~u!,vFhXmw}R_KbdBta*P_=T|rbBL'e1/CQ9;/1g\BU3&!=y8ria$2Uk!HT&BB 8i?|X_+7~1jsy}F~g$2va%3fV`*=L(*cem[@3\yg,G,@rg6/QMJ
|
Mime-Version |
1.0
|
Content-Type |
text/plain; charset=US-ASCII
|
Content-Transfer-Encoding |
7bit
|
X-Spam-Status |
No, hits=-4.0 tagged_above=-999.0 required=3.0 tests=BAYES_00, FORGED_YAHOO_RCVD
|
X-Spam-Level |
|
> My peferred solution would be, as long as specifying the full path to
> the gridshift file is supposed to work and isn't an undocumented
> feature of PROJ,
from the cs2cs man page:
"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."
I take that to mean it is intended.
> would be to change pj_get_kv() (which is called by g.proj) to prepend
> $GISBASE/etc/nad/ to the name of the gridshift file when it prepares
> the PROJ string, and to do away with pj_set_finder().
If you say so, you're the expert.
Hamish
|
|
Wed, Jun 8 2005
14:46:28
|
|
Mail sent by hamish_nospam@yahoo.com
|
|
Return-Path |
<hamish_nospam@yahoo.com>
|
Delivered-To |
grass-bugs@lists.intevation.de
|
Date |
Thu, 9 Jun 2005 00:46:16 +1200
|
From |
Hamish <hamish_nospam@yahoo.com>
|
To |
grass-bugs@intevation.de
|
Cc |
grass5@grass.itc.it
|
Subject |
Re: [GRASS5] [bug #3302] (grass) cs2cs with GRASS and NTv2 grid fails
|
Message-Id |
<20050609004616.2955d22a.hamish_nospam@yahoo.com>
|
In-Reply-To |
<20050608104659.E5C6310016A@lists.intevation.de>
|
References |
<20050608104659.E5C6310016A@lists.intevation.de>
|
X-Mailer |
Sylpheed version 1.0.4 (GTK+ 1.2.10; i386-pc-linux-gnu)
|
X-Face |
M<EoB)"*Z~u!,vFhXmw}R_KbdBta*P_=T|rbBL'e1/CQ9;/1g\BU3&!=y8ria$2Uk!HT&BB 8i?|X_+7~1jsy}F~g$2va%3fV`*=L(*cem[@3\yg,G,@rg6/QMJ
|
Mime-Version |
1.0
|
Content-Type |
text/plain; charset=US-ASCII
|
Content-Transfer-Encoding |
7bit
|
X-Spam-Status |
No, hits=-4.0 tagged_above=-999.0 required=3.0 tests=BAYES_00, FORGED_YAHOO_RCVD
|
X-Spam-Level |
|
> this bug's URL: http://intevation.de/rt/webrt?serial_num=3302
..
> My peferred solution would be, as long as specifying the full path to
> the gridshift file is supposed to work and isn't an undocumented
> feature of PROJ, would be to change pj_get_kv() (which is called by
> g.proj) to prepend $GISBASE/etc/nad/ to the name of the gridshift
> file when it prepares the PROJ string, and to do away with
> pj_set_finder().
temporary work-around to fix v.in.garmin's WGS84->GRASS location bug:
IN_PROJ="+proj=longlat +towgs84=0.000,0.000,0.000"
OUT_PROJ="`g.proj -jf | sed -e
's/+nadgrids=/+nadgrids=$GISBASE\/etc\/nad\//'`"
...
cs2cs -f %.7f $IN_PROJ +to $OUT_PROJ < "${TMP}.base" > "${TMP}.P_base"
I'd like to work towards a general purpose m.proj2 module again with -i
and -o flags to very simply convert a list of points to/from WGS84 & the
current location settings. As above, it's easy to do with cs2cs in a
script, but I still haven't figured out how to pipe into a script well
'cause "read" is kind of crappy.. so perhaps C is better albeit
reinventing the wheel & something else that only a smaller part of the
crowd can maintain, etc.
Hamish
|
|
Thu, Jun 9 2005
02:39:22
|
|
Mail sent by paul-grass@stjohnspoint.co.uk
|
|
Return-Path |
<paul-grass@stjohnspoint.co.uk>
|
Delivered-To |
grass-bugs@lists.intevation.de
|
Date |
Thu, 9 Jun 2005 01:39:25 +0100 (BST)
|
From |
Paul Kelly <paul-grass@stjohnspoint.co.uk>
|
To |
Hamish <hamish_nospam@yahoo.com>
|
Cc |
Paul Kelly via RT <grass-bugs@intevation.de>, grass5@grass.itc.it
|
Subject |
Re: [GRASS5] [bug #3302] (grass) cs2cs with GRASS and NTv2 grid fails
|
In-Reply-To |
<20050609002815.179da00b.hamish_nospam@yahoo.com>
|
Message-ID |
<Pine.LNX.4.60.0506090136480.11530@agrippa.ukshells.co.uk>
|
References |
<20050608104659.E5C6310016A@lists.intevation.de> <20050609002815.179da00b.hamish_nospam@yahoo.com>
|
MIME-Version |
1.0
|
Content-Type |
MULTIPART/MIXED; BOUNDARY="182016655-853398946-1118277565=:11530"
|
X-SA-Do-Not-Run |
Yes
|
X-SA-Exim-Connect-IP |
217.10.143.90
|
X-SA-Exim-Mail-From |
paul-grass@stjohnspoint.co.uk
|
X-SA-Exim-Scanned |
No (on customer-relay-1.mail.uksolutions.net); SAEximRunCond expanded to false
|
X-Spam-Status |
No, hits=-4.9 tagged_above=-999.0 required=3.0 tests=BAYES_00
|
X-Spam-Level |
|
This message is in MIME format. The first part should be readable text,
while the remaining parts are likely unreadable without MIME-aware tools.
--182016655-853398946-1118277565=:11530
Content-Type: TEXT/PLAIN; charset=US-ASCII; format=flowed
On Thu, 9 Jun 2005, Hamish wrote:
> from the cs2cs man page:
>
> "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."
>
>
> I take that to mean it is intended.
It would seem so.
>> would be to change pj_get_kv() (which is called by g.proj) to prepend
>> $GISBASE/etc/nad/ to the name of the gridshift file when it prepares
>> the PROJ string, and to do away with pj_set_finder().
>
> If you say so, you're the expert.
Untested (very simple) patch attached. On second thoughts even if we put
the full path in by default, it is probably best to keep pj_set_finder()
for odd circumstances in PROJ_INFO files, e.g. it would be hard to catch
datumparams: nadgrids=conus
which has been valid up to now.
Paul
--182016655-853398946-1118277565=:11530
Content-Type: TEXT/PLAIN; charset=US-ASCII; name="nadgrids.diff"
Content-Transfer-Encoding: BASE64
Content-ID: <Pine.LNX.4.60.0506090139250.11530@agrippa.ukshells.co.uk>
Content-Description:
Content-Disposition: attachment; filename="nadgrids.diff"
SW5kZXg6IGluY2x1ZGUvZ3Byb2plY3RzLmgNCj09PT09PT09PT09PT09PT09
PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09
PT09PT0NClJDUyBmaWxlOiAvZ3Jhc3NyZXBvc2l0b3J5L2dyYXNzNi9pbmNs
dWRlL2dwcm9qZWN0cy5oLHYNCnJldHJpZXZpbmcgcmV2aXNpb24gMS41DQpk
aWZmIC11IC1yMS41IGdwcm9qZWN0cy5oDQotLS0gaW5jbHVkZS9ncHJvamVj
dHMuaAkyNiBKYW4gMjAwNCAxNTozNzoxMiAtMDAwMAkxLjUNCisrKyBpbmNs
dWRlL2dwcm9qZWN0cy5oCTkgSnVuIDIwMDUgMDA6MzM6NTkgLTAw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w
YXJhbXMsICJuYWRncmlkcz0lcyVzLyVzIiwgZ2lzYmFzZSwgR1JJRERJUiwN
CiAJCSAgIEdfZmluZF9rZXlfdmFsdWUoIm5hZGdyaWRzIiwgcHJvamluZm8p
KTsNCiAJcmV0dXJudmFsID0gMjsNCiAgICAgfQ0KSW5kZXg6IGxpYi9wcm9q
L2dldF9wcm9qLmMNCj09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09
PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT0NClJDUyBmaWxl
OiAvZ3Jhc3NyZXBvc2l0b3J5L2dyYXNzNi9saWIvcHJvai9nZXRfcHJvai5j
LHYNCnJldHJpZXZpbmcgcmV2aXNpb24gMS4zDQpkaWZmIC11IC1yMS4zIGdl
dF9wcm9qLmMNCi0tLSBsaWIvcHJvai9nZXRfcHJvai5jCTI2IEphbiAyMDA0
IDE1OjM3OjEyIC0wMDAwCTEuMw0KKysrIGxpYi9wcm9qL2dldF9wcm9qLmMJ
OSBKdW4gMjAwNSAwMDozNDowMCAtMDAwMA0KQEAgLTI1LDggKzI1LDYgQEAN
CiAjaW5jbHVkZSAiZ3Byb2plY3RzLmgiDQogI2RlZmluZSBNQUlODQogDQot
LyogR1JBU1MgcmVsYXRpdmUgbG9jYXRpb24gb2YgZGF0dW0gY29udmVyc2lv
biBsb29rdXAgdGFibGVzICovDQotI2RlZmluZSBHUklERElSICIvZXRjL25h
ZCINCiAvKiBGaW5kZXIgZnVuY3Rpb24gZm9yIGRhdHVtIGNvbnZlcnNpb24g
bG9va3VwIHRhYmxlcyAqLw0KICNkZWZpbmUgRklOREVSRlVOQyBzZXRfcHJv
al9saWINCiAjZGVmaW5lIFBFUk1BTkVOVCAiUEVSTUFORU5UIg0K
--182016655-853398946-1118277565=:11530--
|
|
Fri, Jun 10 2005
17:56:01
|
|
Mail sent by paul-grass@stjohnspoint.co.uk
|
|
Return-Path |
<paul-grass@stjohnspoint.co.uk>
|
Delivered-To |
grass-bugs@lists.intevation.de
|
Date |
Fri, 10 Jun 2005 16:56:28 +0100 (BST)
|
From |
Paul Kelly <paul-grass@stjohnspoint.co.uk>
|
To |
grass-bugs@intevation.de
|
Cc |
Hamish <hamish_nospam@yahoo.com>, grass5@grass.itc.it
|
Subject |
Re: [GRASS5] [bug #3302] (grass) cs2cs with GRASS and NTv2 grid fails
|
In-Reply-To |
<Pine.LNX.4.60.0506090136480.11530@agrippa.ukshells.co.uk>
|
Message-ID |
<Pine.LNX.4.60.0506101653420.31548@agrippa.ukshells.co.uk>
|
References |
<20050608104659.E5C6310016A@lists.intevation.de> <20050609002815.179da00b.hamish_nospam@yahoo.com> <Pine.LNX.4.60.0506090136480.11530@agrippa.ukshells.co.uk>
|
MIME-Version |
1.0
|
Content-Type |
TEXT/PLAIN; charset=US-ASCII; format=flowed
|
X-SA-Do-Not-Run |
Yes
|
X-SA-Exim-Connect-IP |
217.10.143.90
|
X-SA-Exim-Mail-From |
paul-grass@stjohnspoint.co.uk
|
X-SA-Exim-Scanned |
No (on customer-relay-1.mail.uksolutions.net); SAEximRunCond expanded to false
|
X-Spam-Status |
No, hits=-4.9 tagged_above=-999.0 required=3.0 tests=BAYES_00
|
X-Spam-Level |
|
On Thu, 9 Jun 2005, Paul Kelly wrote:
> Untested (very simple) patch attached. On second thoughts even if we put the
> full path in by default, it is probably best to keep pj_set_finder() for odd
> circumstances in PROJ_INFO files, e.g. it would be hard to catch
> datumparams: nadgrids=conus
> which has been valid up to now.
I am tempted to submit the patch as going by what Hamish said, I am
confident it will solve the problem. The only problem might be if people
are using the output of g.proj -j for some generic purpose. Now (if
gridshift datum files are used in the projection definition) it will be
machine-specific as the path to the gridshift files is hardcoded. But
being machine-specific is possibly less of a disadvantage than being
GRASS-specific, especially if people are using other GIS software.
So if there are no objections I will apply the patch in a few days.
Paul
|
|
Wed, Jun 22 2005
01:09:32
|
|
Status changed to resolved by pkelly
|
|
Wed, Jun 22 2005
01:09:32
|
|
Mail sent by pkelly
|
|
Fix committed to 6.1-CVS today. |
|