[Proj] False Easting & Northing for LAEA?

Fischer, Robert P. (GISS-6110)[COLUMBIA UNIVERSITY] robert.p.fischer-1 at nasa.gov
Mon Apr 9 19:40:23 PDT 2012


Eric,

Thanks a lot.  Now that I see it, it's obvious!  Sorry for posting to the list for such a trivial problem.

-- Bob
________________________________________
From: proj-bounces at lists.maptools.org [proj-bounces at lists.maptools.org] On Behalf Of Eric Miller [EMiller at dfg.ca.gov]
Sent: Monday, April 09, 2012 11:51 AM
To: proj at lists.maptools.org
Subject: Re: [Proj] False Easting & Northing for LAEA?

I think you want "x_0" and "y_0".
--

Eric G. Miller
Software Developer
CA Dept. of Fish & Game


>>> On 4/9/2012 at  7:07 AM, Bob Fischer <robert.p.fischer-1 at nasa.gov> wrote:
> Hello,
>
> I'm pretty new to Proj.4.  I'm having a bit of trouble with false
> easting and northing.  See code below (using a simple C++ wrapper):
>
>     const double D2R = M_PI / 180.0;
>
>      double proj_lon_0 = -40;
>      double proj_lat_0 = 74;
>      char sproj[100];
>      sprintf(sproj, "+proj=laea +lon_0=%f +lat_0=%f +x0=1000000
> +y0=1700000 +ellps=sphere",
>          proj_lon_0, proj_lat_0);
>      printf("Using projection: \"%s\"\n", sproj);
>      Proj proj(sproj);
>      printf("Using full projection: \"%s\"\n", proj.get_def().c_str());
>
> The output is:
>
> Using projection: "+proj=laea +lon_0=-40.000000 +lat_0=74.000000
> +x0=1000000 +y0=1700000 +ellps=sphere"
> Using full projection: " +proj=laea +lon_0=-40.000000 +lat_0=74.000000
> +ellps=sphere"
>
> Note that my false easting/northing has been removed from my proj.4
> string!  The fact that no false easting/northing is being used is
> confirmed when I try to transform a point:
>
>      double lon00 = -40;
>      double lat00 = 74;
>      double xp,yp;
>      int err = transform(llproj, proj, lon00*D2R, lat00*D2R, xp, yp);
>      printf("Proj.4 transform 00 -> (%f, %f) (err = %d)\n", xp, yp, err);
>
> Output is:
>
>    Proj.4 transform 00 -> (0.000000, -0.000000) (err = 0)
>
> Any ideas on why I'm not getting a false easting/northing here?  I can
> certainly work around the problem, but it would be nice if it could work.
>
> Thanks!
> -- Bob
>
> (C++ wrapper is included below, for reference)
>
>
>
> /** C++ API for proj.4 Projection Library.
> Copyright (c) 2012 by Robert Fischer: robert.fischer at nasa.gov
> April 5, 2012
>
>   Permission is hereby granted, free of charge, to any person obtaining a
>   copy of this software and associated documentation files (the "Software"),
>   to deal in the Software without restriction, including without limitation
>   the rights to use, copy, modify, merge, publish, distribute, sublicense,
>   and/or sell copies of the Software, and to permit persons to whom the
>   Software is furnished to do so, subject to the following conditions:
>
>   The above copyright notice and this permission notice shall be included
>   in all copies or substantial portions of the Software.
>
>   THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
>   OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
> MERCHANTABILITY,
>   FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
>   THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
>   LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
>   FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
>   DEALINGS IN THE SOFTWARE.
> */
>
> #ifndef PROJPP_HPP
> #define PROJPP_HPP
>
> #include <proj_api.h>
>
>
> #if 0
> class ProjContext;
>
> class ProjStatic {
> public:
>      ProjContext const defaultContext;
>
>      ProjStatic();
> };
> extern ProjStatic projStatic;
>
>
> class ProjContext {
>      projCtx ctx;
>
> public :
>
>
> };
>
> #endif
>
> namespace giss {
>
> class Proj {
>      projPJ pj;
>
>      explicit Proj(projPJ _pj) : pj(_pj) {}
>
> public:
>      friend int transform(Proj const &src, Proj const &dest,
>          long point_count, int point_offset,
>          double *x, double *y, double *z);
>
>
>      // ------------------ Five Standard constructors/methods
>      // See: http://www2.research.att.com/~bs/C++0xFAQ.html
>
>      explicit Proj(std::string const &definition)
>      {
>          pj = pj_init_plus(definition.c_str());
>          // pj_def = 0;
>      }
>
>      explicit Proj(char const *definition)
>      {
>          pj = pj_init_plus(definition);
>      }
>
>      ~Proj()
>      {
>          pj_free(pj);
>          // if (pj_def) pj_dalloc(pj_def);
>      }
>
>      /** Transfer ownership */
>      Proj(Proj&& h) : pj{h.pj} //, pj_def{h.pj_def}
>      {
>          h.pj = 0;
>          // h.pj_def = 0;
>      }
>
>      /** Transfer value */
>      Proj& operator=(Proj&& h) = delete;
>
>      /** Copy constructor */
>      Proj(const Proj &h)
>      {
>          char *pj_def = pj_get_def(h.pj, 0);
>          pj = pj_init_plus(pj_def);
>          pj_dalloc(pj_def);
>      }
>
>      // no copy with operator=()
>      Proj& operator=(const Proj&) = delete;
>
>      // --------------------------- Other Stuff
>
>
>      /** Returns TRUE if the passed coordinate system is geographic
>      (proj=latlong). */
>      int is_latlong() const
>          { return pj_is_latlong(pj); }
>
>
>      /** Returns TRUE if the coordinate system is geocentric
>      (proj=geocent). */
>      int is_geocent() const
>          { return pj_is_geocent(pj); }
>
>      /** Returns the PROJ.4 initialization string suitable for use with
>      pj_init_plus() that would produce this coordinate system, but with the
>      definition expanded as much as possible (for instance +init= and
>      +datum= definitions).
>      @param options Unused at this point
>      */
>      std::string get_def(int options=0) const
>      {
>          char *pj_def = 0;
>          pj_def = pj_get_def(pj, options);
>
>          std::string ret = std::string(pj_def);
>          pj_dalloc(pj_def);
>          return ret;
>      }
>
>
>      /** Returns a new coordinate system definition which is the geographic
>      coordinate (lat/long) system underlying pj_in. */
>      Proj latlong_from_proj() const
>      {
>          return Proj(pj_latlong_from_proj(pj));
>      }
>
> };
>
>
> inline int transform(Proj const &src, Proj const &dest,
>      long point_count, int point_offset, double *x, double *y, double *z=0)
> {
>      return pj_transform(src.pj, dest.pj,
>          point_count, point_offset, x, y, z);
> }
>
> inline int transform(Proj const &src, Proj const &dest,
>      double x0, double y0, double &x1, double &y1)
> {
>      x1 = x0;
>      y1 = y0;
>      int ret = transform(src, dest, 1, 1, &x1, &y1);
>      return ret;
> }
>
>
> }
>
> #endif
>
> _______________________________________________
> 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



More information about the Proj mailing list