![](https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjJ1axim4QJZpk_gLW1nTGVcRyU1KNcD1qKIsLsT05wPGtvPnnhGMzseyAX8Ojr6_m8PzNw3BPlki0y7RTBdeXbgxrm4KcgvUMy5CAmYlazxeuTB-SnIQFtOzRn_PiCVXV4zwHjYA0ScH1D/s400/ua_bad_polys2.png)
I'd hoped to get further with my Urban Atlas simulation, but have been distracted by badly formed polygons. In using osm2pgsql, I relied on it for conversion of OSM data to polygons in PostGIS. The polygons get created and load fine, but once I started clipping sets of data I noticed that I was losing some landuse polygons. Specifically I noticed that the residential landuse for the two large villages (or small towns) of Bingham and Radcliffe-on-Trent were missing. The image above shows the Harlequin area of Radcliffe with residential landcover (red), but the polygon for the rest of the village has gone.
I was not at all sure where the problem lay. I reimported the data with a different version of osm2pgsql; I used an older data set; I even rendered the area using a modified version of the OSM mapnik
![](https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgnc4-C1oq40j49h7Maf09X8cwcIp5a0LZ44AYriUlM5hw2evb-gP0JSPQlqK1T-cuPliEJ302RRSBvqxAsVadv7bW7LU3zCdpodvk0Q5i4ckBavZqboNNF1qfyZtbCTW01vWzHF4xs5Lid/s320/urban_atlas3highlight.png)
Only partially. It's really much better to find the problem at source and resolve it there. I had tried the JOSM validator on the data but it did not report any problems, so I was still uncertain if it was a hidden bug in osm2pgsql or a data problem.
I left the issue for a couple of days, until, whilst checking some address data, I noticed Geofabrik's OSM Inspector had a set of Geometry validation tools. I'd never found a use for these in the past. Of course, Jochen Topf and Frederik Ramm thought about this sort of problem long ago and I could instantly see the exact location of the problems, and even click on an icon to start-up Potlatch in the right location. Just another illustration of the rich endowment of the OSM ecosystem.
![](https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEibyncqKPjxLwWYyKMMXyyfzxWg2Yzp-PLfmsyYsnhvIkmORf6zFh7liaYPdQZuJaQc-S_MaOc-l45bCdokZU7j3JYau0Zy3Ccz9Qr-NlN9u9zEf14oRaeN2khUoS0-afjTxxxsOJ2gheDM/s400/Bad_polys_small.png)
Great Britain has around 1500 badly formed polygons (based on data from Jan 22) or about 0.2% of the total data. Of these about 80% are self-intersecting and the rest are mainly self-intersecting rings. Many are buildings (400 or so, as seen in the screen-shot above), with the rest more or less evenly distributed between landuse, woodland (natural=wood) and water (natural=water). Overall the error rate is extraordinarily low given that most OSM contributors are, like me, probably don't do formal checks on the geometry of their data.
So I can go back to my simulation, having once more found that OSM provides the tools I need.
No comments:
Post a Comment
Sorry, as Google seem unable to filter obvious spam I now have to moderate comments. Please be patient.