[gdal-dev] ImportFromESRIStatePlaneWKT access from python

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
6 messages Options
Reply | Threaded
Open this post in threaded view
|

[gdal-dev] ImportFromESRIStatePlaneWKT access from python

Glen Rice - NOAA Federal
Hello,

I am looking for any hints for how to access ImportFromESRIStatePlaneWKT in the OGRSpatialReference class through the python bindings.  I am working with xyz text files where the header contains a FIPS zone reference and I would like to convert it to another system.

Regards,
Glen


--
Glen Rice
Hydrographic Systems and Technology Branch
Office of Coast Survey / Coast Survey Development Laboratory
603-862-1397

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

Re: ImportFromESRIStatePlaneWKT access from python

Even Rouault-2
On jeudi 9 août 2018 08:42:57 CEST Glen Rice - NOAA Federal wrote:
> Hello,
>
> I am looking for any hints for how to access ImportFromESRIStatePlaneWKT in
> the OGRSpatialReference class through the python bindings.  I am working
> with xyz text files where the header contains a FIPS zone reference and I
> would like to convert it to another system.

You can't from Python. This method is only available from C++.

But perhaps the osr.SetStatePlane(int zone, int is_nad83 = 1, char const
*unitsname = "", double units = 0.0) that corresponds to
OGRSpatialReference::SetStatePlane() will do the job ?

Even

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

Re: ImportFromESRIStatePlaneWKT access from python

Glen Rice - NOAA Federal
Thanks Even,

From the SetStatePlane docs it says
"""
nZoneState plane zone number, in the USGS numbering scheme (as distinct from the Arc/Info and Erdas numbering scheme.
"""
which would seem to indicate that using the FIPS code in place of the USGS numbering scheme will lead to erroneous results.  It appears that my best path forward with FIPS within GDAL with python would be to read the Lib/site-packages/osgeo/data/gdal/esri_StatePlane_extra.wkt file directly and build a small converter utility.

Glen

On Thu, Aug 9, 2018 at 9:02 AM, Even Rouault <[hidden email]> wrote:
On jeudi 9 août 2018 08:42:57 CEST Glen Rice - NOAA Federal wrote:
> Hello,
>
> I am looking for any hints for how to access ImportFromESRIStatePlaneWKT in
> the OGRSpatialReference class through the python bindings.  I am working
> with xyz text files where the header contains a FIPS zone reference and I
> would like to convert it to another system.

You can't from Python. This method is only available from C++.

But perhaps the osr.SetStatePlane(int zone, int is_nad83 = 1, char const
*unitsname = "", double units = 0.0) that corresponds to
OGRSpatialReference::SetStatePlane() will do the job ?

Even

--
Spatialys - Geospatial professional services
http://www.spatialys.com



--
Glen Rice
Hydrographic Systems and Technology Branch
Office of Coast Survey / Coast Survey Development Laboratory
603-862-1397

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

Re: ImportFromESRIStatePlaneWKT access from python

Even Rouault-2
On jeudi 9 août 2018 09:27:43 CEST Glen Rice - NOAA Federal wrote:

> Thanks Even,
>
> From the SetStatePlane docs
> <https://www.gdal.org/classOGRSpatialReference.html#a4e0f1e23207c157f7238871
> 7c35be88c> it says
> """
> nZone State plane zone number, in the USGS numbering scheme (as distinct
> from the Arc/Info and Erdas numbering scheme."""
> which would seem to indicate that using the FIPS code in place of the USGS
> numbering scheme will lead to erroneous results.

The mapping from USGS (left column) to ESRI (right column) zone number is at:
https://github.com/OSGeo/gdal/blob/master/gdal/ogr/ogr_srs_esri.cpp#L134
and ultimately this reads the data/stateplane.csv with the USGS zone number as
a key.


> It appears that my best
> path forward with FIPS within GDAL with python would be to read
> the Lib/site-packages/osgeo/data/gdal/esri_StatePlane_extra.wkt file
> directly and build a small converter utility.

Sounds reasonable

>
> Glen
>
> On Thu, Aug 9, 2018 at 9:02 AM, Even Rouault <[hidden email]>
>
> wrote:
> > On jeudi 9 août 2018 08:42:57 CEST Glen Rice - NOAA Federal wrote:
> > > Hello,
> > >
> > > I am looking for any hints for how to access ImportFromESRIStatePlaneWKT
> >
> > in
> >
> > > the OGRSpatialReference class through the python bindings.  I am working
> > > with xyz text files where the header contains a FIPS zone reference and
> > > I
> > > would like to convert it to another system.
> >
> > You can't from Python. This method is only available from C++.
> >
> > But perhaps the osr.SetStatePlane(int zone, int is_nad83 = 1, char const
> > *unitsname = "", double units = 0.0) that corresponds to
> > OGRSpatialReference::SetStatePlane() will do the job ?
> >
> > Even
> >
> > --
> > Spatialys - Geospatial professional services
> > http://www.spatialys.com


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

