(that needs some preparation before loading via ogr2ogr)
Author: Astun Technology Ltd.
Contact: support [at] astuntechnology.com
A GML and KML loader written in Python that makes use of OGR 1.9. Source data can be in GML or KML format (including compressed files in GZ or ZIP format) and can be output to any of the formats supported by OGR. The source data can be prepared using a simple Python to both make it suitable for loading with OGR (useful with complex feature types) or to add value by deriving attributes.
The loader was originally written to load Ordnance Survey OS MasterMap Topographic Layer data in GML/GZ format but has since been used to load other GML and KML data.
OGR 1.9
Python 2.6+ or 3
Installation details are available on the project wiki
First configure Loader by editing loader.config
specifying:
See CHANGELOG.md.
src_dir
out_dir
tmp_dir
ogr_cmd
prep_cmd
post_cmd
gfs_file
See python/loader.config
for further explanation and details of available tokens. Environment variables can be used with any of the options by using a token of the form: $HOME
, ${HOME}
or %TEMP%
(Windows only)
Then run from the command-line:
python loader.py loader.config
Additional arguments can be passed to override the values in the config file (useful when running more than one instance of the loader) for example to specify a different source directory (src_dir
):
python loader.py loader.config src_dir=./data/tq
Some configuration examples are available on the project wiki
Data
OS OSMM Water Network Layer
<net:inNetwork nilReason="missing" xsi:nil="true" />
, <hy-n:length xsi:nil="true" uom="m" nilReason="missing" />,
OS MasterMap ITN
roadpartiallinkinformation,
roadpartialrouteinformation
feature typesCore loader.py
GML_GFS_TEMPLATE path_to_template.gfs
loader.py
instances in parallel one per core each processing a single input fileloader.py
process which spawns one process per feature type
--config GML_READ_MODE SEQUENTIAL_LAYERS
as each ogr2ogr
instance would only be loading a single feature typeprepgml4ogr | ogr2ogr | psql
Potential improvements due to changes in OGR
--config GML_GFS_TEMPLATE path/to/file.gfs
to specify template instead of copying template file for each source file (requires GDAL 1.9.0)--config GML_READ_MODE SEQUENTIAL_LAYERS
with GML files that include multiple feature types that appear sequentially to avoid the GML being scanned multiple times (requires GDAL 1.9.0)/vsigzip/
to read gz directlySee AUTHORS.md.
MIT, Copyright (c) 2017 Astun Technology Ltd. (http://astuntechnology.com). See LICENSE.txt for full terms.
The logic to apply style_code
and style_description
values to OSMM Topography Layer data is derived from the ESRI UK OSMM-Styling project licensed under Apache-2.0.