2

I am working on a Python script in QGIS 3 that creates buffers around points in Web Mercator (EPSG:3857) and transforms the buffers into WGS84 (EPSG:4326).

I have a problem with geometries that cross antimeridian (180 deg longitude) - after transformation the buffers (circles) show up as long rectangles that span from -180 to +180 longitude, with actual buffers (circles) being "excluded" from these geometries.

Fig. 1: Buffer in Web Mercator that crosses antimeridian

Buffer crossing antimeridian

Fig. 2: Buffer after transforming into WGS84

Buffer after transforming into WGS84

How best to transform geometries that span across antimeridian?

Is there a way to fix the output geometries?

Taras
  • 32,823
  • 4
  • 66
  • 137
jan_b
  • 792
  • 10
  • 16
  • 1
    If you want to use geometries that cross the antimeridian you need to use a projection that is not split by it, or split the geometry. – Ian Turton Oct 15 '20 at 18:52
  • Thanks @IanTurton for your suggestion. However, why it is possible to create and display a polygon (buffer) that crosses the antimeridian? I've tried both ways: from WGS84 to WebMercator and the other way round. I can create a buffer in both coordinate systems and they show correctly. The issue arises only when the geometry is transformed to another coordinate system. – jan_b Oct 15 '20 at 21:26
  • 1
    I worked on a project where I had to create custom Coordinate Systems for global earthquake points. I ran into a very similar problem. My question doesn't deal with the problem directly but it may help you https://gis.stackexchange.com/questions/263379/custom-transverse-mercator-projection-with-fiona-and-shapely – ziggy Oct 15 '20 at 22:31
  • 1
    Likely your “native” buffer in either coordinate system results in points outside the official bounds, eg longitudes > 180 or < 180. These display correctly on many maps. When you convert, the conversion probably normalizes the points to the official bounds, breaking the display. – nrabinowitz Oct 16 '20 at 02:44
  • @ziggy (and Ian Turton) - thanks, your suggestions to create a custom projection worked! For buffers that cross antimeridian I'm using a modified WGS84 with a primary meridien centered at 180 deg and then transforming back to the regular WGS84. The output geometry shows up correctly. Thanks for your feedback. – jan_b Oct 16 '20 at 08:02
  • 1
    @ziggy - feel free to add your comment as an answer so I can mark the question as answered and give you credits. – jan_b Oct 16 '20 at 08:04

0 Answers0