The object defines the target projection, but that's easier said than
done: projections have different parameter needs. The parameters which
can (or need to) be used are listed with cs2cs -lP
. The manual
page of cs2cs
explains how the configuration works.
Two ways are provided to define the projection. Either, use a list
of OPTIONS, which are pairs of parameters, or pass one string which
contains all parameters at once. You must supply a proj
parameter.
In case of an OPTION list: WARNING: Specify boolean parameters (e.g. the south parameter to the UTM projection) with a matching value of undef.
my $proj = Geo::Proj4->new(proj => "merc", ellps => "clrk66", lon_0 => -96 ) or die Geo::Proj4->error; my $proj = Geo::Proj4->new("+proj=merc +ellps=clrk66 +lon_0=096") or die Geo::Proj4->error;
Tries to return a datum name for this projection.
Write the definition in extended form to stdout. This output cannot be caught, because it is done on stdio level, below the reach of PerlIO.
Returns whether the reverse function for the projection exists. Some projections are one-way.
Returns true when the source projection is using a geocentric coordinate system; i.e. uses x-y coordinates.
Returns true when the source projection is using a geodetic coordinate system; i.e. uses lat long coordinates. Same as isLatlong()
Returns true when the source projection is using a geodetic coordinate system; i.e. uses lat long coordinates. Same as isGeodesic().
Returns a string which is produced by the library based on the data extracted from the initiation parameters. This string may be more explicit than the passed values, and could be used for debugging.
Returns the projection type.
Perform a forward projection from LATITUDE and LONGITUDE (LL) to the cartographic projection (XY) represented by the Geo::Proj4 instance.
WARNING: for historic reasons, latitude and longitude are assumed to be in (floating point) degrees, although the library expects rads. See forwardRad(). A latitude south of the Equator and longitude west of the Prime Meridian given with negative values.
Returned are two values, usually X and Y in meters, or whatever units are relevant to the given projection. When the destination projection also than the order of parameters will be returned as LONG,LAT (not lat,long!)
On error, forward
will return undef for both values.
my ($x, $y) = $proj->forward($lat, $lon); my ($long2, $lat2) = $proj->forward($lat, $lon);
Perform a forward projection from LATITUDE and LONGITUDE (LL) to the
cartographic projection (XY) represented by the Geo::Proj4 instance.
This function reflects to library function forward()
, expecting
radians, not degrees.
Perform an inverse projection from the (cartographic) projection represented by this Geo::Proj4 object, back into latitude and longitude values.
WARNING: for historic reasons, latitude and longitude are assumed to be in (floating point) degrees, although the library expects rads. See inverseRad().
On error, inverse
will return undef for both values.
if($proj->hasInverse) { my ($lat, $lon) = $proj->inverse($x, $y); ... }
Perform an inverse projection from the (cartographic) projection represented by this Geo::Proj4 object, back into latitude and longitude values. Latitude and longitude are assumed to be in radians. See inverse().
Translate the POINTS into the projecten of TO. Each point is specified as two or three values in an ARRAY. In case of latlong source or destination projections, coordinates are translated into radians and/or back. Both input and output values are always in X-Y/LongLat order. See transformRad()
my $from = Geo::Proj4->new("+proj=latlong +datum=NAD83"); my $to = Geo::Proj4->new("+proj=utm +zone=10 +datum=WGS84"); my $point = [ 1.12, 3.25 ]; # See Geo::Point my $pr_point = $from->transform($to, $point); my $pr = $from->transform($to, [ $point1, $point2 ]); my $pr_point1 = $pr->[0]; my $pr_point2 = $pr->[1];
Translate the POINTS into the projecten of TO. Each point is specified as two or three values in an ARRAY. In case of latlong source or destination projections, coordinates are expected to be in radians. Both input and output values are always in X-Y/LongLat order. See transform()
Returns a hash with information about the specified datum. With listDatums(), all defined LABELS can be found.
Returns a hash with information about the specified ellipsis. With listEllipsoids(), all defined LABELS can be found.
Returns the version of the proj4 library
Returns a list with all defined datum labels.
foreach my $id (Geo::Proj4->listDatums) { my $def = Geo::Proj4->datum($id); print "$id = $def->{ellips_id}\n"; }
Returns a list with all defined ellips labels.
foreach my $id (Geo::Proj4->listEllipsoids) { my $def = Geo::Proj4->ellipsoid($id); print "$id = $def->{name}\n"; }
Returns a hash with information about the specified projection type. With listTypes(), all defined LABELS can be found.
Returns a hash with information about the specified unit. With listUnits(), all defined LABELS can be found.