|
| 1 | +Plateau Utils |
| 2 | +============= |
| 3 | + |
| 4 | +This is a collection of utilities for the `Plateau <https://www.mlit.go.jp/plateau/>`_ project. |
| 5 | + |
| 6 | +.. code:: bash |
| 7 | +
|
| 8 | + pip install plateauutils |
| 9 | +
|
| 10 | +Tested with Python 3.9 and 3.10 |
| 11 | + |
| 12 | +CityGML parser |
| 13 | +-------------- |
| 14 | + |
| 15 | +.. code:: python |
| 16 | +
|
| 17 | + >>> from shapely.geometry import Point |
| 18 | + >>> from plateauutils.mesh_geocorder.geo_to_mesh import point_to_meshcode |
| 19 | + >>> point = Point(139.71475, 35.70078) |
| 20 | + >>> mesh_code = point_to_meshcode(point, "2/1") |
| 21 | + >>> mesh_code |
| 22 | + '533945471' |
| 23 | + >>> from shapely import from_wkt |
| 24 | + >>> from plateauutils.parser.city_gml_parser import CityGMLParser |
| 25 | + >>> target_polygon = from_wkt("POLYGON ((130.41249721501615 33.224722548534864, 130.41249721501615 33.22506264293093, 130.41621606802997 33.22506264293093, 130.41621606802997 33.224722548534864, 130.41249721501615 33.224722548534864))") |
| 26 | + >>> parser = CityGMLParser(target_polygon) |
| 27 | + >>> result = parser.download_and_parse("https://assets.cms.plateau.reearth.io/assets/d6/70821e-7f58-4f69-bc34-341875704e78/40203_kurume-shi_2020_citygml_3_op.zip", "/tmp") |
| 28 | + >>> result |
| 29 | + [{'gid': 'bldg_383f1804-aa34-4634-949f-f769e09fa92d', 'center': [130.41263587199947, 33.22489181671553], 'min_height': 3.805999994277954, 'measured_height': 9.3, 'building_structure_type': '非木造'}, {'gid': 'bldg_877dea60-35d0-4fd9-8b02-852e39c75d81', 'center': [130.41619367090038, 33.22492719812357], 'min_height': 4.454999923706055, 'measured_height': 3.0, 'building_structure_type': '非木造'},...] |
| 30 | +
|
| 31 | +URLs of CityGML zip files can be found at `G空間情報センター <https://www.geospatial.jp/ckan/dataset/plateau>`_. |
| 32 | + |
| 33 | +MVT parser |
| 34 | +---------- |
| 35 | + |
| 36 | +.. code:: python |
| 37 | +
|
| 38 | + >>> from plateauutils.parser.mvt_tile_parser import MvtTileParser |
| 39 | + >>> target_polygon = from_wkt("POLYGON ((130.525689 33.323966, 130.522728 33.314069, 130.511441 33.308653, 130.501013 33.30937, 130.492516 33.318516, 130.493717 33.325831, 130.504618 33.332249, 130.512857 33.332213, 130.525689 33.323966))") |
| 40 | + >>> parser = MvtTileParser(target_polygon) |
| 41 | + >>> result = parser.download_and_parse("https://assets.cms.plateau.reearth.io/assets/43/53a0e1-cc14-4228-a5ef-19333a23596d/40203_kurume-shi_2020_3dtiles-mvt_3_op.zip", "/tmp") |
| 42 | + >>> result |
| 43 | + ['/tmp/40203_kurume-shi_2020_3dtiles-mvt_3_op/luse/15/28254/13174.mvt'] |
| 44 | +
|
| 45 | +URLs of 3D Tiles/MVT zip files can be found at `G空間情報センター <https://www.geospatial.jp/ckan/dataset/plateau>`_. |
| 46 | + |
| 47 | +Flood converter |
| 48 | +--------------- |
| 49 | + |
| 50 | +.. code:: python |
| 51 | +
|
| 52 | + >>> from plateauutils.flood_converter.flood_to_3dtiles import FloodTo3dtiles |
| 53 | + >>> f = FloodTo3dtiles() |
| 54 | + >>> f.convert('/tmp/floodmap_depth', '/tmp/depth_3dtiles') |
| 55 | + >>> from plateauutils.flood_converter.flood_to_png import FloodToPng |
| 56 | + >>> p = FloodToPng('/tmp/floodmap_depth') |
| 57 | + >>> p.parse('/tmp/depth_png') |
| 58 | +
|
| 59 | +How to develop |
| 60 | +-------------- |
| 61 | + |
| 62 | +.. code:: bash |
| 63 | +
|
| 64 | + python3.9 -m venv venv |
| 65 | + ./venv/bin/activate |
| 66 | + pip install -U pip |
| 67 | + pip install -r dev-requirements.txt |
| 68 | + pytest --cov=plateauutils --cov-report=html --cov-fail-under=90 |
0 commit comments