osm.pbf 制作中国铁路网mbtiles
数据源
下载全量矢量数据
OpenStreetMap: https://planet.openstreetmap.org/pbf/planet-latest.osm.pbf
各个大洲拆分矢量数据
Geofabrik: https://download.geofabrik.de
osm.pbf 抽取指定图层
osmium-tool
github: https://github.com/osmcode/osmium-tool
按照文档说明安装必要的库,注意版本
安装osmium
sudo apt-get update
sudo apt install osmctools
sudo apt install osmium-tool
获取中国范围内geojson
{
"type": "FeatureCollection",
"features": [
{
"type": "Feature",
"properties": {},
"geometry": {
"type": "Polygon",
"coordinates": [
[
[
79.40917968749999,
42.09822241118974
],
[
73.5205078125,
40.27952566881291
],
[
73.0810546875,
39.33429742980725
],
[
74.267578125,
36.914764288955936
],
[
78.7060546875,
33.02708758002874
],
[
78.0029296875,
32.47269502206151
],
[
78.31054687499999,
31.42866311735861
],
[
79.40917968749999,
30.44867367928756
],
[
81.8701171875,
29.611670115197377
],
[
83.056640625,
29.22889003019423
],
[
84.1552734375,
28.57487404744697
],
[
88.857421875,
26.745610382199022
],
[
90,
27.72243591897343
],
[
91.4501953125,
27.254629577800063
],
[
91.97753906249999,
26.391869671769022
],
[
94.833984375,
27.01998400798257
],
[
95.5810546875,
27.839076094777816
],
[
97.822265625,
27.410785702577023
],
[
98.3056640625,
26.62781822639305
],
[
97.9541015625,
25.918526162075153
],
[
96.9873046875,
24.806681353851964
],
[
96.94335937499999,
23.68477416688374
],
[
97.734375,
23.36242859340884
],
[
100.01953125,
21.207458730482642
],
[
100.95886230468749,
21.44795595975583
],
[
101.392822265625,
20.99734274071184
],
[
102.0355224609375,
21.15623836610943
],
[
101.84326171875,
22.22300538374278
],
[
104.17785644531249,
22.421184710331858
],
[
106.171875,
22.63429269379353
],
[
106.8310546875,
21.43261686447735
],
[
106.787109375,
18.458768120015126
],
[
109.2041015625,
15.961329081596647
],
[
109.8193359375,
11.673755403433413
],
[
107.73193359375,
6.35897532723566
],
[
109.53369140625,
3.7327083213358465
],
[
112.0166015625,
3.030812122664383
],
[
113.62060546875,
4.3464112753331925
],
[
115.99365234375,
7.035475652433024
],
[
118.14697265625,
10.444597722834875
],
[
118.85009765625,
10.703791711680736
],
[
119.24560546875001,
11.43695521614319
],
[
119.37744140625,
15.559544421458103
],
[
120.0146484375,
18.521283325496277
],
[
121.46484375,
20.797201434307
],
[
123.04687499999999,
23.140359987886118
],
[
123.22265625000001,
24.56710835257599
],
[
123.72802734375,
25.284437746983055
],
[
125.22216796875,
25.780107118422244
],
[
124.23339843749999,
39.58875727696545
],
[
125.2880859375,
40.51379915504413
],
[
127.13378906249999,
41.31082388091818
],
[
128.32031249999997,
41.244772343082076
],
[
130.10009765625,
42.48830197960227
],
[
130.8251953125,
42.24478535602799
],
[
132.220458984375,
45.120052841530544
],
[
133.34106445312497,
44.88701247981298
],
[
134.615478515625,
47.16730970131578
],
[
135.35156249999997,
48.42191010942875
],
[
134.989013671875,
48.64016871811908
],
[
134.505615234375,
48.60385760823255
],
[
131.231689453125,
47.97521412341618
],
[
130.484619140625,
49.46098385110948
],
[
125.52978515625001,
53.35710874569601
],
[
122.32177734375,
53.76819584019795
],
[
119.47631835937499,
53.034607110319044
],
[
116.1474609375,
49.66051672522669
],
[
115.12573242187499,
47.50978034953473
],
[
114.85107421875,
45.744526980468436
],
[
112.137451171875,
45.19752230305682
],
[
111.29150390625,
44.933696389694674
],
[
110.950927734375,
43.38109758727857
],
[
109.412841796875,
42.601619944327965
],
[
107.29248046875,
42.53689200787315
],
[
104.87548828125,
41.74672584176937
],
[
101.8212890625,
42.593532625649935
],
[
98.45947265625,
42.80346172417078
],
[
95.526123046875,
44.268804788566165
],
[
95.372314453125,
44.43377984606822
],
[
90.933837890625,
45.62172169252446
],
[
91.549072265625,
47.37603463349758
],
[
87.901611328125,
49.25346477497736
],
[
86.85791015625,
49.26063518364422
],
[
85.5615234375,
48.480204398955145
],
[
85.286865234375,
48.04870994288686
],
[
85.10009765625,
47.100044694025215
],
[
83.21044921875,
47.27922900257082
],
[
82.77099609375,
47.27922900257082
],
[
81.859130859375,
45.48324350868221
],
[
79.62890625,
45.09679146394738
],
[
80.35400390625,
43.92163712834673
],
[
79.969482421875,
42.58544425738491
],
[
79.40917968749999,
42.09822241118974
]
]
]
}
}
]
}
编译osmium-tool,抽取中国范围内矢量数据,执行以下命令
osmium extract -p polygon.geojson france.pbf -o china-rang.pbf
抽取中国范围的铁路线和火车站,执行以下命令
osmium tags-filter china-rang.osm.pbf wr/railway railway=station -o china.osm.pbf
tilemaker制作mbtiles
github: https://github.com/systemed/tilemaker
指定JSON配置和Lua脚本
config-openmaptiles.json、process-openmaptiles.lua两个文件可以访问以下路径获得:
https://github.com/systemed/tilemaker/blob/master/resources
中国所在的矩形大致位置
--bbox 57.216796875,1.31824,138.2519,56.41390
编译可执行程序,制作mbtiles执行以下命令
tilemaker --output china.mbtiles --input china.osm.pbf --config config-openmaptiles.json --process process-openmaptiles.lua --bbox 57.216796875,1.31824,138.2519,56.41390