OpenStreetMap doesn't have anything like an Area, Polygon or MultiPolygon
basic data type. Instead, areas are modelled as closed ways or using a relation
tagged with type=multipolygon
or type=boundary
. This makes the data hard to
edit and use, but it is the way it is.
This repository contains several programs based on the libosmium library that help with understanding what areas there are in OSM by creating statistics or other information from the OSM data. Some programs assemble areas from the nodes, ways, and relations.
The programs in this repository are not meant to be used by end users, they are for developers or mappers who want to understand what's in the OSM data and maybe fix (some of) it.
Osmium/OSM Area Tools uses the following naming conventions:
- Area: A Polygon or MultiPolygon with tags created from a closed way or an Area Relation.
- Area Relation: Any kind of relation that can be turned into an area, a Multipolygon Relation or a Boundary Relation.
- Multipolygon Relation: A relation tagged
type=multipolygon
. - Boundary Relation: A relation tagged
type=boundary
. - Assembling: The process of creating an Area from the basic OSM objects.
- Polygon: A type of geometry (as defined by the Simple Feature Definition) with one outer ring and zero or more inner rings.
- MultiPolygon: A collection of polygons (with one or more outer rings and zero or more inner rings).
Copy only closed ways from input file to output file.
Find all "simple" and "complex" areas and write their IDs to the output files. Complex areas are those where the boundary meets itself somewhere, i.e. they have a node more than once in the boundary. Simple areas are all others.
Assembles areas from their parts and optionally checks them for validity. Can write the areas to a Spatialite database including all the problems encountered on the way.
Creates areas but only looks at those areas which could not be built due to geometry problems. Creates some tag statistics on stdout.
Find problematic data with respect to area creation. This program does not try to actually build the areas, it just looks at the data and flags some obvious problems.
Look at the largest area relations in the input OSM file in terms of the number of ways or nodes they contain. Creates a Sqlite database with information about those relations and an OSM file containing those relations.
Assembles areas from their parts, projects them to Mercator (3857) and checks them for validity. Can write the areas to a Spatialite database including all the problems encountered on the way.
Create areas and report all problems encountered into shapefiles. The areas themselves are not kept.
Prints sizes of some C++ structures used in assembling areas from their parts. This is only interesting for C++ developers optimizing the code.
Create some statistics from an OSM file related to areas. This program will not actually assemble the areas, just look at the objects potentially making up the areas. The results are stored in an Sqlite database.
You need a C++11 compliant compiler. GCC 4.8 and later as well as clang 3.4 and later are known to work. You also need the following libraries:
Osmium Library
Need at least version 2.15.4
https://osmcode.org/libosmium
Protozero
Need at least version 1.6.3
https://github.com/mapbox/protozero
Debian/Ubuntu: libprotozero-dev
gdalcpp
https://github.com/joto/gdalcpp
Also included in the libosmium repository.
bz2lib (for reading and writing bzipped files)
http://www.bzip.org/
Debian/Ubuntu: libbz2-dev
CMake (for building)
https://cmake.org/
Debian/Ubuntu: cmake
Expat (for parsing XML files)
https://libexpat.github.io/
Debian/Ubuntu: libexpat1-dev
openSUSE: libexpat-devel
GDAL/OGR
https://gdal.org/
Debian/Ubuntu: libgdal-dev
GEOS
https://trac.osgeo.org/geos/
Debian/Ubuntu: libgeos++-dev
Sqlite
https://sqlite.org/
Debian/Ubuntu: libsqlite3-dev
zlib (for PBF support)
https://www.zlib.net/
Debian/Ubuntu: zlib1g-dev
openSUSE: zlib-devel
Build like any CMake program by creating a build directory and running cmake
and then make
as follows:
mkdir build
cd build
cmake ..
make
To set the build type call cmake with -DCMAKE_BUILD_TYPE=type
. Possible
values are empty, Debug, Release, RelWithDebInfo, MinSizeRel, and Dev. The
defaults is RelWithDebInfo.
Copyright (C) 2016-2021 Jochen Topf [email protected]
This program is available under the GNU GENERAL PUBLIC LICENSE Version 3. See the file LICENSE.txt for the complete text of the license.
This program was written and is maintained by Jochen Topf [email protected].