QGIS with SOSI support on Windows

Denne posten er også tilgjengelig på norsk.

  • Download and run the OSGeo4W network installer, rather than standalone QGIS
  • Choose advanced installation
  • Select your preferred QGIS version to install from the Desktop category [2]
  • Select the package named gdal-sosi from the Libs category to install alongside QGIS
  • Run C:\OSGeo4W\bin\ogrinfo.exe ‐‐formats (if you chose to install in the default location) and verify that SOSI is on the list of supported formats
  • Run QGIS and under Settings -> System verify that GDAL_DRIVER_PATH is set to C:\OSGeo4W\bin\gdalplugins

That’s it! But in reality you might prefer to just convert the SOSI files to a different format:

Option 1: A new tool by Espen Andersen, sosicon, now makes it very easy to convert SOSI files to ESRI Shape format. If it is not necessary to access SOSI files directly in QGIS (or you’re not using QGIS at all) I recommend you try sosicon first. Windows, Linux and Mac OS X versions are available at Andersen’s github.

Option 2: QGIS, GRASS and other open source GIS-software rely on the GDAL and OGR libraries to access raster and vector data, and these come with their own command line tools that can be used to convert your files without involving QGIS. Previously you would have had to compile your own replacement library first to get SOSI support, like you do on Linux and OSX, but an easier option is now available for Windows users.

To convert files with the ogr2ogr tool: [3]

  • C:\OSGeo4W\bin\ogr2ogr.exe <output>.shp <input>.sosi <layer>
  • (Or just ogr2ogr <output>.shp <input>.sosi <layer> if you use the OSGeo4W Shell)

With <layer> typically being one of points, lines or polygons, like:

  • C:\OSGeo4W\bin\ogr2ogr.exe somefile_pol.shp somefile.sosi polygons

“ESRI Shapefile” is the default output format; to specify another (write-enabled) format, add the -f option and the name as written in the list of supported formats, like:

  • C:\OSGeo4W\bin\ogr2ogr.exe -f “GPX” paths.gpx tfr.sosi lines

You could also create a script to automate this final step, or try my script version for linux or windows.

 

Footnotes:

1: Converting to the Shape format will cause long attribute names to be truncated at ten characters; this is usually not a problem.

2: If you’re using a multi-core/CPU computer and QGIS 2.4 or newer, make sure you enable multi-threaded/parallel rendering from the settings->options->rendering menu.

3: Norwegian SOSI files tend to contain Norwegian characters, that may get lost in conversion. In such cases explicitly defining input and output character sets via SHAPE_ENCODING and ENCODING has solved the issue for me.

Leave a Reply

Your email address will not be published. Required fields are marked *