[gdal-dev] Re: can ogr2ogr split polygons that cross 180 degree longitude

Even Rouault even.rouault at mines-paris.org
Mon Sep 28 17:07:01 EDT 2009


Selon Hermann Peifer <peifer at gmx.eu>:

I've finally added a new switch to ogr2ogr : -wrapdateline. See
http://trac.osgeo.org/gdal/ticket/3158

> Even,
>
> Thanks for the possible algorithm.... but to be honest: some sort of
> command line switch would be /somewhat more handy/, for non-programmers
> like me.
>
> Hermann
>
> Even Rouault wrote:
> > Selon Hermann Peifer <peifer at gmx.eu>:
> >
> > I think this should be prefectly doable with some code/script just using
> OGR
> > API.
> >
> > Here's a possible algorithm :
> >
> > 1) Create a new empty WGS84 shapefile
> > 1) Loop over features in the source shapefile (the one after reprojection
> to
> > WGS84)
> > 2a) If the polygon has points with longitudes both near 180° and near
> -180°,
> > create a duplicate temporary polygon and add 360° to the negative
> longitudes.
> > Compute the interescection with Geometry.Intersect (you need GEOS support)
> of
> > that polygon with POLYGON((0 90,180 90,180 -90,0 -90,0 90)) and with
> > POLYGON((180 90,360 90,360 -90,180 -90,180 90)). For the second
> intersection,
> > substract 360° to the longitudes in order to get again longitudes in the
> > [-180,180] range. Finally, write 2 new features into the output shapefile,
> or
> > better, just one with the geometry being a multipolygon with the 2 parts.
> > 2b) Otherwise, just copy the original feature into the output shapefile
> >
> > Best regards,
> > Even
> >
> >
> >> Eric,
> >>
> >> I can't help much apart from confirming that the same happened to me
> >> when trying to reproject Russia from LAEA to WGS84.
> >>
> >> My "solution" was to ask a colleague, who is using ESRI products to do
> >> me a favour... :-(
> >>
> >> Hermann
> >>
> >>
> >> Eric Muller wrote:
> >>
> >>> I am trying to reproject  shapefiles that represent Russia (from
> >>>
> http://wagda.lib.washington.edu/DATA/geography/world/russia/download.html)
> >>> from the original:
> >>>
> >>>     The map is Albers equal-area projection Clarke spheroid of1866 with
> >>>     the first standard parallel 46 00 0.000, the second standard
> >>>     parallel 73 00 0.000, the central meridian 84 00 0.000. The latitude
> >>>     of the projection's origin is 60 00 0.000.  Units -- meters.
> >>>
> >>> to lat/long WGS84. I use the following command:
> >>>
> >>> ogr2ogr \
> >>>     -s_srs '+proj=aea +ellps=clrk66 +lat_1=46.0 +lat_2=73.0 +lat_0=60.0
> >>> +lon_0=84.0 +units=m +no_defs' \
> >>>     -t_srs '+proj=latlong +ellps=WGS84 +datum=WGS84 +no_defs' \
> >>>     rs_polbnda_${f}.shp rus${f}.shp
> >>>
> >>> I would like polygons that cross the 180 degree longitude to be split.
> >>> It there a way to ask ogr2ogr to do that? What is the recommended way to
> >>> do it, if not?
> >>>
> >>> Thanks,
> >>> Eric.
> >>>
> >>>
> >>> ------------------------------------------------------------------------
> >>>
> >>> _______________________________________________
> >>> gdal-dev mailing list
> >>> gdal-dev at lists.osgeo.org
> >>> http://lists.osgeo.org/mailman/listinfo/gdal-dev
> >>>
> >> _______________________________________________
> >> gdal-dev mailing list
> >> gdal-dev at lists.osgeo.org
> >> http://lists.osgeo.org/mailman/listinfo/gdal-dev
> >>
> >>
> >
> >
>




More information about the gdal-dev mailing list