Extracting the to_meter parameter from a projection

classic Classic list List threaded Threaded
5 messages Options
Reply | Threaded
Open this post in threaded view
|

Extracting the to_meter parameter from a projection

Hearne, Michael (US SSA)
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.

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"

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?

Thanks,

Mike Hearne

_______________________________________________
Proj mailing list
[hidden email]
http://lists.maptools.org/mailman/listinfo/proj
Reply | Threaded
Open this post in threaded view
|

Re: Extracting the to_meter parameter from a projection

Frank Warmerdam
On 11/15/05, Hearne, Michael  (US SSA) <[hidden email]> 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, [hidden email]
light and sound - activate the windows | http://pobox.com/~warmerdam
and watch the world go round - Rush    | Geospatial Programmer for Rent

_______________________________________________
Proj mailing list
[hidden email]
http://lists.maptools.org/mailman/listinfo/proj
Reply | Threaded
Open this post in threaded view
|

Re: Extracting the to_meter parameter from a projection

Hearne, Michael (US SSA)
In reply to this post by Hearne, Michael (US SSA)
Frank - Thanks for your quick response.  I searched through my copy of
the proj4 source and couldn't find a function called pj_get_units_ref().
Is this defined in a relatively recent version of proj4?  My copy is
perhaps a couple of years old.  I do have the pj_units table defined in
"pj_units.c".

Also, we tested pj_get_def() for a fairly exhaustive list of
projections, and none of them returned a "+unit=" string token (list at
bottom of email.)  Does this mean that all of these projections are in
units of meters?

Thanks,

Mike Hearne


Albers_Conical_Equal_Area
Azimuthal_Equidistant
Bipolar_Oblique
Bonne
Cassini
Cylindrical_Equal_Area
Eckert_IV
Eckert_VI
Equidistant_Conic
Gnomonic
Lambert_Azimuthal_Equal_Area
Lambert_Conformal_Conic
Mercator
Miller_Cylindrical
Mollweide
Oblique_Mercator
Orthographic
Polyconic
Sinusoidal
Space_Oblique_Mercator
Stereographic
Transverse_Mercator
Van_der_Grinten_I

_______________________________________________
Proj mailing list
[hidden email]
http://lists.maptools.org/mailman/listinfo/proj
Reply | Threaded
Open this post in threaded view
|

Re: Re: Extracting the to_meter parameter from a projection

Frank Warmerdam
On 11/15/05, Hearne, Michael  (US SSA) <[hidden email]> wrote:
> Frank - Thanks for your quick response.  I searched through my copy of
> the proj4 source and couldn't find a function called pj_get_units_ref().
> Is this defined in a relatively recent version of proj4?  My copy is
> perhaps a couple of years old.  I do have the pj_units table defined in
> "pj_units.c".

Michael,

Yes, pj_get_units_ref() is relatively new.  It, and some similar functions,
were added to give access to internal tables needed for "smart" applications
that need to know more about coordinate system options.

> Also, we tested pj_get_def() for a fairly exhaustive list of
> projections, and none of them returned a "+unit=" string token (list at
> bottom of email.)  Does this mean that all of these projections are in
> units of meters?

All projections methods have an implicit unit type of meters unless
otherwise set.  Try a definition like Arizona East NAD27 (+init=epsg:26748).

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

_______________________________________________
Proj mailing list
[hidden email]
http://lists.maptools.org/mailman/listinfo/proj
Reply | Threaded
Open this post in threaded view
|

Re: Re: Extracting the to_meter parameter from a projection

Gerald I. Evenden-2
IMPORTANT CONCEPT REGARDING ALL PROJ VERSIONS:

One thing to remember with proj AND libproj4 is that neither  care
about units.  Units depend upon the units that define +a (and +b, x_0,
etc.).  All prestored constants for radius or elliptic axis are presented in
meters which is the factor that to_/fr_meter depends upon.

--> IF the user defines +a= in feet, then to_/fr_meter is meaningless and
should not be used and Easting/Northing will be in feet.

As I recall, this material is discussed in the first proj manual.

--
Jerry and the low riders:Daisy May and Joshua
"The being cannot be termed rational or virtuous,
who obeys any authority, but that of reason."
---Mary Wollstonecraft 1792
_______________________________________________
Proj mailing list
[hidden email]
http://lists.maptools.org/mailman/listinfo/proj