OSM Berlin importing the Shapefiles
Not logged in

Back to OSM Berlin Index



First of all you need to download the collection of Shapefiles for the Berlin area supplied by Geofabrik

This is actually is a compressed ziplfile containing several Shapefiles, each one of them shipping specific categories of MapFeatures. We'll not use all of them for building our OSM Berlin Map, so we'll start first by creating and populating a transient work database by importing only the few relevant Shapefiles we really intend to use. This will make easier and simpler building the final database in a second step.

First approach: using the wizards supported by the GUI

This one wiil probably be the most appreciated by the majority of the users because it's (apparently) more user friendly.
However you'll quickly discover that continuosly repeating the same sequences of click-click-click actions could easly become a boring and time consuming task.

First of all be sure that you have available the Shapefiles released by GeoFabrik covering Berlin.

If not, you can dowload the zipfiles containing all them right now from here


Now execute spatialite_gui and create en empty, brand new database.

The side figure shows the button on the toolbar you have to press for importing all interesting Shapefiles one by one.
map-02
Now for each Shapefile to be imported set the appropriate arguments, then confirm.
  • Be always sure to set SRID=4326 and Charset=UTF-8

Repeat the same procedure untill you have imported all the required Shapfiles accordingly to the following list:
  • gis_osm_buildings_a_free_1
  • gis_osm_landuse_a_free_1
  • gis_osm_pofw_a_free_1
  • gis_osm_railways_free_1
  • gis_osm_roads_free_1
  • gis_osm_places_a_free_1</li>
  • gis_osm_transport_free_1
  • gis_osm_water_a_free_1
  • gis_osm_waterways_free_1
osm-be-001


Alternative approach: using a SQL script

The preferred method for any professional user. It's only slightly more complex, but it ensures a not comparable efficieny and productivity.
-- importing all OSM features of the Buildings class - MULTIPOLYGON
SELECT ImportSHP('c:/osm/berlin-latest-free.shp/gis_osm_buildings_a_free_1', 'gis_osm_buildings_a_free_1', 'UTF-8', 4326);

-- importing all OSM features of the LandUse class - MULTIPOLYGON
SELECT ImportSHP('c:/osm/berlin-latest-free.shp/gis_osm_landuse_a_free_1', 'gis_osm_landuse_a_free_1', 'UTF-8', 4326);

-- inserting all OSM features of the Places class - MULTIPOLYGON
SELECT ImportSHP('c:/osm/berlin-latest-free.shp/gis_osm_places_a_free_1', 'gis_osm_places_a_free_1', 'UTF-8', 4326);

-- importing all OSM features of the PointOfWorship class - MULTIPOLYGON
SELECT ImportSHP('c:/osm/berlin-latest-free.shp/gis_osm_pofw_a_free_1', 'gis_osm_pofw_a_free_1', 'UTF-8', 4326);

-- importing all OSM features of the Railways class - LINESTRING
SELECT ImportSHP('c:/osm/berlin-latest-free.shp/gis_osm_railways_free_1', 'gis_osm_railways_free_1', 'UTF-8', 4326);

-- importing all OSM features of the Roads class - LINESTRING
SELECT ImportSHP('c:/osm/berlin-latest-free.shp/gis_osm_roads_free_1', 'gis_osm_roads_free_1', 'UTF-8', 4326);

-- importing all OSM features of the Transport class - POINT
SELECT ImportSHP('c:/osm/berlin-latest-free.shp/gis_osm_transport_free_1', 'gis_osm_transport_free_1', 'UTF-8', 4326);

-- importing all OSM features of the Water class - MULTIPOLYGON
SELECT ImportSHP('c:/osm/berlin-latest-free.shp/gis_osm_water_a_free_1', 'gis_osm_water_a_free_1', 'UTF-8', 4326);

-- importing all OSM features of the Waterways class - LINESTRING
SELECT ImportSHP('c:/osm/berlin-latest-free.shp/gis_osm_waterways_free_1', 'gis_osm_waterways_free_1', 'UTF-8', 4326);
Highlights:
Important notice: due to security concerns the ImportSHP() is always disabled by default. You absolutely require to set the external variable SPATIALITE_SECURITY=relaxed in order to explicitly enable it.
This is not required when using spatialite_gui because the GUI tool will automatically enable all restricted SQL functions.


Lesson to keep in mind




Back to OSM Berlin Index