Bug report #19746

Disappearing -180 / 180 longitude grid lines on certain zoom levels

Added by Andreas Neumann over 5 years ago. Updated over 5 years ago.

Status:Open
Priority:Normal
Assignee:Even Rouault
Category:Projection Support
Affected QGIS version:3.3(master) Regression?:No
Operating System: Easy fix?:No
Pull Request or Patch supplied:No Resolution:
Crashes QGIS or corrupts data:No Copied to github as #:27571

Description

Depending on the zoom level, the -180 / 180 degree grid lines appear / disappear in QGIS.

This is not depending on a certain projection, but seems to be a spatial filter accuracy issues.

Quote from Even Rouault:
--------------------------
This seems to be an issue with the spatial filter issued to OGR

At the zooms where the lines disappear, there are requests like:

Thread 23 "Thread (pooled)" hit Breakpoint 2, OGR_L_SetSpatialFilterRect
(hLayer=0x7f81180c90a0, dfMinX=-179.79163612932865,
dfMinY=-69.446164378986353, dfMaxX=179.90530755284408,
dfMaxY=78.959077253477474) at ogrlayer.cpp:1223

At the zooms where that work (even when zoomed in), there are like:

Thread 29 "Thread (pooled)" hit Breakpoint 2, OGR_L_SetSpatialFilterRect
(hLayer=0x7f81180c90a0, dfMinX=-180, dfMinY=-90, dfMaxX=180, dfMaxY=90) at
ogrlayer.cpp:1223

I haven't looked at the QGIS code that computes this bounding box, but from my
experience with gdalwarp which has similar challenges, it is tricky to compute
a source bounding box from a target bounding box, because sometimes the
coordinates in the target bounding box do not correspond to a physical point
on Eath, and hence inverse projection fails. So you have to resort to a grid
sampling approach, but that makes you miss the exact boundaries. So probably
that a band-aid fix would be to add some ad-hoc logic, like "if the source SRS
is long/lat, and the computed extent is almost worldwide, then extend it to
full worlwide (or do not emit a spatial filter at all)"
--------------------------

Attached is a Geopackage file with grid lines for testing.

gridlines.gpkg (1.31 MB) Andreas Neumann, 2018-09-01 11:24 AM


Related issues

Related to QGIS Application - Bug report #13380: reprojection of lat/long lines across 180 in mercator map... Closed 2015-09-18
Related to QGIS Application - Bug report #19626: World map incorrectly drawn when using a different projec... Reopened 2018-08-15
Related to QGIS Application - Bug report #597: lat/lon maps should wrap around 180 longitude Closed

History

#1 Updated by Andreas Neumann over 5 years ago

  • Related to Bug report #13380: reprojection of lat/long lines across 180 in mercator map fails added

#2 Updated by Andreas Neumann over 5 years ago

  • Related to Bug report #19626: World map incorrectly drawn when using a different projection than the data source added

#3 Updated by Andreas Neumann over 5 years ago

  • Related to Bug report #597: lat/lon maps should wrap around 180 longitude added

#4 Updated by Johannes Kroeger over 5 years ago

Another easy test case:

  • Load ne_110m_coastline and ne_110m_graticules_20.
  • Set projection to EPSG:3995 or EPSG:3031 ((ant)arctic stereographic)
  • Zoom to ne_110m_coastline
  • Rotate the map canvas
  • The antimeridian as well as some high latitudes will disappear every now and then (eg at 20° rotation).

Also available in: Atom PDF