Importing Housenumbers into OSM from Trento municipality's dataset with Python 2.7
Here you can see how I did to get the housenumbers from the municipality of Trento into OpenStreetMap, verifing which are already in OpenStreetMap and deleting from the dataset.
Here are all the steps I made
- I got the dataset with the house numbers of Trento from the Open Data section of the Municipality website. The dataset is distributed with the terms of the CC0.
- I got the dataset with the house numbers of Trento from OpenStreetMap from the website Estratti OpenStreetMap. The file used is the shapefile addresses.shp archived on the zipfile 022205---Trento.zip
- I created a SQLite/Spatialite database and inserted the datasets creating 2 tables with Spatialite-gui. The projection used by the Municipality is the ETRS89 / UTM zone 32N EPSG:3044.
- I created a third table, based on the Municipality one, containing only "front entrance" (value "ingresso principale") numbers and discarding side entrances.
- I started to write some code in Python to do some exercises without Spatialite-gui
- Then I began to write the code to get common housenumbers from the two tables (get_common_numbers). To improve it I used the library pypostal to normalize the names.
- I cleaned the data with OpenRefine in order to remove housenumbers with different street names, from the output of get_common_numbers
- I checked and corrected manually the data inside OpenStreetMap
- Once refined the output file, I wrote the file delete_civici_comune to delete all the common housenumbers from the table
- I done another time from the 8th point, but this time with a bigger Buffer (50m - expressed with the projection EPSG:3044) for intersecting housenumbers that were at an higher distance
- Estracted in a CSV file (civici_osm.csv) all the OpenStreetMap housenumbers, then with the file osm_only_search I've isolated in a CSV file all the numbers not contained in the municipality's table
- I controlled by hand all the numbers in OpenStreetMap from the previous file, changed data where needed and deleted from the municipality table (to have no copies of the same housenumber)
- Managed to get all Municipality's street a corresponding one to OpenStreetMap, importing the roads datasets from both OpenStreetMap and the municipality, done with get_street_comuni primarily, secondly with get_street_names, and at the end with get_street_names_notinosm
- Wrote the import_osmapi in order to import the housenumbers into OpenStreetMap using osmapi for Python.