How do we count how many buildings mapped in Indonesia? On OpenStreetMap (OSM) it is fairly easy and can be done in less than 5 minutes (if internet bandwith and processor power permits).
Before we start counting, there are several applications that needs to be downloaded and installed.
- Osmosis, used to filter object on the OSM file. Osmosis is a command line, Java-based appplication, ensure that you already Java installed in your operating system.
- Osmconvert, to count the number of buildings. You can download the binary file (ready to run) and it is recomended to put it inside osmosis-latest/bin folder:
There are couple of options for the input data, one of the recommendation is .pbf format (Protocolbuffer Binary Format). Since we want to count number of buildings mapped in Indonesia, we can download Indonesian files at Geofabrik. Geofabrik provide .pbf extract for countries which is updated daily. Don’t forget to put your downloaded file at osmosis-latest/bin folder.
How to Count
After we prepared the data and applications, next step is to open your command line (Windows) or terminal/console (Linux) andd then go to osmosis-latest/bin and type this command:
osmosis --read-pbf indonesia-latest.osm.pbf --tf accept-ways building=* --tf reject-nodes --tf reject-relations --write-pbf indo_building_18082015.pbf
The command above will read indonesia-latest.osm.pbf from Geofabrik and then filter in all OSM object with the tag building=*, the asterisk (*) meaning that it can be yes, house, school or else. The command will filter out all nodes and relations. The results is stored at indo_building_18082015.pbf file. Here is the output from the command above:
Picked up _JAVA_OPTIONS: -Xmx512M Aug 19, 2015 4:16:22 PM org.openstreetmap.osmosis.core.Osmosis run INFO: Osmosis Version 0.43.1 Aug 19, 2015 4:16:22 PM org.openstreetmap.osmosis.core.Osmosis run INFO: Preparing pipeline. Aug 19, 2015 4:16:22 PM org.openstreetmap.osmosis.core.Osmosis run INFO: Launching pipeline execution. Aug 19, 2015 4:16:22 PM org.openstreetmap.osmosis.core.Osmosis run INFO: Pipeline executing, waiting for completion. Aug 19, 2015 4:17:32 PM org.openstreetmap.osmosis.core.Osmosis run INFO: Pipeline complete. Aug 19, 2015 4:17:32 PM org.openstreetmap.osmosis.core.Osmosis run INFO: Total execution time: 70297 milliseconds.
Ensure that the result file (indo_building_18082015.pbf) in the same folder as osmconvert. To make it easier, you can put the osmconvert at osmosis-latest/bin folder. Next, we can count the number of buildings in OSM using the command as follow:
osmconvert --out-statistics indo_building_18082015.pbf
The results of above command are:
timestamp min: 2008-04-21T08:17:56Z timestamp max: 2015-08-18T18:46:47Z nodes: 0 ways: 3916528 relations: 0 way id min: 23892830 way id max: 366365825 keyval pairs max: 37 keyval pairs max object: way 164661954 noderefs max: 877 noderefs max object: way 187879157
Since we only want all of the building tag with ways data type, then the number of buildings is equal with the number of buildings mapped in OSM. In other words, the number of buildings mapped in Indonesia is equal with 3,916,528! This number is growing significantly compared to 1 million buildings in June 2013. In 2 years, buildings data in Indonesia have grown 4 times.
Don’t stop there, let’s keep on map Indonesia!