[gdal-dev] Python interface to wrapdateline

Sean Gillies sean at mapbox.com
Tue May 10 08:51:20 PDT 2016


Hi Brendan,

On Tue, May 10, 2016 at 8:45 AM, Even Rouault <even.rouault at spatialys.com>
wrote:

> Le mardi 10 mai 2016 16:31:44, DeTracey, Brendan a écrit :
> > Hi,
> >
> > Is there any way to access the wrap dateline capabilities of OGR from the
> > Python interface? For example how to split the following polygon:
> >
> > from osgeo import ogr, osr
> > srs = osr.SpatialReference()
> > srs.ImportFromEPSG(4326)
> > p = ogr.CreateGeometryFromWkt('POLYGON ((160 1, -160 1, -160 -1, 160 -1,
> > 160 1))')
> >
> >
> > Looking at the OGRGeometryFactory  source I see :
> > static void CutGeometryOnDateLineAndAddToMulti(OGRGeometryCollection*
> > poMulti, const OGRGeometry* poGeom, double dfDateLineOffset)
> >
> > but I can't see how to access it from Python. Would it be via an option
> to
> > the ogr.CreateGeometryFromWkt?
>
> No, this is unavailable through Python bindings.
>
> With GDAL 2.1, you can use gdal.VectorTranslate() (librarified version of
> ogr2ogr), although it might not be very practical if you just need to do
> that
> on a single geometry.
>

I don't know if using the Python interface to OGR named Fiona is an option
for you (Windows support is not 100%), but antimeridian cutting is readily
available in the Fiona API:
https://github.com/Toblerity/Fiona/blob/master/fiona/transform.py#L62-L64.

>
-- 
Sean Gillies
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osgeo.org/pipermail/gdal-dev/attachments/20160510/fbb6083b/attachment.html>


More information about the gdal-dev mailing list