Script to upload notes based on a source geojson to OSM. This is an alternative to directly import the data in the database.
GPL-3.0 License
Warning: automatic note creation is not endorsed by the community. MapRoulette or a regular import should be used instead, see https://wiki.openstreetmap.org/wiki/Notes
The purpose of this script is to import geojson features as osm notes.
The purpose is to help curate OSM based on messy data from some source.
In the example below we have unreliable data for bathing sites from a Swedish government agency. They don't have names for the site, nor a stable identifier.
Still the points are useful for OSM editors to know about and check out on the ground.
Compares a dataset with OSM and creates notes if the source has more information than OSM
Clone the repository.
Run
$ pip install poetry && poetry install
Copy config.
$cp sample_config.py config.py
Edit the config and add your credentials.
python main.py --source-geojson source.geojson --osm-geojson osm.geojson --notes-file notes.csv --bounding-box 12.0541,59.8233,16.9100,62.3042
The bounding box is on the same format as the Openstreetmap API, see https://wiki.openstreetmap.org/wiki/Bounding_Box
First we get the geojson from the source. In this case we got the data from the Swedish Lantmäteriet and extracted the geojson via https://github.com/dpriskorn/LantmaterietHikingPaths/blob/main/extract_bathing_site_pois.py
The OSM data was fetched via overpass-api using this query:
/*
This has been generated by the overpass-turbo wizard.
The original search was:
“amenity=public_bath or leisure=bathing_place in Sweden”
*/
[out:json][timeout:25];
// fetch area “Sweden” to search in
{{geocodeArea:Sweden}}->.searchArea;
// gather results
(
// query part for: “amenity=public_bath”
node["amenity"="public_bath"](area.searchArea);
way["amenity"="public_bath"](area.searchArea);
relation["amenity"="public_bath"](area.searchArea);
// query part for: “leisure=bathing_place”
node["leisure"="bathing_place"](area.searchArea);
way["leisure"="bathing_place"](area.searchArea);
relation["leisure"="bathing_place"](area.searchArea);
);
// print results
out body;
>;
out skel qt;
Both files were fed to the script like this
$ python main.py --source-geojson badplatser_sverige.geojson --osm-geojson export.geojson --notes-file notes.csv --bounding-box 12.0541,59.8233,16.9100,62.3042
GPLv3+
To the Magnus Sälgö and the Swedish OSM community for feedback.