Converting Japan DEM GML/XML files to geotiffs
When downloading 5m or 10m DEM data for Japan from their Geospatial Information Authority, you get a bunch of zipped
➜ unzip -l FG-GML-6645-42-DEM5A.zip Archive: FG-GML-6645-42-DEM5A.zip Length Date Time Name --------- ---------- ----- ---- 733439 2016-09-14 23:05 FG-GML-6645-42-05-DEM5A-20161001.xml 587112 2016-09-14 23:05 FG-GML-6645-42-06-DEM5A-20161001.xml 685434 2016-09-14 23:05 FG-GML-6645-42-07-DEM5A-20161001.xml 86624 2016-09-14 23:05 FG-GML-6645-42-15-DEM5A-20161001.xml 555112 2016-09-14 23:05 FG-GML-6645-42-16-DEM5A-20161001.xml --------- ------- 2647721 5 files
.xml files shows they do contain the elevation data as newline-separated tuples, but they’re not readable by common tools like GDAL. This stackoverflow question suggests using demtool but it only runs on windows.
So I built a tool jpgis-dem to convert these
.xml files to
.tif. It uses the same logic as tmizu23/demtool but written in Python (with rasterio) so you can run it on Linux and MacOS.
It installs with pip
pip install jpgis-dem
and can convert
jpgis-dem xml2tif FG-GML-3622-57-DEM10B-20190510.xml 3622-57.geotiff
as well as zipped archives containing one or more
jpgis-dem xml2tif FG-GML-3624-31-DEM5B.zip 3624-31.geotiff
into cloud-optimized geotiff files that can be opened by e.g., qgis. Here’s a heatmap for a single tile: