[Proj] NZGD2000 to NZGD49
Anthony Dunk
AnthonyD at rocketmail.com
Wed May 17 00:06:39 PDT 2006
Hi Simon,
I'm glad my email was of some help. I forgot to mention you should
include the ".gsb" on the end of the grid file name though.
I am no familiar with postgres, but the way the PROJ library finds the
grid shift files is by looking in the folder pointed to by the PROJ_LIB
environment variable if this is set. Otherwise it looks in a default
directory which is precompiled in - and varies depending on the build.
So, I suggest you try setting PROJ_LIB to the directory where your grid
shift files live and see if that works for you.
Anthony.
--- Simon O'Malley <simonom at gmail.com> wrote:
> Hi Anthony
>
> Thanks for the tips.
>
> I checked the epsg file and also read the man page for cs2cs which I
> should
> have done first.
>
> Using cs2cs -lp and -ld showed that nzgd49 and nzmg were available
> but
> nzgd2000 was conspicuous by it's absence.
>
> The epsg file had the following for nzgd2000:
>
> +proj=longlat +ellps=GRS80 +towgs84=0,0,0,0,0,0,0 +no_defs
>
> So I then tried the following:
>
> cs2cs +proj=longlat +ellps=GRS80 +towgs84=0,0,0,0,0,0,0 +no_defs +to
> +proj=nzmg +datum=nzgd49 +nadgrids=nzgd2kgrid0005
>
> Which seemed to work (the first set of coordinates entered get
> droppped, but
> I think I saw a bug logged for that already).
>
> Using the following coordinates:
>
> 175.232739997 -37.3476467750
>
> Gave me:
>
> 2708093.01 6425845.96
>
> Whereas the LINZ site (
>
http://www.linz.govt.nz/rcs/linz/pub/web/root/core/SurveySystem/GeodeticInfo/CoordinateConversions/coordinateconversions/index.jsp
>
> Gave me the following for the conversion:
>
> 175.232739997 -37.347646775 2708091.7091 6425845.7365
>
> Which is 2 meters different in the x coordinate.
>
> I then set PROJ_DEBUG to see what was going on and it said it
> couldn't open
> /usr/local/share/proj/nzgd2kgrid0005, so I changed the command to add
> in the
> .gsb on the end and got the correct answer (saw somehwre on the net
> with the
> .gsb dropped off so incorrectly thought it was not needed).
>
> cs2cs +proj=longlat +ellps=GRS80 +a=6378137 +rf=298.257222101 +to
> +proj=nzmg
> +datum=nzgd49 +nadgrids=nzgd2kgrid0005.gsb
> pj_open_lib(proj_def.dat): call
> fopen(/usr/local/share/proj/proj_def.dat) -
> succeeded
> pj_open_lib(proj_def.dat): call
> fopen(/usr/local/share/proj/proj_def.dat) -
> succeeded
>
> pj_open_lib(nzgd2kgrid0005.gsb): call
> fopen(/usr/local/share/proj/nzgd2kgrid0005.gsb) - succeeded
> NTv2 NZNAT 141x141: LL=(166,-48) UR=(180,-34)
> pj_apply_gridshift(): failed to find a grid shift table for
> location (0.0000000dW,0.0000000dN)
> tried: nzgd2kgrid0005.gsb
> * * 0.00
> 175.232739997 -37.3476467750
> NTv2 - loading grid NZNAT
> pj_open_lib(nzgd2kgrid0005.gsb): call
> fopen(/usr/local/share/proj/nzgd2kgrid0005.gsb) - succeeded
> pj_apply_gridshift(): used NZNAT
> 2708091.71 6425845.74 -0.00
>
> Success, thank you.
>
> I mainly use postgres and have data stored in
> NZGD2000/latlong(SRID=4167),
> which I need to convert to NZMG (SRID=27200)
>
> How do I set up proj so that it uses the grid shift for this
> transform. Do I
> have to add something somewhere to make it use it?
> Postgres doco states if it is there it will use it but how???? cs2cs
> had a
> lot of trouble, and using transform in postgres gives the same result
> as
> cs2cs not finding the gsb file.
>
> Simon
>
> On 5/17/06, Anthony Dunk <AnthonyD at rocketmail.com> wrote:
> >
> > Hi Simon,
> >
> > I think the problem is that NZ datums are not defined in PROJ (I
> found
> > the same was true of Australian datums). You will need to provide
> the
> > ellipsoid parameters for these datums instead. i.e. +a=6378388.0
> > +rf=297.0 for NZGD49 and +a=6378137.0 +rf=298.257222 for NZGD2000.
> >
> > So, to convert from NZGD200 Lat/Lon to NZGD49 Lat/Lon try this:
> >
> > cs2cs +proj=latlong +a=6378137.0 +rf=298.257222 +to +proj=latlong
> > +a=6378388.0 +rf=297.0 +nadgrids=nzgd2kgrid0005
> >
> > Anthony.
> >
> > --- Simon O'Malley <simonom at gmail.com> wrote:
> >
> > > Hi
> > >
> > > I am trying to test the datum shift (using nzgd2kgrid0005.gsb
> file)
> > > for
> > > conversions between NZGD2000 and NZGD49(NZMG).
> > >
> > > I have downloaded the proj-datumgrid-1.3.zip file, and extracted
> > > everything
> > > under the nad directory.
> > >
> > > configured, make, and make install. However the gsb file does not
> get
> > > copied
> > > to /usr/local/share/proj
> > >
> > > I copied it across but postgis does not appear to use it i.e. my
> > > transformed
> > > coordinates are not correct, as verified by the linz website and
> > > other
> > > software that uses the grid file.
> > >
> > > I then tried to use cs2cs to validate it but all attempts at
> > > specifying the
> > > projections and datums gave me errors.
> > >
> > > I have tried multiple versions of:
> > >
> > > cs2cs +proj=latlong +datum=nzgd2000 +nadgrids=nzgd2kgrid0005 +to
> > > +proj=nzmg
> > > +datum=nzgd49
> > >
> > > After setting PROJ_DEBUG I get:
> > >
> > > pj_open_lib(proj_def.dat): call
> > > fopen(/usr/local/share/proj/proj_def.dat) -
> > > succeeded
> > > Using from definition: proj=latlong datum=nzgd2000
> > > nadgrids=nzgd2kgrid0005
> > > Rel. 4.4.9, 29 Oct 2004
> > > <cs2cs>:
> > > projection initialization failure
> > > cause: unknown elliptical parameter name
> > > program abnormally terminated
> > >
> > > Tried upper and lower case NZGD2000, NZGD49, NZMG, latlong,
> longlat,
> > > without
> > > nadgrids???
> > > Do I have to add an ellipsoid to the projection definitions for
> > > cs2cs?
> > >
> > > The grid shift file does not appear to mentioned in any of the
> files
> > > in
> > > /usr/local/share/proj is that normal?
> > >
> > > Some pointers would be appreciated.
> > >
> > > Simon
> > > > _______________________________________________
> > > Proj mailing list
> > > Proj at lists.maptools.org
> > > http://lists.maptools.org/mailman/listinfo/proj
> >
> >
> >
> >
> > __________________________________________________
> > Do You Yahoo!?
> > Tired of spam? Yahoo! Mail has the best spam protection around
> > http://mail.yahoo.com
> > _______________________________________________
> > Proj mailing list
> > Proj at lists.maptools.org
> > http://lists.maptools.org/mailman/listinfo/proj
> >
> > _______________________________________________
> Proj mailing list
> Proj at lists.maptools.org
> http://lists.maptools.org/mailman/listinfo/proj
__________________________________________________
Do You Yahoo!?
Tired of spam? Yahoo! Mail has the best spam protection around
http://mail.yahoo.com
More information about the Proj
mailing list