[PROJ] Getting "proj" and "datum" for a CRS

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

[PROJ] Getting "proj" and "datum" for a CRS

Nyall Dawson
Hi list,

Next question:

If I have a crs created from a proj string like:

+proj=tmerc +lat_0=0 +lon_0=102 +k=0.9999 +x_0=500000 +y_0=0 +ellps=WGS84 +units=m +no_defs +type=crs

1. How can I get the "tmerc" acronym from the proj API? If I call proj_crs_get_coordoperation and then proj_coordoperation_get_method_info I can retrieve the method name, but this is a long version of this value (ie. ."Transverse Mercator", not the tmerc acronym)

2. How can I get the ellipsoid/datum value? Again, I can call proj_get_ellipsoid to get an ellipsoid, and from that I've been using proj_get_id_auth_name/proj_get_id_code. But this only sometimes gives a value, and ideally I'm trying to retrieve the "WGS84" value used in the original proj string.

(I'm trying to use the official proj methods to retrieve these values - without resorting to regex parsing)

3. Using proj_as_proj_string sometimes results in errors like: "proj_as_proj_string: Unsupported conversion method: Lambert Conic Conformal (West Orientated)". I'm guessing this indicates that there's NO way of representing that projection using proj strings, and I'm wasting my time if I try to work around this?

Nyall


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

Re: Getting "proj" and "datum" for a CRS

Kristian Evers-2

Nyall,

 

For 1, try giving proj_pj_info() a go. I am not sure that it will work in all situations (a compound CRS will probably not behave as you might want/expect). There’s currently not a similar function for retrieving the ellipsoid id, but it can be added to proj_pj_info() if needed. You are welcome to submit a PR with such a change (if you are quick it can be part of 6.1.0).

 

/Kristian

 

Fra: PROJ <[hidden email]> På vegne af Nyall Dawson
Sendt: 3. maj 2019 03:38
Til: PROJ <[hidden email]>
Emne: [PROJ] Getting "proj" and "datum" for a CRS

 

Hi list,

 

Next question:

 

If I have a crs created from a proj string like:

 

+proj=tmerc +lat_0=0 +lon_0=102 +k=0.9999 +x_0=500000 +y_0=0 +ellps=WGS84 +units=m +no_defs +type=crs

 

1. How can I get the "tmerc" acronym from the proj API? If I call proj_crs_get_coordoperation and then proj_coordoperation_get_method_info I can retrieve the method name, but this is a long version of this value (ie. ."Transverse Mercator", not the tmerc acronym)

 

2. How can I get the ellipsoid/datum value? Again, I can call proj_get_ellipsoid to get an ellipsoid, and from that I've been using proj_get_id_auth_name/proj_get_id_code. But this only sometimes gives a value, and ideally I'm trying to retrieve the "WGS84" value used in the original proj string.

 

(I'm trying to use the official proj methods to retrieve these values - without resorting to regex parsing)

 

3. Using proj_as_proj_string sometimes results in errors like: "proj_as_proj_string: Unsupported conversion method: Lambert Conic Conformal (West Orientated)". I'm guessing this indicates that there's NO way of representing that projection using proj strings, and I'm wasting my time if I try to work around this?

 

Nyall

 


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

Re: Getting "proj" and "datum" for a CRS

Even Rouault-2
In reply to this post by Nyall Dawson
On vendredi 3 mai 2019 11:37:58 CEST Nyall Dawson wrote:

> Hi list,
>
> Next question:
>
> If I have a crs created from a proj string like:
>
> +proj=tmerc +lat_0=0 +lon_0=102 +k=0.9999 +x_0=500000 +y_0=0 +ellps=WGS84
> +units=m +no_defs +type=crs
>
> 1. How can I get the "tmerc" acronym from the proj API? If I
> call proj_crs_get_coordoperation and
> then proj_coordoperation_get_method_info I can retrieve the method name,
> but this is a long version of this value (ie. ."Transverse Mercator", not
> the tmerc acronym)
>
> 2. How can I get the ellipsoid/datum value? Again, I can
> call proj_get_ellipsoid to get an ellipsoid, and from that I've been
> using proj_get_id_auth_name/proj_get_id_code. But this only sometimes gives
> a value, and ideally I'm trying to retrieve the "WGS84" value used in the
> original proj string.
>
> (I'm trying to use the official proj methods to retrieve these values -
> without resorting to regex parsing)

As Kristian said, there's no such methods.

>
> 3. Using proj_as_proj_string sometimes results in errors like:
> "proj_as_proj_string: Unsupported conversion method: Lambert Conic
> Conformal (West Orientated)". I'm guessing this indicates that there's NO
> way of representing that projection using proj strings, and I'm wasting my
> time if I try to work around this?

Yes, there are a few projection methods in the EPSG dataset which aren't
supported by PROJ

Even

--
Spatialys - Geospatial professional services
http://www.spatialys.com
_______________________________________________
PROJ mailing list
[hidden email]
https://lists.osgeo.org/mailman/listinfo/proj
Reply | Threaded
Open this post in threaded view
|

Re: Getting "proj" and "datum" for a CRS

Even Rouault-2
In reply to this post by Kristian Evers-2
On vendredi 3 mai 2019 06:52:18 CEST Kristian Evers wrote:
> Nyall,
>
> For 1, try giving proj_pj_info() a go. I am not sure that it will work in
> all situations (a compound CRS will probably not behave as you might
> want/expect). There’s currently not a similar function for retrieving the
> ellipsoid id, but it can be added to proj_pj_info() if needed. You are
> welcome to submit a PR with such a change (if you are quick it can be part
> of 6.1.0).

I'd note that adding a new member to PJ_PROJ_INFO will change the ABI in a
incompatible manner. Will/would require a libtool 'current' bump


--
Spatialys - Geospatial professional services
http://www.spatialys.com
_______________________________________________
PROJ mailing list
[hidden email]
https://lists.osgeo.org/mailman/listinfo/proj
Reply | Threaded
Open this post in threaded view
|

Re: Getting "proj" and "datum" for a CRS

Nyall Dawson
On Fri, 3 May 2019 at 17:48, Even Rouault <[hidden email]> wrote:

>
> On vendredi 3 mai 2019 06:52:18 CEST Kristian Evers wrote:
> > Nyall,
> >
> > For 1, try giving proj_pj_info() a go. I am not sure that it will work in
> > all situations (a compound CRS will probably not behave as you might
> > want/expect). There’s currently not a similar function for retrieving the
> > ellipsoid id, but it can be added to proj_pj_info() if needed. You are
> > welcome to submit a PR with such a change (if you are quick it can be part
> > of 6.1.0).
>
> I'd note that adding a new member to PJ_PROJ_INFO will change the ABI in a
> incompatible manner. Will/would require a libtool 'current' bump

So is this a -1 on this change? I'm conscious the deadline is closing
for 6.1....

At the moment I'm wondering if I'll need to just resort to a regex to
get this property (argh!) as I'd need that as a fallback for proj 6.0
in any case.

Nyall



>
>
> --
> Spatialys - Geospatial professional services
> http://www.spatialys.com
_______________________________________________
PROJ mailing list
[hidden email]
https://lists.osgeo.org/mailman/listinfo/proj
Reply | Threaded
Open this post in threaded view
|

Re: Getting "proj" and "datum" for a CRS

Even Rouault-2
> > I'd note that adding a new member to PJ_PROJ_INFO will change the ABI in a
> > incompatible manner. Will/would require a libtool 'current' bump
>
> So is this a -1 on this change? I'm conscious the deadline is closing
> for 6.1....

I'm indifferent. Was mostly to bring that to the attention of Kristian.

>
> At the moment I'm wondering if I'll need to just resort to a regex to
> get this property (argh!)

In an ideal world, QGIS should avoid messing directly with PROJ strings (I
guess this is for some backward compatibility reason regarding QGIS API).
Especially regarding extracting elements from them. Treating the whole string
as an opaque string might be acceptable, although not the most precise
representation compared to using WKT or directly the EPSG:XXXX representation
when available (I know I repeat myself on this, but this is for the education
of the crowds :-))

Even

--
Spatialys - Geospatial professional services
http://www.spatialys.com
_______________________________________________
PROJ mailing list
[hidden email]
https://lists.osgeo.org/mailman/listinfo/proj
Reply | Threaded
Open this post in threaded view
|

Re: Getting "proj" and "datum" for a CRS

Kristian Evers-2


> On 7 May 2019, at 11:37, Even Rouault <[hidden email]> wrote:
>
>>> I'd note that adding a new member to PJ_PROJ_INFO will change the ABI in a
>>> incompatible manner. Will/would require a libtool 'current' bump
>>
>> So is this a -1 on this change? I'm conscious the deadline is closing
>> for 6.1....
>
> I'm indifferent. Was mostly to bring that to the attention of Kristian.
>

Thanks :-) I am of the opinion that we should avoid incompatible changes for
this release. When suggested adding more to PJ_PROJ_INFO I didn’t realize
that it would affect the ABI.

