0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

shpファイルからPMTilesを作成する

0
Posted at

はじめに

以前にこちらの記事では、shpファイルから圧縮されていないベクトルタイルと、MBTilesを作成しました。今回の記事ではPMTilesを作成します。

作業レポジトリ

ソースデータ

参考記事と同様にNatural Earth のデータを使用します。ダウンロードページから、「1:110m Physical Vectors」の「Coastline」、「Land」、「Rivers,Lake Centerlines」をダウンロードします。

ベクトルタイルの構成

ベクトルタイル構成も参考記事と同じにします。後にスタイル付けをする際に必要になってくるので、この時点で整理しておきます。

レイヤ名 ソース Min Zoom Max Zoom
coastl ne_110m_coastline.shp 0 4
landmass ne_110m_land.shp 0 4
riverl ne_110m_rivers_lake_centerlines.shp 0 4

shpからGeojsonへの変換

GDALを使用して変換します。作業レポジトリのホームから、以下のコードを実行します。GeoJSONというフォルダは事前に作成しておきます。

ogr2ogr -f GeoJSON ./GeoJSON/coastl.geojson ./SHP/ne_110m_coastline/ne_110m_coastline.shp
ogr2ogr -f GeoJSON ./GeoJSON/landmass.geojson ./SHP/ne_110m_land/ne_110m_land.shp
ogr2ogr -f GeoJSON ./GeoJSON/riverl.geojson ./SHP/ne_110m_rivers_lake_centerlines/ne_110m_rivers_lake_centerlines.shp 

GeojsonからPMTilesへの変換

作業レポジトリのホームから、tippecanoeを使用して以下のコードを実行します。

tippecanoe -o VTpractice.pmtiles --no-feature-limit --no-tile-size-limit --drop-rate=1 -Z0 -z4 -L coastl:./GeoJSON/coastl.geojson -L landmass:./GeoJSON/landmass.geojson -L riverl:./GeoJSON/riverl.geojson

ちなみに、オプションの「-o」はMBTilesを作る時も、PMTilesを作る時も共通です。

ちなみに、ファイルサイズは以下のとおりです。
VTpractice.mbtiles: 287KB
VTpractice.pmtiles: 188KB

MBTilesは中身がSQLiteデータベースであり、タイル本体以外にSQLite のページ構造や、インデックスがあるので、重くなるようです。実データが小さいと、SQLite の管理領域の重さが目立ちそうです。もっと大きいデータでどうなるかは、また調査します。

PMTilesの地図表示

PMTiles viewerで簡単に地図表示することが出来ます。MBTilesだと自身でホストしないといけないので、少し面倒でしたが、PMTilesだと簡単でいいですね。
以下のとおり、正常に表示されました。

Screenshot 2026-04-11 at 9.31.24 AM.jpg

まとめ

shpファイルからPMTilesを作成する方法を簡単にまとめました。

Reference

0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?