Re: ImportFromESRIStatePlaneWKT access from python

Glen Rice - NOAA Federal
This is a followup comment for completeness in case someone else tries to go down the same path of ingesting the ImportFromESRIStatePlaneWKT file directly.

I found that when I used the resulting wkt directly in an instance of osr.CoordinateTransformation I got the following error:
"""
ERROR 6: No translation for Lambert_Conformal_Conic to PROJ.4 format is known.
Wrong number or type of arguments for overloaded function 'CoordinateTransformation_TransformPoint'.
  Possible C/C++ prototypes are:
    OSRCoordinateTransformationShadow::TransformPoint(double [3])
    OSRCoordinateTransformationShadow::TransformPoint(double [3],double,double,double)
"""

After some mucking around I found that updating the PROJECTION from "Lambert_Conformal_Conic" to "Lambert_Conformal_Conic_2SP" fixed the problem.

Kind regards,
Glen

On Thu, Aug 9, 2018 at 9:40 AM, Even Rouault <[hidden email]> wrote:
On jeudi 9 août 2018 09:27:43 CEST Glen Rice - NOAA Federal wrote:
> Thanks Even,
>
> From the SetStatePlane docs
> <https://www.gdal.org/classOGRSpatialReference.html#a4e0f1e23207c157f7238871
> 7c35be88c> it says
> """
> nZone State plane zone number, in the USGS numbering scheme (as distinct
> from the Arc/Info and Erdas numbering scheme."""
> which would seem to indicate that using the FIPS code in place of the USGS
> numbering scheme will lead to erroneous results.

The mapping from USGS (left column) to ESRI (right column) zone number is at:
https://github.com/OSGeo/gdal/blob/master/gdal/ogr/ogr_srs_esri.cpp#L134
and ultimately this reads the data/stateplane.csv with the USGS zone number as
a key.


> It appears that my best
> path forward with FIPS within GDAL with python would be to read
> the Lib/site-packages/osgeo/data/gdal/esri_StatePlane_extra.wkt file
> directly and build a small converter utility.

Sounds reasonable

>
> Glen
>
> On Thu, Aug 9, 2018 at 9:02 AM, Even Rouault <[hidden email]>
>
> wrote:
> > On jeudi 9 août 2018 08:42:57 CEST Glen Rice - NOAA Federal wrote:
> > > Hello,
> > >
> > > I am looking for any hints for how to access ImportFromESRIStatePlaneWKT
> >
> > in
> >
> > > the OGRSpatialReference class through the python bindings.  I am working
> > > with xyz text files where the header contains a FIPS zone reference and
> > > I
> > > would like to convert it to another system.
> >
> > You can't from Python. This method is only available from C++.
> >
> > But perhaps the osr.SetStatePlane(int zone, int is_nad83 = 1, char const
> > *unitsname = "", double units = 0.0) that corresponds to
> > OGRSpatialReference::SetStatePlane() will do the job ?
> >
> > Even
> >
> > --
> > Spatialys - Geospatial professional services
> > http://www.spatialys.com


--
Spatialys - Geospatial professional services
http://www.spatialys.com



--
Glen Rice
Hydrographic Systems and Technology Branch
Office of Coast Survey / Coast Survey Development Laboratory
603-862-1397

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

Re: ImportFromESRIStatePlaneWKT access from python

Even Rouault-2
On vendredi 17 août 2018 16:54:42 CEST Glen Rice - NOAA Federal wrote:

> This is a followup comment for completeness in case someone else tries to
> go down the same path of ingesting the ImportFromESRIStatePlaneWKT file
> directly.
>
> I found that when I used the resulting wkt directly in an instance
> of osr.CoordinateTransformation I got the following error:
> """
> ERROR 6: No translation for Lambert_Conformal_Conic to PROJ.4 format is
> known.
> Wrong number or type of arguments for overloaded function
> 'CoordinateTransformation_TransformPoint'.
>   Possible C/C++ prototypes are:
>     OSRCoordinateTransformationShadow::TransformPoint(double [3])
>     OSRCoordinateTransformationShadow::TransformPoint(double
> [3],double,double,double)
> """
>
> After some mucking around I found that updating the PROJECTION from
> "Lambert_Conformal_Conic" to "Lambert_Conformal_Conic_2SP" fixed the
> problem.

ImportFromESRIStatePlaneWKT() likely brings you a WKT in ESRI variant format,
which isn't understood by other parts of GDAL.
The 'clean' way is to massage it into the more standard OGC WKT v1 with
OGRSpatialReference::morphFromESRI(), which will among other things will
transform "Lambert_Conformal_Conic" to "Lambert_Conformal_Conic_2SP"

Even

--
Spatialys - Geospatial professional services
http://www.spatialys.com
_______________________________________________
gdal-dev mailing list
[hidden email]
https://lists.osgeo.org/mailman/listinfo/gdal-dev