[PROJ] Geodetic to geographic conversions
Even Rouault
even.rouault at spatialys.com
Sat Oct 31 02:49:13 PDT 2020
On jeudi 29 octobre 2020 08:25:24 CET Nicolas Bellaiche wrote:
> Hi all,
>
> I need to migrate my old PROJ.4 C++ codes to PROJ-7.1.1 and I'm a bit stuck
> with the conversions geodetic <-> geographic coordinates (on the same
> datum).
By geodetic, you mean geocentric ?
> The only doc I could find is this single line but I haven't been
> able to deal with it:
>
>
> pj_latlong_from_proj
>
>
> No direct equivalent, but can be accomplished by chaining
> proj_create()<https://proj.org/development/reference/functions.html#c.proj_
> create>, proj_crs_get_horizontal_datum()
> andproj_create_geographic_crs_from_datum()
Something along:
PJ* datum = proj_crs_get_horizontal_datum(ctxt, geocentric_crs);
PJ* cs = proj_create_ellipsoidal_2D_cs(
ctxt, PJ_ELLPS2D_LONGITUDE_LATITUDE, /* or PJ_ELLPS2D_LATITUDE_LONGITUDE */
NULL, /* default unit name for Degree */
0 /* default conversion factor from Degree to Radian */
);
/* or proj_create_ellipsoidal_3D_cs() depending on your needs */
PJ* geog_crs = proj_create_geographic_crs_from_datum(ctxt, NULL, datum, cs);
proj_destroy(cs);
proj_destroy(datum);
PJ* transf = proj_create_crs_to_crs(ctxt, geocentric_crs, geog_crs, NULL);
proj_trans(transf, ...);
proj_destroy(geog_crs);
Even
--
Spatialys - Geospatial professional services
http://www.spatialys.com
More information about the PROJ
mailing list