aboutsummaryrefslogtreecommitdiffstats
path: root/common_gdal.py
diff options
context:
space:
mode:
authorGuilhem Moulin <guilhem@fripost.org>2025-05-21 17:33:46 +0200
committerGuilhem Moulin <guilhem@fripost.org>2025-05-21 18:57:54 +0200
commitd1416171c63f58a764859fb3694ef5cc17dae52d (patch)
tree5edd9436c4a7b616a3287d180ef01c4d22fbb942 /common_gdal.py
parent9b192ebb312741672babd46523d8558b6e74ff9a (diff)
MVT: Don't clip features manually.
It's done automatically by the MVT driver. Also we don't want to clip at the extent boundaries, but instead leave som headroom so the clipped polygon border is not visible on the map. The MVT driver does that. It seems that GDAL 3.6.2 from Debian Bookworm generates too many tiles though. It yields the following tile counts for group ‘ren’: no manual clipping, BUFFER=32: 83718 tiles [min=33 B, max=117.70 kiB, sum=15.73 MiB, avg=197 B] no manual clipping, BUFFER=0: 83676 tiles clip at extent, BUFFER=32: 76256 tiles GDAL 3.10.3 from Debian Trixie yields less surprising tile counts: no manual clipping, BUFFER=32: 75972 tiles [min=33 B, max=128.16 kiB, sum=15.10 MiB, avg=208 B] no manual clipping, BUFFER=0: 75939 tiles clip at extent, BUFFER=32: 75972 tiles (Interesting to see that the largest tile — 0/0/0.pbf — is over 10kiB larger with the more recent GDAL version, also.)
Diffstat (limited to 'common_gdal.py')
-rw-r--r--common_gdal.py11
1 files changed, 2 insertions, 9 deletions
diff --git a/common_gdal.py b/common_gdal.py
index 35511a3..7333f58 100644
--- a/common_gdal.py
+++ b/common_gdal.py
@@ -128,20 +128,13 @@ def getExtent(extent : Optional[tuple[float, float, float, float]],
return polygon
-def getSpatialFilterFromGeometry(geom : ogr.Geometry,
- srs : osr.SpatialReference,
- fail_if_srs_not_equivalent : bool = False) -> ogr.Geometry:
+def getSpatialFilterFromGeometry(geom : ogr.Geometry, srs : osr.SpatialReference) -> ogr.Geometry:
"""Make the geometry suitable for use as a spatial filter. It is
- densified the SRS:s are not equivalent, unless fail_if_srs_not_equivalent is True in
- which case it errors out (this ensure clipping geometries remain simple)."""
+ densified the SRS:s are not equivalent."""
cloned = False
geom_srs = geom.GetSpatialReference()
if not geom_srs.IsSame(srs, [ 'IGNORE_DATA_AXIS_TO_SRS_AXIS_MAPPING=YES',
'CRITERION=EQUIVALENT']):
- if fail_if_srs_not_equivalent:
- raise RuntimeError(f'Geometry {geom.ExportToWkt()} has SRS ' +
- geom_srs.ExportToPrettyWkt() + ',\nexpected ' +
- srs.ExportToPrettyWkt())
# densify the geometry (a rectangle) to avoid issues when reprojecting,
# cf. apps/ogr2ogr_lib.cpp:ApplySpatialFilter()
segment_distance_metre = 10 * 1000