Giter VIP home page Giter VIP logo

vtpk2mbtiles's Introduction

Convert ESRI's Vector Tile Package (VTPK) to mbtiles

Resulting mbtiles can be used with mapbox-gl-js (Web), mapbox-gl-native (iOS/Android) or offline with QGIS via Vector-Tiles-Reader Plugin.

Disclaimer 1

I don't have access to any ESRI software or data. This is tested with the Austrian basemap.at Verwaltungsgrundkarte Vektor Offline (Beta) Österreich (EPSG:3857) only.

A few parameters are hard coded towards basemap.atas well, as some metadata values in the vtpkg are not correct.

Download vtpk here: https://www.data.gv.at/katalog/dataset/b694010f-992a-4d8e-b4ab-b20d0f037ff0

Disclaimer 2

No magic sauce or reverse engineering in the code, the internals of ESRI cache format are documented here: https://github.com/Esri/raster-tiles-compactcache

Another piece of software that does the same thing: https://github.com/syncpoint/openvtpk

Disclaimer 3

This is a one off proof of concept written months ago, putting it online now for educational purposes, unblocking offline and open source tool use. And free 🍻, maybe. Implementation is quick and dirty. No plans for further development. Feel free to clone, fork, ...

Note

For convenience a docker image is provided. For fast conversion Linux is recommended.

On my laptop:

  • native on Windows
    • extracting tiles to local file system (xy-scheme): ~30 seconds
    • converting to mbtiles: ~50 seconds
  • docker on Windows (Linux container)
    • extracting: ~3 minutes
    • converting: ~20 minutes(!)
  • docker on Linux (Linux container)
    • extracting: ~4 seconds(!)
    • converting: ~30 seconds

Usage

vtpk2mbtiles </path/to/extracted/vtpkg/folder> <output> <decompress tiles>
  • </path/to/extracted/vtpkg/folder>: folder where the vtpkg has been extracted to
  • <output>:
    • if it ends with .mbtiles destination format will be a mbtiles file
    • otherwise it is assumed to be a folder: single tiles will be placed there. With "current" vtpk version (Basemap_20190617): +162,000 tiles
  • <decompress tiles>: if true tiles will be decompressed, if false (default) not.

Abort processing with Ctrl+C.

Linux

  • convert to mbtiles, not decompressing tiles:
docker run -it --rm --name vtpk2mbtiles \
 --mount src="${HOME}/basemap",dst=/data,type=bind bergwerkgis/vtpk2mbtiles \
 /data/bmapv_vtpk_3857 \
 /data/bmapv.mbtiles \
 false
  • extract tiles to file system, unzip tiles:
docker run -it --rm --name vtpk2mbtiles \
 --mount src="${HOME}/basemap",dst=/data,type=bind bergwerkgis/vtpk2mbtiles \
 /data/bmapv_vtpk_3857 \
 /data/bmapv-tiles \
 true

Windows

  • Temporarily switch off Real-time protection (Virus & threat protection -> Virus & threat protection settings -> Manage settings -> Real-time protection -> Off). This will increase conversion speed considerably, especially when exporting to seperate tile files.

  • Docker

    • Right click Docker icon in the taskbar: Switch to Linux Containers
    • Docker -> Settings -> Resources -> Filesharing: check the drive where the downloaded vtpk resides
    • Docker -> Settings -> Resources -> Advanced:
      • bump CPUs to the max
      • at least 3 GB Memory, as much as you can afford (expecially for mbtiles conversion)
    • Apply & Restart
  • convert to mbtiles, not decompressing tiles:

docker run -it --rm ^
 --name vtpk2mbtiles ^
 -m 4g ^
 --cpus=%NUMBER_OF_PROCESSORS% ^
 --mount src="C:\basemap",dst=/data,type=bind bergwerkgis/vtpk2mbtiles ^
 /data/bmapv_vtpk_3857 ^
 /data/bmapv.mbtiles ^
 false
  • extract to file system, unzip tiles:
docker run -it --rm ^
 --name vtpk2mbtiles ^
 -m 4g ^
 --cpus=%NUMBER_OF_PROCESSORS% ^
 --mount src="C:\basemap",dst=/data,type=bind bergwerkgis/vtpk2mbtiles ^
 /data/bmapv_vtpk_3857 ^
 /data/bmapv-tiles ^
 false

Converted mbtiles in mbview:

mbview

mbview

vtpk2mbtiles's People

Contributors

wilhelmberg avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar

vtpk2mbtiles's Issues

hard coded layer names

This project is truly limited to the basemap.at vector tiles since you embed all(?) layer names into OutputMbtiles.cs.

To make vtpk2mbtiles beneficial for others you need to read the layer names from the tiles.

error in basemap vector files

Hello, i did not know how where to write you about an issue i found with the basemap vector project (https://basemap.at/standard-5)

I reported an issue at the fileserver-gl project: maptiler/tileserver-gl#1034 (comment)
The problem here is that vector data is not avaliable at some zoom levels:

i tried it with the offline vtpk file and the online source.
The error also appeares here: https://trafficon.github.io/basemap-at-maplibre/

image

I know there is some mail to send this issue to: [email protected] but i dont expect a fast answer there.anyways i also sent a mail with this problem to this mail. since i know you made this i thought ill report this in some of your project.

best regards
andy

Possibility to add styles to mbtiles cache

Hello i followed your converting script.

Now I have the same result as you. The raw vektor data. Is it somehow possible to apply the provided styles that the map looks like here:

image

Thanks in advance.
Best regards
Andy

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.