1

Is there a way to disable the geometry simplification when using the ST_AsMVTGeom() function in PostGIS? I'm generating tiles for zoom level 9 and overzoom them.

This is how it looks like when the z9 tile is overzoomed:

overzoomed z9 tile

This is how I would like the overzoomed tile to look like (tile rendered for z19, not overzoomed):

tile rendered for z19

Here is the SQL snippet I'm using to generate the tiles

ST_AsMVTGeom (
     ST_Transform(c.geometry, 3857) -- transform geometry to 3857: SRID Web Mercator
    ,ST_TileEnvelope($1, $2, $3)    -- tile bounds
    ,4096   -- tile extent size in tile coordinate space
    ,0      -- buffer size in tile coordinate space for geometry clippig
    ,false  -- false means do not clip the geometry, encoded as-is
) as geom

I'm using Postgis v3.3 USE_GEOS=1 USE_PROJ=1 USE_STATS=1 and PostgreSQL 14.6, compiled by Visual C++ build 1914, 64-bit.

10
  • 2
    The tile space is only 4096 by 4096 integer numbers. That leads into simplification that gets more obvious with overzoom.
    – user30184
    Jan 12, 2023 at 11:32
  • 1
    @ziggy it's a webapp using maplibre-gl-js (fork of mapbox-gl-js) library/API. Overzooming is when you zoom into a tile without loading new tiles. See docs.mapbox.com/help/glossary/overzoom Jan 12, 2023 at 16:25
  • 1
    See how geometries are encoded in MVT vector tiles docs.mapbox.com/data/tilesets/guides/vector-tiles-standards/…. They use grid coordinates which are integers. Enlarging the tile space would make the step between the grid coordinates smaller. The effect is the same as zooming in to next level instead of overzooming.
    – user30184
    Jan 12, 2023 at 16:40
  • 1
    Correct, when the postgis.net/docs/ST_AsMVTGeom.html function is used. Users who create tiles with GDAL can continue the simplification in grid coordinates space with creation option "simplification" gdal.org/drivers/vector/mvt.html.
    – user30184
    Jan 12, 2023 at 19:48
  • 1
    @Iroh it's a nest-js server, nothing GIS specific. All it does is executing the SQL query and returning 1:1 what Postgis returns. Mar 18, 2023 at 12:31

1 Answer 1

0

I ended up increasing the tile extent size to 16777215. With that, the tile kilobytes size didn't grow much and still is acceptable.

ST_AsMVTGeom (
     ST_Transform(c.geometry, 3857) -- transform geometry to 3857: SRID Web Mercator
    ,ST_TileEnvelope($1, $2, $3)    -- tile bounds
    ,16777215   -- tile extent size in tile coordinate space
    ,0      -- buffer size in tile coordinate space for geometry clippig
    ,false  -- false means do not clip the geometry, encoded as-is
) as geom

Result now looks much better and is acceptable for me. Even though it still is not perfect.

enter image description here

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.