Shape up your maps

qgis_n250_example
SOSI files for Norway’s N250 land cover, converted to Shapefile layers with Sosicon and imported in QGIS.

Access super-quality digital maps freely available from the Norwegian Mapping Authority.

SOSI (Norwegian acronym for “Coordinated Approach for Geospatial Information”) is the standard for exchanging geospatial data in Norwegian government institutions.

Sosicon screen shot.
Sosicon screen shot.

Sosicon extracts and converts geospatial information embedded in SOSI-formatted files to more commonly used formats, such as PostgreSQL/PostGIS or ESRI Shapefile, which can be imported directly into most GIS applications, such as QGIS or TileMill.

Sosicon is open-source software and is released under GNU General Public License, version 3. You may use this software for any purpose of your desire, as long as it is kept open source. Please read the license terms.

This is a beta version of the program. Bugs are expected!

The command-line interface

Download the command-line version (binary file) to a location where it can be run from the terminal window. A simple approach for testing is to put Sosicon in the same folder as the SOSI file. Then run

./sosicon -2shp sourcefile.sos

where sourcefile.sos is the name of the SOSI file you want to convert.

Likewise, to produce a PostgreSQL/PostGIS database import file, use -2psql instead:

./sosicon -2psql sourcefile.sos

More tips and tricks can be found in the «using Sosicon» section.

For permanent installation on Linux or OS X, copy sosicon to one of the locations pointed to by the $PATH environment variable, typically the /usr/bin directory.

On Linux and OS X, piping is supported for batch processing of multiple SOSI files in one operation. To process all SOSI files in current directory, run the following command:

ls *.sos | sosicon -2shp

This will churn through all *.sos files in the directory, extracting several sets of shapefiles depending on the geometries and object types found.

A list of the available, free map data sets can be found at the web site for the Norwegian Mapping Authority.

For the time being, PostgreSQL/PostGIS and Shapefile export are supported. Please let me know of any errors.

License and disclaimer

This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.

Sosicon is written by Espen Andersen. It is released under the GNU General Public License, version 3.
Read the license terms here

The desktop versions of sosicon are built using the cross-platform development tool Qt, licensed under the LGPL open-source license. A copy of the source code kan be obtained here (OS X and Linux), and is also available from the vendor’s web site.

Bugs

There are bugs, of course. After all, this is merely a pre-release (not even beta) a beta release. If you encounter an error in the software, please create an issue on GitHub where you describe the problem.

