10: 2016-05-19 (木) 04:55:48 yuji Attached file: shape2osm.py |
11: 2016-05-23 (月) 01:16:36 yuji Attached file: hokkaido_s.osm, Attached file: tohoku_s.osm, Attached file: kanto_s.osm, Attached file: chubu_s.osm, Attached file: kinki_s.osm, Attached file: chugoku_s.osm, Attached file: shikoku_s.osm, Attached file: kyushu_s.osm |
||
---|---|---|---|
Line 136: | Line 136: | ||
*** 海を青くする [#ze3004e1] | *** 海を青くする [#ze3004e1] | ||
- | OpenStreetMapの地図データは,海岸線タグ(coastlines)がサポートされなくなってます。Mapsforgeのライブラリではこの海岸線タグで海を青く表示できるようになってます。 | + | OpenStreetMapの地図データは,陸地と海岸の境界のタグ(coastlines)がサポートされなくなってます。Mapsforgeのライブラリではこの陸地と海岸の境界のタグで海を青く表示できるようになってます。 |
- | 海岸線がサポートされなくなっちゃったんで,なんとかして海岸線を特定し,海側はkey='natural' value='sea'タグを,陸側はkey='natural' value='nosea'タグを追加する必要があります。 | + | 陸地と海岸の境界のタグがサポートされなくなっちゃったんで,海を青く表示するには,なんとかして陸地と海岸の境界を特定し,海側はkey='natural' value='sea'タグを,陸側はkey='natural' value='nosea'タグを追加する必要があります。 |
このためには,日本の陸地や海の領域を特定する地形データが必要です。~ | このためには,日本の陸地や海の領域を特定する地形データが必要です。~ | ||
まず,[[OpenStreetMapData>http://data.openstreetmapdata.com]]というサイトから,世界の陸地線のデータである,[[land-polygons-split-4326.zip>http://data.openstreetmapdata.com/land-polygons-split-4326.zip]]ファイルをダウンロードします。~ | まず,[[OpenStreetMapData>http://data.openstreetmapdata.com]]というサイトから,世界の陸地線のデータである,[[land-polygons-split-4326.zip>http://data.openstreetmapdata.com/land-polygons-split-4326.zip]]ファイルをダウンロードします。~ | ||
> wget http://data.openstreetmapdata.com/land-polygons-split-4326.zip | > wget http://data.openstreetmapdata.com/land-polygons-split-4326.zip | ||
- | zipファイルを解凍すると,land_polygons.shpというShapeフォーマットのデータがあります。これを[[ogr2ogr>http://www.gdal.org/ogr2ogr.html]](Windowsの場合QGISがインストールされていればogr2ogrも使える)というツールを使用して日本の陸地線のShapeデータを取り出します。 | + | zipファイルを解凍すると,land_polygons.shpというShapeフォーマット(外形)のデータがあります。これを[[ogr2ogr>http://www.gdal.org/ogr2ogr.html]](Windowsの場合QGISがインストールされていればogr2ogrも使える)というツールを使用して日本の陸地線のShapeデータを取り出します。 |
> ogr2ogr -overwrite -progress -skipfailures -clipsrc 122.560700 21.209920 153.890100 45.802450 japan.shp land-polygons-split-4326/land_polygons.shp | > ogr2ogr -overwrite -progress -skipfailures -clipsrc 122.560700 21.209920 153.890100 45.802450 japan.shp land-polygons-split-4326/land_polygons.shp | ||
その後,&ref(shape2osm.py);を使用して,日本の陸地線データを,japan_ns.osmファイルに変換する。 | その後,&ref(shape2osm.py);を使用して,日本の陸地線データを,japan_ns.osmファイルに変換する。 | ||
> python shape2osm.py -l japan_ns -o 10000000 japan.shp | > python shape2osm.py -l japan_ns -o 10000000 japan.shp | ||
- | これで,japan_ns.osmが作成される。この時,key='natural' value='nosea'が追加される。~ | + | これで,日本の陸地の外形地図データのjapan_ns.osmが作成される。この時shape2osm.pyにより,key='natural' value='nosea'が追加されている。~ |
- | 日本全体の陸地線データから,北海道,東北,関東,中部,近畿,中国,四国,九州の陸地線データを)を作成しておく。(osmconvertでカットする) | + | 日本全体の外形データから,北海道,東北,関東,中部,近畿,中国,四国,九州の外形データを作成する。これはosmconvertを使用して各場所をカットすることにした。 |
> osmconvert japan_ns.osm -B=..\poly\Hokkaido.poly -o=hokkaido_ns.osm | > osmconvert japan_ns.osm -B=..\poly\Hokkaido.poly -o=hokkaido_ns.osm | ||
> osmconvert japan_ns.osm -B=..\poly\Tohoku.poly -o=tohoku_ns.osm | > osmconvert japan_ns.osm -B=..\poly\Tohoku.poly -o=tohoku_ns.osm | ||
Line 159: | Line 159: | ||
> osmconvert japan_ns.osm -B=..\poly\Kyushu.poly -o=kyushu_ns.osm | > osmconvert japan_ns.osm -B=..\poly\Kyushu.poly -o=kyushu_ns.osm | ||
- | 海を特定して,key='natural' value='sea'タグを付けるため,以下の内容でjapan_sea.osmをテキストエディタを使って作成する。めんどくさいんで,日本全体を海にしている。 | + | 海を特定した上でkey='natural' value='sea'タグを付けるため,テキストエディタを使って %%japan_s.osmを作成する。めんどくさいんで,日本全体を海にしている。%% &ref(hokkaido_s.osm); &ref(tohoku_s.osm); &ref(kanto_s.osm); &ref(chubu_s.osm); &ref(kinki_s.osm); &ref(chugoku_s.osm); &ref(shikoku_s.osm); &ref(kyushu_s.osm); をそれぞれ作成した。 |
- | <?xml version="1.0" encoding="UTF-8"?> | + | |
- | <osm version="0.6"> | + | |
- | <bounds minlat="32.3844554" minlon="131.8803602" maxlat="34.6285997" maxlon="134.9868537"/> | + | |
- | <node timestamp="2016-04-29T23:59:59Z" changeset="20000" id="32951459320" version="1" lon="122.560700" lat="21.209920" /> | + | |
- | <node timestamp="2016-04-29T23:59:59Z" changeset="20000" id="32951459321" version="1" lon="122.560700" lat="45.802450" /> | + | |
- | <node timestamp="2016-04-29T23:59:59Z" changeset="20000" id="32951459322" version="1" lon="153.890100" lat="45.802450" /> | + | |
- | <node timestamp="2016-04-29T23:59:59Z" changeset="20000" id="32951459323" version="1" lon="153.890100" lat="21.209920" /> | + | |
- | <way timestamp="2016-04-29T23:59:59Z" changeset="20000" id="32951623372" version="1"> | + | |
- | <nd ref="32951459320" /> | + | |
- | <nd ref="32951459321" /> | + | |
- | <nd ref="32951459322" /> | + | |
- | <nd ref="32951459323" /> | + | |
- | <nd ref="32951459320" /> | + | |
- | <tag k="area" v="yes" /> | + | |
- | <tag k="layer" v="0" /> | + | |
- | <tag k="natural" v="sea" /> | + | |
- | </way> | + | |
- | </osm> | + | |
- | 海(japan_s.osm)と海でない陸地部分(xxxx_ns.osm)をマージして,xxxx_sea.osmを作成する。 | + | 海(xxxx_s.osm)と陸地部分(xxxx_ns.osm)をマージして,xxxx_sea.osmを作成しておく。 |
- | > osmosis --read-xml file="japan_s.osm" --read-xml file="hokkaido_ns.osm" --sort --merge --write-xml file="hokkaido_sea.osm" | + | > osmosis --read-xml file="hokkaido_s.osm" --read-xml file="hokkaido_ns.osm" --sort --merge --write-xml file="hokkaido_sea.osm" |
- | > osmosis --read-xml file="japan_s.osm" --read-xml file="tohoku_ns.osm" --sort --merge --write-xml file="tohoku_sea.osm" | + | > osmosis --read-xml file="tohoku_s.osm" --read-xml file="tohoku_ns.osm" --sort --merge --write-xml file="tohoku_sea.osm" |
- | > osmosis --read-xml file="japan_s.osm" --read-xml file="kanto_ns.osm" --sort --merge --write-xml file="kanto_sea.osm" | + | > osmosis --read-xml file="kanto_s.osm" --read-xml file="kanto_ns.osm" --sort --merge --write-xml file="kanto_sea.osm" |
- | > osmosis --read-xml file="japan_s.osm" --read-xml file="chubu_ns.osm" --sort --merge --write-xml file="chubu_sea.osm" | + | > osmosis --read-xml file="chubu_s.osm" --read-xml file="chubu_ns.osm" --sort --merge --write-xml file="chubu_sea.osm" |
- | > osmosis --read-xml file="japan_s.osm" --read-xml file="kinki_ns.osm" --sort --merge --write-xml file="kinki_sea.osm" | + | > osmosis --read-xml file="kinki_s.osm" --read-xml file="kinki_ns.osm" --sort --merge --write-xml file="kinki_sea.osm" |
- | > osmosis --read-xml file="japan_s.osm" --read-xml file="chugoku_ns.osm" --sort --merge --write-xml file="chugoku_sea.osm" | + | > osmosis --read-xml file="chugoku_s.osm" --read-xml file="chugoku_ns.osm" --sort --merge --write-xml file="chugoku_sea.osm" |
- | > osmosis --read-xml file="japan_s.osm" --read-xml file="shikoku_ns.osm" --sort --merge --write-xml file="shikoku_sea.osm" | + | > osmosis --read-xml file="shikoku_s.osm" --read-xml file="shikoku_ns.osm" --sort --merge --write-xml file="shikoku_sea.osm" |
- | > osmosis --read-xml file="japan_s.osm" --read-xml file="kyushu_ns.osm" --sort --merge --write-xml file="kyushu_sea.osm" | + | > osmosis --read-xml file="kyushu_s.osm" --read-xml file="kyushu_ns.osm" --sort --merge --write-xml file="kyushu_sea.osm" |
- | やっと,陸地は<tag k="natural" v="nosea" />が,海の部分は<tag k="natural" v="sea" />がある地図データが作成できた。(海は日本全体だけど・・・) | + | やっと,陸地は<tag k="natural" v="nosea" />が,海の部分は<tag k="natural" v="sea" />がある地図データが作成できた。%%(海は日本全体だけど・・・)%% |
*** 日本の地図と等高線をマージして完成 [#g8a11fa9] | *** 日本の地図と等高線をマージして完成 [#g8a11fa9] |