Sosicon has the ability to assemble several SOSI source files into one large SQL file. However, the maximum size of the destination file depends on the target machine’s memory resources. Sometimes, the data source is too large for a single-run approach and you will run out of memory.
Fortunately, there is an easy workaround to avoid memory exhaustion. You will have to build the database creation script (DDL statements) separately, and then split up your insertion script (SQL statements) across multiple SQL files. That is quite easily accomplished with the -create and -insert parameters.
Continue reading Converting exceptionally large SOSI files to PostGIS
Here’s an example on how to convert and import SOSI map data into PostgreSQL/PosGIS using Sosicon, then opening it in Mapbox’ design studio TileMill.
We are going to use the landcover SOSI file “NO_N250_Arealdekke.sos” from the N250 SOSI package provided for free by the Norwegian Mapping Authority.
Continue reading Get SOSI into PostGIS and TileMill
SOSI files may be converted to a PosgreSQL/PostGIS dump file for easy database import. The content of related SOSI elements are exported alongside the geometry.
The following command will create an sql file for PostGIS from, let’s say 32_1244Adresse.sos:
sosicon -2psql 32_1244Adresse.sos
The default file name for the export file is postgis_dump.sql. Run it in psql to create the schema and the points table. A database schema called sosicon will be created in the active database, and in it the table object_point is created and filled with the exported SOSI data points. If there are several geometry types in the SOSI files, one table is created for each geometry. The table names are postfixed with the relevant geometry name, i.e. “object_point”, “object_linestring” or “object_polygon”.
Use the -o parameter to specify a different output file name. To specify custom schema or table name, use -schema and -table:
sosicon -2psql -schema municipalities -table austevoll -o austevoll.sql 32_1244Adresse.sos
This vil output austevoll.sql. When imported in PostGIS, the data will be stored in table austevoll_[XXX] within schema municipalities, where [XXX] is the geometry name.
Continue reading PostGIS
A single SOSI file may contain several types of objects and geometry types. By default, Sosicon converts everything contained in the source file. It either writes the result to a large number of destination files in case of Shapefile export, or creates one very large SQL file in case of PostgreSQL/PostGIS export.
If you only want a pre-defined subset of features exported from the SOSI source, you can use the
-g options to restrict the conversion. On large SOSI files, this will save both time and storage space.
Continue reading Export selected
High-quality maps can be downloaded from the home page of the Norwegian Mapping Authority. You can get the SOSI files for the nation-wide N500 map here.
The N500 package consists of several SOSI files, each representing a set of various geographical features. One SOSI file may contain a multitude of geometries and object types. However, Shapefiles can contain no more than one geometry type each (typically polygons, polylines or points). Hence, one SOSI file may generate several Shapefiles, as individual geometries and object types are singled out and exported to separate Shapefile layers.
Continue reading Data example