39 thoughts on “Shape up your maps”

  1. Hi

    I downloaded the sosicon program, both linux and windows and have not been able to make it work. Not sure that is a bug, that’s why I did not open an issue on github.

    1. In windows I get an error message regarding a missing “MSVCP120.dll” file, I think I have to install visual studio 2013. Is that right?

    2. So, I tried linux.. I use a vm with linux mint, and when I try to execute this:
    sosicon -2shp ADM_kommune_15_More_og_Romsdal.sos
    returns
    sosicon: command not found

    I prefer to use linux because i need to transform multiple files to shp. What could be my problem?

    regards
    Silvia

    1. Hi and thank you for trying it out!

      The Linux version should work regardless of any external libraries. If you run the app from the same directory, you’ll have to prefix the command with ./ – like this:

      ./sosicon -2shp xxxxxx.sos

      Another option is to copy or symlink the excutable to one of the directories listed in your $PATH environment variable, typically /usr/local/bin or /usr/bin.

      I’ll have a look at the win32 version; there seems to be some kind of dependency lurking around there – which it clearly shouldn’t be. You should not have to install anything to run sosicon on a Windows system.

      After a bit of checking, it turns out that Windows users should also install the “Visual C++ Redistributable Packages for Visual Studio 2013”.

      Some users have this installed from before. It can be downloaded from Microsofts site. Sorry about the confusion. I’ll update the install instructions.

      Regards
      Espen

  2. Hei,

    Thanks for creating this tool! Worked perfectly on Windows7 64b. Why do you think Norwegian map authorities chose to release their data in the .SOSI format instead of more mainstream ones?

    Thanks again,
    Terje

    1. Hi and thank you! I suspect that SOSI came into existence because Norwegian government institutions were in fact quite ahead of time when they started to digitize and exchange geospatial information in the 80s.

      The contemporary lack of well established standards for exchanging geographical information prompted them to create their own format – SOSI.

  3. Hi, thanks for a great tool. I was stuck after copying sosicon to /usr/bin with permission denied in terminal. After some googling I found sudo chmod 755. You might include this line in the guide as well for us newbies. Now it works!

    1. Ok, there is probably some kind of formatting issue with your source file. I would need to look at the file you are trying to convert. Please feel free to PM me with an attachement or link to an example file that fails like you say.

    2. Hi,
      I think I have the same issue but it turned out to be easy to solve. Coordinates are scaled so You have to rescale the coordinates by multiplying by scalar of 0.01. Hope it helps!

      1. Thanks for looking into this. Sosicon is programmed to take the scalar value (technically the ENHET [unit] element within the file head) into consideration. I will have to find out what went wrong.

  4. If you have a bunch of SOSI files in a directory tree, this handy command will recursively convert all files to shp and leave the files in same directory as the originating SOSI file.


    find . -type f -name "*.sos" -exec sosicon -2shp {} \;

    Since the output of a single SOSI file may be multiple Shapefiles, it would be nice if sosicon could put all files in a sub directory.

  5. Installed Sosicom and Visual C+ in Windows 7, but it didn’t work . The command window just opens for half a second and then shuts down.

    Also tried in xubuntu. There I god permission denied (to the file?). The sudo chmod was over my abilities.

    Maybe I need to become a more advanced user?

    1. Hi!

      Sosicon has no graphical user interface, and must be run from the command-line. It’s not hard once you’ve gotten into the basics :)

  6. Hi, I am a complete rookie in the field of GIS, but I am eager to learn… I am using the program Distance which is “the” program for sampling biological populations. Distance has a GIS application which needs the files to be in ESRI Shape format. Your program looked perfect for the job! I downloaded the Sosicon program and the other C++ packages and followed you suggestions. When trying to run the .exe file it opens and closes again within 1/10 of a second (or less). Not possible to enter any parameters. Running WIN8.1 64bit. Any suggestions?

    1. Sosicon must be run from the command line. Open the terminal window (the “DOS” window) and run it from there. Type sosicon –help to get some hints.

  7. Just started using Autocad LT on Mac and needed som sosi-files and was glad when I found sosicon, but…
    I have tried for four hours with variations of your recommended commands in the program “Terminal” with the result “Permission denied”.
    Any hints on what to do next?

    1. Sorry for such late answer. Your problem relates to file permissions not being set properly. I suspect that the sosicon binary doesn’t have execute permission.

      Goto the directory where you stored sosicon and try to set the permissions with the command “chmod 755 sosicon”.

  8. Hi, just a comment. I struggled with the missing “MSVCP120.dll” file. My solution was to install the “Visual C++ Redistributable Packages for Visual Studio 2013” 32 BIT version. The 64 bit version did not solve the missing dll file.

  9. Hi! I have come upon a curios problem, when testing the program I managed to convert my .sos-files to .sql – but the .shp command did not work.

    When converting to .sql everything worked as it should, but when I try the same for .shp I get the error “whateverinputfile.sos not found”.

    Any idea what I did wrong?
    (OS: windows)

    1. Hi!

      Looks like the source file name or path is wrong. Please check the input file name.

      If there are spaces somewhere in the path, enclose the file name in quotes.

      sosicon -2shp "whatever input file.sos"

      The path is relative to the directory from which you run Sosicon. Hence, if you run Sosicon from the same directory as the SOSI file, the command should be as follows:

      sosicon -2shp whateverinputfile.sos

      If the file resides in a subfolder called “sosi”, the command should be:

      sosicon -2shp sosi/whateverinputfile.sos

      PS: Make sure that you have one of the latest versions of Sosicon. Unknown bugs may appear in earlier versions.

      Espen

  10. I have just downloaded sosicon for OS/X, have done chmod 755 sosicon and tried to run the command ./sosicon -2shp Arealdekke.sos in the terminal window. I get the response “illegal instruction”. Any suggestions? Do I need to initiate sosicon before trying to convert?
    I am running OS/X 10.6.8. Does Sosicon require a later version?

    1. Hello!
      This issue might have something to do with your OS X version. Unfortunately, I don’t have access to any machines running OS X 10.6.x – otherwise I’d be happy to build a version for your system. However, if you feel up to it, you can build Sosicon yourself from source code using the instructions on GitHub. You’ll need the g++ compiler (comes with Apples free XCode development tool) to build Sosicon.

  11. Hi there Espena,
    I have converted a number of SOSI format files to ESRI shapefiles using Sosicon, and then imported these shape files into Illustrator using the plugin MAPublisher.
    Everything seems to work fine except for the text! All the names were converted, but were placed outside the design plane and therefore unusable!
    Contacts at the Norwegian Kartverket say that names in their database are stored as text objects. They suggest that when converted into shapefiles by Sosicon, the names are converted to points with text attributes, and under this conversion the placement coordinates may not have been correctly interpreted. (They say that ESRI does not support text objects).
    Is this something you have heard of before and if so do you have any suggestions about how this problem can be solved?

  12. Hei Espen,

    Jeg forsøker å åpne sosicon programmet i Windows, men programet viser seg kun i 1 sekund og så forsvinner det fra skjermen. Jeg har forsøkt å installere Visual C++ Redistributable Packages for Visual Studio 2013, men heller ikke dette gjør susen. Har du noen ideer for hvordan jeg kan løse dette?

    Supert at du lager et “open soruce” program for dette!

    Hilsen Pernille

    1. Hei igjen,

      Jeg fikk det til, måtte bare finne ut av hvordan man åpner kommandoviduet i mappa. Supert verktøy! Takk.

      Er det en måte å konvertere flere filer samtidig? For eksempel kan det tenkes at vi har kartdata for 100 år eller dager tilbake i tid. Dette vil være en tidkrevende prosess.

      Igjen, takk for bra verktøy!

      Let me know if you want me to translate the text to English!

      Pernille

      1. Hei og takk!

        Du kan konvertere flere filer samtidig i OS X, Linux og Windows ved å bruke “pipe” (|). Se avsnittet “Shapefile conversion” på GitHub for en beskrivelse.

        Espen.

  13. Prøver sosicon for første gang, men får kun denne meldingen:
    Reading NO_N250_Arealdekke.sos
    16768045 lines parsed
    Building postGIS export
    Coordinate system: ETRS89 / UTM zone 33N
    bad allocation

    maskinen min er win 7×64

  14. Hei,

    I am running a linux 32bit system. and converting the sql file gives me a bunch of error message.

    postgres=# \i postgis_dump.sql -v
    SET
    psql:postgis_dump.sql:8: ERROR: schema "sosicon" already exists
    CONTEXT: SQL statement "CREATE SCHEMA sosicon"
    PL/pgSQL function inline_code_block line 3 at SQL statement
    DO
    psql:postgis_dump.sql:18: NOTICE: relation "object_point" already exists, skipping
    CREATE TABLE
    psql:postgis_dump.sql:19: ERROR: function addgeometrycolumn(unknown, unknown, unknown, integer, unknown, integer) does not exist
    LINE 1: SELECT AddGeometryColumn( 'sosicon','object_point','object_g...
    ^
    HINT: No function matches the given name and argument types. You might need to add explicit type casts.
    psql:postgis_dump.sql:20: NOTICE: relation "object_linestring" already exists, skipping
    CREATE TABLE
    psql:postgis_dump.sql:21: ERROR: function addgeometrycolumn(unknown, unknown, unknown, integer, unknown, integer) does not exist
    LINE 1: SELECT AddGeometryColumn( 'sosicon','object_linestring','obj...
    ^
    HINT: No function matches the given name and argument types. You might need to add explicit type casts.
    psql:postgis_dump.sql:22: NOTICE: relation "object_polygon" already exists, skipping
    CREATE TABLE
    psql:postgis_dump.sql:23: ERROR: function addgeometrycolumn(unknown, unknown, unknown, integer, unknown, integer) does not exist
    LINE 1: SELECT AddGeometryColumn( 'sosicon','object_polygon','object...
    ^
    HINT: No function matches the given name and argument types. You might need to add explicit type casts.
    psql:postgis_dump.sql:50024: ERROR: column "object_geom" of relation "object_point" does not exist
    LINE 1: ...t_point (dybde,dybdetype,foerstedatafangstdato,n�,object_geo...
    ^
    psql:postgis_dump.sql:100025: ERROR: column "object_geom" of relation "object_point" does not exist
    LINE 1: ...t_point (dybde,dybdetype,foerstedatafangstdato,n�,object_geo...
    ^
    psql:postgis_dump.sql:150026: ERROR: column "object_geom" of relation "object_point" does not exist
    LINE 1: ...t_point (dybde,dybdetype,foerstedatafangstdato,n�,object_geo...
    ^
    psql:postgis_dump.sql:175858: ERROR: column "object_geom" of relation "object_point" does not exist
    LINE 1: ...t_point (dybde,dybdetype,foerstedatafangstdato,n�,object_geo...
    ^
    psql:postgis_dump.sql:200485: ERROR: column "object_geom" of relation "object_linestring" does not exist
    LINE 1: ...string (dybde,foerstedatafangstdato,kp,kystref,n�,object_geo...
    ^
    psql:postgis_dump.sql:207732: ERROR: column "object_geom" of relation "object_polygon" does not exist
    LINE 1: ...gon (dybde_max,dybde_min,foerstedatafangstdato,n�,object_geo...
    ^
    SET
    \i: extra argument "-v" ignored

    any hint what I could do or what this means?

    tussen takk!

    1. Hi!

      Sorry for a late answer – I had to look into this. Turns out that there was a bug in Sosicon, causing trouble in UTF8-encoded SOSI files with three dimensional coordinates. The bug should have been fixed now, I have committed and published a new version today. Sorry for the inconvenience.

      Espen

  15. Hi, some comments/questions (sosicon_v1.0_gui_setup_x64.exe)

    1. Is it possible to convert to a 3d shape file?
    2. Is there problems with Norwegian letters æøå? Sosicon will not recognice files with those letters, getting a “xxx.sos not found!”. Workaround, change “Ø” to “O” in filename.

    Keep up the good work…

Leave a Reply

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