[Proj] Extracting the to_meter parameter from a projection

Frank Warmerdam warmerdam at pobox.com
Tue Nov 15 13:26:55 PST 2005


On 11/15/05, Hearne, Michael  (US SSA) <michael.hearne at baesystems.com> wrote:
> I'm working on a piece of software that uses proj4 as a library.  I have
> it working, and for the most part, understand how to get it to do what I
> want.  What I cannot quite figure out, however, is how to determine the
> units of a given projection.  I did a little digging through the source,
> trying to find this, and the closest I could come to this was the
> "PJconsts" struct defined in projects.h.  This structure contains
> parameters "to_meter" and "from_meter", which presumably are values that
> one could use to convert whatever units the projected values are in to
> or from meters.

Michael,

You can call pj_get_units_ref() to fetch a pointer to the
pj_units table (see pj_units.c).  This table relates the short
name for units with a size of the unit (in terms of meters) and
a long name.

> I have not been able to find anything that would tell me how to
> instantiate a "PJconsts" structure.
>
> If my usage to create a projection is something like this:
>
> inProj = pj_init(nParams,(char**)params);
>
> then is there a function (or chain of functions) that I can call that
> will get me either the units of the projection, or the "to_meter" and
> "from_meter" values?
>
> I've already experimented with pj_get_def, and I get a string like this:
>
> " +proj=utm +datum=WGS84 +ellps=WGS84 +towgs84=0,0,0"

If pj_get_def()'s return string does not include a unit specifier
(either as +to_meter= or as +unit=) then the units are implicitly
meter.

> which has no information about the units or how to convert from whatever
> the units might be.
>
> More generally, is there any documentation (a la doxygen) on the Proj4
> API?

There is a limited man page on the API but it does not
include some of the more esoteric API entry points.

  http://proj.maptools.org/man_pj_init.html

Best regards,
--
---------------------------------------+--------------------------------------
I set the clouds in motion - turn up   | Frank Warmerdam, warmerdam at pobox.com
light and sound - activate the windows | http://pobox.com/~warmerdam
and watch the world go round - Rush    | Geospatial Programmer for Rent




More information about the Proj mailing list