[gdal-dev] Check validity of geometries before writing them into vector tiles?

Even Rouault even.rouault at spatialys.com
Wed Feb 14 07:34:19 PST 2018


On mercredi 14 février 2018 15:10:57 CET Rahkonen Jukka (MML) wrote:
> Hi,
> 
> I admit that my test was somewhat lunatic but I took some random dataset
> from Finland with 68101 polygons and converted data into MVT with default
> settings which means that minzoom was 0.  As a result 12196 of the source
> polygons were written into the 0-level protobuf tile (in EPSG:3067 gridset)
> and none of the polygons is valid. Most polygons have too few points and
> those which have enough points have self-intersections.
> 
> Perhaps there should be some sort of geometry validator in the writer chain?

There is some geometry validation, but it is not white&black. In my tests, with the 
ne_10m_admin_1_states_provinces dataset, when I initially implemented very strict 
geometry validation, a number of polygons were completely dropped, so I ended up 
implementing a more relaxed logic: for an outer ring, it after conversion to integer 
coordinates, it is not valid (with GEOSIsValid() testing), then do : buffer( tolerance) followed 
by bufffer(-tolerance) followed by simplifypreservetopology(tolerance) (where tolerance is 2 
* tile_dim_in_crs_unit / EXTENT) followed by a new round of integer coordinates conversion. 
If that's still not valid, keep it.
For an inner ring, drop it if when included in the outer ring, the resulting polygon is not valid

Perhaps you could play with the SIMPLIFICATION and SIMPLIFICATION_MAX_ZOOM options ?

Perhaps you should also use an already simplified layer for the lowest zoom level (see the 
CONF option)

Are you sure you get polygons with less than 4 points ? Normally they should be discarded.

Even

-- 
Spatialys - Geospatial professional services
http://www.spatialys.com
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osgeo.org/pipermail/gdal-dev/attachments/20180214/f7d5b601/attachment.html>


More information about the gdal-dev mailing list