Taking some OSM (*.osm) data downloaded from Geofabrik I have created a Spatialite database using spatialite_osm_map. Now I have problems, because some of the data that is supposed to be in the form of polygons appears in the database as polylines, which I can't style properly. As an example, objects tagged "natural=wood" appear correctly as polygons in the DB while objects tagged "landuse=forest" appear as lines.

I think this must be something to do with what I've seen called the "multipolygon problem". At present I am loading the affected objects into QGIS, exporting them as shapefiles and then polygonising these, but there must be a better way of working. Any help on this topic would be gratefully received.

I ought to mention that what I know about Spatialite and OSM data wouldn't fill a thimble.

Added later: here is a screenshot illustrating the problem. The "polygon" selected by the info tool is in fact a polyline. Nick.

enter image description here

  • Can you show the steps to repeat this? It would help to know exactly which data, and exactly how you are running spatialite_osm_map. – BradHards Aug 2 '12 at 9:40
  • The data is "england.osm" from Geofabrik. To load it into the DB I used "spatialite_osm_map -o england.osm -d enJUL2012.sqlite". Geofabrik's shapefiles also have this problem. Using QGIS Master under Ubuntu 12.04 (amd64). Thanks for your interest. N. – nhopton Aug 2 '12 at 10:54

In Openstreetmap, polygons can be build either by one closed way, or by a number of ways, which form a closed way. Those ways have to be part of a "relation" of type "multipolygon".

I dont know your tool, but the safest way to have those polygons correctly is to use a Postgis database filled with osm2pgsql.

A sample osm-id from your data could help investigating further.

  • Hi Andre, I've added a picture above with an OSM id. N. – nhopton Aug 2 '12 at 11:16
  • Ok, so its a simple closed way, no recent editing in the database, and no redaction bot involved. Using the OSM plugin within Qgis gives a nice polygon. And the Geofabrik shapefile has the object in layer natural. I dont know what problems the spatialite tool has. – AndreJ Aug 2 '12 at 11:26
  • "Closed ways", thanks for the proper terminology. But how to get these into a Spatialite DB as polygons? N. – nhopton Aug 2 '12 at 11:46
  • Have you tried the Openstreetmap plugin? It creates layers within qgis, which you can copy&paste to your database layers. – AndreJ Aug 2 '12 at 12:00
  • I just tried spaitalite-osm-map on the single way I downloaded with JOSM editor. It has been imported as a polygon in pg_landuse as expected. SQLite version 3.7.9, Spatialite version 3.0.1 under Windows 7. – AndreJ Aug 2 '12 at 15:03

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.