Complete Cadastral Map of France Using PMtiles
We converted a 33 GB MBTiles file covering all of France to a single PMTiles file using Docker and loaded to S3. We provide several simple tips.
The French government maintains a single database of all parcel boundaries in France, most of them also including building footprints. The data is updated and made available several times per year, currently at https://cadastre.data.gouv.fr/datasets/cadastre-etalab. This webpage also publishes a single mbtiles file for the entire dataset. Displaying this data on a web map is a perfect occasion to work with pmtiles.
Pmtiles allow one to hold a collection of tiles in one file, rather than as a large pyramid of tiny files, and allow a web map to easily call tiles when the pmtiles are hosted on a service such as AWS S3.
We gave this job a try and it worked wonderfully.
We'll share a couple details of the implementation. First, the original mbtiles file is 33GB, so storage on a laptop would be tricky. We worked on AWS and created a t2xlarge instance in Paris. wget was already installed and the 33GB file was downloaded in under ten minutes.
We installed Docker and then pulled image listed at https://github.com/protomaps/go-pmtiles/pkgs/container/go-pmtiles. The only tricky part we found was attaching the volumes correctly. The command that worked was
sudo docker run -i -t -v /home/ec2-user/:/workspace/data/ -v /home/ec2-user/temp/:/tmp/ ghcr.io/protomaps/go-pmtiles:main convert /workspace/data/cadastre.mbtiles /tmp/cadastre.pmtiles
The working directory in the container is workspace
, and so I mapped the instance directory containing cadastre.mbtiles to workspace/data
. I found that the output was written to a tmp directory and that on an early attempt this directory ran out of space. I increased the volume to 200 GB and then mapped a subdirectory temp
to the container's tmp
directory, and now the output wrote to the intended temp
directory. The process took less than an hour and the 33 GB mbtiles was converted to a 27 GB pmtiles file.
Once the file was finished I copied it to S3 using the aws s3 cp function rather than the pmtiles copy function. The S3 bucket allows public access, and so I could copy the address to the PMTiles Viewer to check the tiles. The tiles appeared perfectly.
And so, with very little work, we can now create a web map showing parcels and building footprints throughout France and do not have the job of keeping track of an enormous number of small mvt files.
The example map below shows parcel boundaries and building footprints. The map defaults to showing Saint-Malo, but one can zoom to anywhere in France.