OpenStreetMap logo OpenStreetMap

Saving shapes from vector tiles to a shapefile

Posted by Answerquest on 14 October 2023 in English. Last updated on 15 October 2023.
  1. From XYZ tiles in browser, drag Openstreetmap to Layers
    https://server.nikhilvj.co.in/dump/img/vector-tiles-guide/vt-0-osm.webp

  2. In left “Browser” pane, Vector Tiles > New Generic Connection
    https://server.nikhilvj.co.in/dump/img/vector-tiles-guide/vt-1-addvector.webp

  3. Put in a layer name, the URL https://indianopenmaps.fly.dev/google-buildings/{z}/{x}/{y}.pbf, and a min and max zoom like 7 and 14.
    https://server.nikhilvj.co.in/dump/img/vector-tiles-guide/vt-2-vectorurl.webp
    - Don’t worry, QGIS will still show the data when you zoom deeper than 14.
    - This is just for telling qgis till what level vector data is available.
    - Check with the tile layer publisher what their max zoom is.
    - It’s usually useless to have smaller min-zoom value, as the tile server will anyways give redacted data at those levels.
    - If you want to extract the whole data for your region, you better be seeing the map at at least the specified max zoom so that you don’t miss out any shapes.

  4. Use “Select features by area” or a variant of that to select the features you want.
    https://server.nikhilvj.co.in/dump/img/vector-tiles-guide/vt-3-select.webp
    - You can use Shift / Ctrl to move around the map and add more shapes to the selection.
    - Note: stay on a higher/deeper zoom (ie, you should not zoom out too much) so that the shapes aren’t redacted in your view.
    - If you zoom out, what vector tile tech does is: it drops some shapes or does simplification / aggregation so that it doesn’t need to load up all the data over the larger area.

  5. Menu > Edit > Copy Features
    https://server.nikhilvj.co.in/dump/img/vector-tiles-guide/vt-4-copy.webp

  6. Menu > Edit > Paste Features As > New Vector Layer
    https://server.nikhilvj.co.in/dump/img/vector-tiles-guide/vt-5-paste.webp

  7. In the box that opens, select geojson or your preferred format, choose a folder / filename
    https://server.nikhilvj.co.in/dump/img/vector-tiles-guide/vt-6-file-crs.webp
    - Remeber to change the CRS to WGS 84 / EPSG 4326 : That’ll give you lat/lon values. The 3857 one will give huge numbers in your shapefile.

  8. You can now drag-drop your newly created .geojson file onto https://geojson.io to independently verify that you’ve got the correct data. It’ll also be carrying any metadata / attributes that the original vector tile layer was having.
    https://server.nikhilvj.co.in/dump/img/vector-tiles-guide/vt-7-preview.webp

Location: Shaniwar Peth, Pune, Pune District, Maharashtra, 411002, India
Email icon Bluesky Icon Facebook Icon LinkedIn Icon Mastodon Icon Telegram Icon X Icon

Discussion

Comment from PlaneMad on 14 October 2023 at 11:05

Very useful, wasn’t aware one could copy out features from tiles in QGIS.

One thing to note is that the detail of the features in the tiles can vary by zoom level, so the copying needs to be done at the max zoom level for that tile set to ensure features are not simplified. Not sure if there’s an obvious way to know that in QGIS.

Log in to leave a comment