postgislarge-datavector-tilesmvt

Mapbox Vector Tiles (MVT) Not visible for point layer at lower zoom levels


I am using this POSTGIS query to generate MVT tiles and visualize large point layer data. When zooming in these tiles starts appearing visually but leads to drastic changes in number of tiles visible at next zoom level. This lead to reports of data inaccuracy. Tiles at lower zoom level are not returning any data even though there are millions of data in that bounding box. 1st image is when i try to see my map one zoom level up 2nd image is when i move my zoom level to one zoom level down

My query looks like this

      ST_AsMVT(tile, 'table', 4096, 'geom')
    FROM (
      SELECT
        ST_AsMVTGeom(
            ST_Transform(ST_CurveToLine("geometry"), 3857),
            ST_TileEnvelope($1::integer, $2::integer, $3::integer),
            4096, 64, true
        ) AS geom
        , "ogc_fid"
      FROM
        table
      WHERE
        "geometry" && ST_Transform(ST_TileEnvelope($1::integer, $2::integer, $3::integer, margin => 0.015625), 4326)
    ) AS tile

Image of map tiles one zoom level up

Image of map tiles one zoom level down(lower zoom level)


Solution

  • Increasing the tile_extent to 4096000 and reducing buffer size to 0 helped me getting desired output. Along with it i also removed the margin from tile envelope. So the updated code looks like

        FROM (
          SELECT
            ST_AsMVTGeom(
                ST_Transform(ST_CurveToLine("geometry"), 3857),
                ST_TileEnvelope($1::integer, $2::integer, $3::integer),
                4096000, 0,false
            ) AS geom
            , "ogc_fid"
          FROM
            table
          WHERE
            "geometry" && ST_Transform(ST_TileEnvelope($1::integer, $2::integer, $3::integer), 4326)
        ) AS tile