OSM Mirror¶
The OSM mirror uses the kartoza/docker-osm tool to create an in-database mirror of a designated geographical area in the designated postgres databse schema (set to: osm). The OSM mirror tool is described in the project README here:
https://github.com/kartoza/docker-osm
To deploy the docker-mirror you need to follow the steps descibed below. First a process overview:
- Create the PBF feature container passing it a URL to a PBF file
- Create a clip file that will be used to constrain any retrieved / imported data to a specific geographic area.
- Tweak the mappings.yml file (advanced users)
- Run the docker-osm service
- Optionally include these data in published services via QGIS projects, GeoServer etc.
PBF Container¶
During the make configure
process, the script will ask for the URL
to an OSM .pbf file e.g.:
------------------------------------------------------------------
Fetching pbf if not cached and then copying to settings dir
------------------------------------------------------------------
URL For Country PBF File: https://download.geofabrik.de/central-america-latest.osm.pbf
You can enter any valid URL for an OSM .PBF file at this point. A docker container will be built that fetches the PBD and stores it on the host file system under osm_config.
Clip Area¶
Create the clip area to constrain the geographical region that data
will be harvested for. For best performance, a simple rectangle is best,
but any complext polygon can be used. The clip area must be saved
as osm_config/clip.geojson
. The format for the clip area must be
GeoJSON. You can easily create this using QGIS.
Mappings¶
For advanced users, you can tweak the osm_config/mapping.yml
You can see how the imposm3 mapping syntax works here:
https://imposm.org/docs/imposm3/latest/mapping.html
Note that you cannot alter the mappings after the service is running without clearing the databse and restarting the import.
Publishing with GeoServer¶
You can publish the data in the osm schema using GeoServer or by publishing a QGIS project that references the data layers in the OSM schema.
The steps for publishing with GeoServer are quite simple:
Log in to GeoServer using the ‘admin’ user and the password in .env.
Create a new store of type ‘Postgis’ and configure it as per the screenshot below, replacing the password with the Postgres password stored in .env:
Also, be sure to scroll down and set SSL mode to Required:
Register one or more layers from that store as per the image below:
4.Complete the layer details as appropriate and make sure to click the options highlighted in red in the screenshot below:
- Connect to the GeoServer from a client e.g. QGIS using WFS or WMS using the scheme:
https://example.org/geoserver/SaintLucia/wfs
or
https://example.org/geoserver/SaintLucia/wms
Publishing with QGIS Server¶
The workflows described in the section on working with the PostgreSQL database below are basically all you need to know, so we don’t repeat that here, other than to remind you that hte OSM mirrored data is by default stored in a schema called ‘osm’.
OSM Attribution¶
Note that whenever you publish a map containing OSM data, be careful to adhere to the license and credit the OSM Project as per:
https://www.openstreetmap.org/copyright