I'm trying to create mvt using postgis by following this tutorial

If understand correctly ST_AsMVT is used to create a layer and generated layer will have id. same id can be used to apply styles.

SELECT ST_AsMVT(q, 'buildings', 4096, 'geom')
  SELECT id, name, type,
      BBox(16597, 11273, 15),
    ) AS geom
  FROM import.osm_buildings
  WHERE geometry && BBox(16597, 11273, 15)
  AND ST_Intersects(geometry, BBox(16597, 11273, 15))
) AS q;

Will create a layer named admin with id admin. styling can be applied by using this id - from index.html

  "id": "building",
  "source": "osm",
  "source-layer": "buildings",
  "type": "fill",
  "paint": {
    "fill-color": "#D8CEC3",
    "fill-outline-color": "#C5C0BB",
    "fill-opacity": 1

How can we create a single layer with multiple id's so we can style them separately.

I'm complete in newbie to PostGIS and Tiles stuff any other approaches and suggestions are welcome

  • I believe you can just use UNION SELECT to select from the separate tables, so that you end up with one MVT file, with different id and source-layer, so that the styling will work differently for each one. – John Powell Mar 6 at 19:12
  • Hi, Thanks for reply. I am not sure it will generate specific ID [i'm just assuming that]. if you look at openmaptiles [github.com/openmaptiles/openmaptiles/tree/master/layers]. They did not specify any id in the code [or may be i'm missing some thing]. – anilkunchalaece Mar 11 at 5:38

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.