In addition, after having giving this some more though I think there must be a
better way to deal with this problem. A generic function that can returns all
parameters that make up a PJ object would be preferable. A wrapper for
pj_param() would do the trick but a better way likely exists.


>>
>> At the moment I'm wondering if I'll need to just resort to a regex to
>> get this property (argh!)
>
> In an ideal world, QGIS should avoid messing directly with PROJ strings (I
> guess this is for some backward compatibility reason regarding QGIS API).
> Especially regarding extracting elements from them. Treating the whole string
> as an opaque string might be acceptable, although not the most precise
> representation compared to using WKT or directly the EPSG:XXXX representation
> when available (I know I repeat myself on this, but this is for the education
> of the crowds :-))
>
> Even
>
> --
> Spatialys - Geospatial professional services
> http://www.spatialys.com

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

Re: Getting "proj" and "datum" for a CRS

Martin Desruisseaux-3
Le 07/05/2019 à 14:48, Kristian Evers a écrit :
> In addition, after having giving this some more though I think there
> must be a better way to deal with this problem. A generic function
> that can returns all parameters that make up a PJ object would be
> preferable. A wrapper for pj_param() would do the trick but a better
> way likely exists.

An array of OperationParameterValue provided by
SingleOperation.parameterValue method? (ISO 19111 figure 16). I do not
know if PROJ6 already implements those classes, but that would be an ISO
approach if PROJ wishes to continue that path.

    Martin


_______________________________________________
PROJ mailing list
[hidden email]
https://lists.osgeo.org/mailman/listinfo/proj