Skip to content

NKAmapper/building2osm-sweden

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

31 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

building2osm-sweden

Tools for importing buildings in Sweden to OpenStreetMap

building2osm

Downloads buildings from Geotorget and generates tagged geojson import file with building footprints.

Usage: python3 building2osm.py <municipality> [<input filename>] [-split] [-original] [-verify] [-debug] [-heritage]

Parameters:

  • municipality - Name of the municipality to generate. Output for several municipalities if "Sweden" is given.
  • input filename - Optional GeoJSON or GeoPackage file containing source data of buildings for municipality, otherwise automatic downloading from Geotorget.
  • -split - Also split output file into smaller subdivisions ("bydel", electoral or post districts).
  • -original - Produce file without any modifications.
  • -verify - Include extra tags for verification of topology modifications.
  • -debug - Include extra tags for debugging.
  • -heritage - Save separate GeoJSON file with all protected heritage buildings (points) in Sweden.

building_merge

Conflates the geojson import file with existing buildings in OSM and produces an OSM file for manual verification and uploading. First generate the import file with building2osm.py or download from OSM building import progress.

Usage: python3 building_merge.py <municipality> [<max distance>] [<filename.geojson>] [-debug]

Parameters:

  • municipality - Name of the municipality to conflate.
  • max distance - Optional maximum Hausdorff distance between matched buildings. Default value is 10 metres (5 metres if the building is tagged). Increase if needed for larger offsets.
  • filename.geojson - Optional input file in geojson format. If not specified, the import file for the municipality will be loaded (it must be present in the default folder or in a predefined folder).
  • -debug - Include extra tags for debugging.

building_split

Split building import file into smaller subdivisions. Useful is municipality contains more than approx. 10.000 buildings.

usage: python3 building_split.py <municipality> | <filename.geosjon> [<target_size>] [-tag] [-debug]

Parameters:

  • municipality - Either name of the municipality (will produce filename).
  • filename.geosjon - Or name of import file to split.
  • target_size - Optional target size, i.e. number of buildings per partitioned file (default 10.000).

Notes

  • Source data is from Lantmäteriet, combined with heritage data from Riksantikvarieämbetet.
  • The building=* tag is given a value corresponding to the building_tags translation table in this respository. Please provide feedback if you observe that the tagging should be modified.
  • Certain modifications of the footprint polygons are made to avoid clutter in OSM:
    • Polygons which are almost square are rectified (orthogonalized) to get exact 90 degrees corners. Groups of connected buildings are rectified as a group. Multipolygons are supported. A polygon is not rectified if it would relocate one of its nodes by more than 20 centimeters.
    • Redundant nodes are removed if they are located on an (almost) straight line.
    • Curved walls are only simplified lightly.
  • Output is stored in a geosjon file which may be loaded into JOSM when the OpenData plugin has been installed. Please read the import plan for guiding on how to do the import.
  • The building_merge.py program conflates the import buildings with existing buildings in OSM.
    • New buildings are loaded from the geojson import file. You may split the import file into smaller parts using municipality_split.py or manually.
    • Existing buildings are loaded from OSM.
    • New and existing buildings which are each other's best match within the given maximum Hausdorff distance (default 10 metres) are automatically conflated. They also need to have similar size (default up to 50% difference).
    • The OSM_BUILDING=* tag will show which building tag was used by the existing building, unless they are in similar residential/commercial/farm categories.
    • Use the To-do plugin in JOSM to:
      1. Resolve Overlapping buildings warnings.
      2. Resolve Building within buildings warnings.
      3. Resolve Self-intersecting ways and Self crossing ways warnings.
      4. Check LM_building=* for considering manual retagging of building types.
      5. Check untouched existing OSM buildings (search for building=* -modified -parent modified).
      6. Check if entrances or other tagged nodes needs to be reconnected to the new buildings (search for type:node ways:0 -untagged).
    • Consider using Edit->Purge in JOSM to work on a subset of a large municipality.
    • The building_merge.py program may be run several times for the same municipality. Only buildings with a new ref:lantmateriet:byggnad tag will be added each time.

Changelog

  • 2025-03-02: building2osm.py: Load heritage data from Riksantikvarieämbetet; Better topology/more details; Improved circles; More user-friendly municipality identification; File exception handling.
  • 2025-01-22: building2osm.py: Direct loading from Geotorget; Adjacent buildings connected. Improved building topology.
  • 2025-01-16: Added building_split.py.

References

About

Tools for importing buildings in Sweden to OpenStreetMap

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages