Displaying S57 nautical charts in QGis 3.X

In this article you’ll find out how to load an ENC file in S57 format into QGis 3.34 and download a nautical chart symbology to apply to it.

As the previous article on the S57 format and how to view electronic nautical charts (ENC) with QGis dates back to 2015, it was high time to publish an update for current versions of QGis (3.34 at the time of publication of this article).

Information sources for coastal territories are not limited to classic terrestrial sources. Marine maps can provide very useful information and, from a rendering point of view, can produce rich, high-impact documents.

Electronic nautical charts (ENC) are the most suitable source for rapidly integrating large quantities of information. In a single batch of data, you can find all the information contained in a nautical chart: coastline, bathymetry, buoyage, etc…

Unlike in the USA and other countries, where nautical charts are free and available for download, in France they have to be paid for, which slows down their distribution and use enormously.

ENC maps are distributed in an International Hydrological Bureau (IHB) format called S-57. This format is one of the vector formats that can be loaded directly into QGis. So you can open an ENC map in QGis, and display its contents. But the problem is that you’re displaying its contents with conventional default symbols, which have nothing to do with the symbology used on a nautical chart.

Here’s the result of loading an S-57 file into QGis.

displaying an ENC S57 map with QGis, using direct loading

You can, of course, take layer by layer and assign it an appropriate symbology. There are around 75 layers in a typical ENC.

Here’s a quicker way.

If you’d like to try out this procedure and don’t have an ENC map to hand, you can download a free American map from the NOAA website by clicking here.

How the procedure works

Instead of loading the S57 file directly, we’re going to pre-process it to create shape files of the various layers present. Not only is this essential for displaying a pre-established symbology, but it also allows you to integrate only the layers you want into other current processes.

To create the shape files, we’ll use the GDAL library in Qgis. Using a command line, we’ll retrieve the S57 tables and create a shape for each type of geometry and object.

To do this, simply open the OSGeo4W shell window:

Osgeo4W Shell

The Shell window opens

Osgeo4W Shell

We’re going to translate the S57 format into a series of shp files, which we’ll save in a new directory.

The command line to be entered is of the following form:

ogr2ogr -skipfailures output input
output: corresponds to the name of an empty directory where the shp files created will be stored
input: this is the S-57 file to be translated, with its .000 extension. Please note that the S57 file tree is not constant. Make sure you enter the path of the file with the .000 extension.

If we use this command line, with no other options, for example:
ogr2ogr -skipfailures c:\blog\nautical\ENC603360 c:\blog\nautical\FR603360\2\0\FR603360.000

We’ll get one shape per S57 object type, for example the MARCUL (marine culture) object. The problem is that SD57 objects can be points, lines or polygons simultaneously. This is the case with MARCUL. Without any other option on the command line, we’ll obtain a shapefile of the first type found from MARCUL, with other geometries ignored.

We will therefore perform three translations:

the first by selecting all point-type entities present:

ogr2ogr -skipfailures -where “OGR_GEOMETRY=’POINT’ or OGR_GEOMETRY=’MULTIPOINT'” C:/test/points C:\test\2D7DK000.000

the second by selecting all line entities present:

ogr2ogr -skipfailures -where “OGR_GEOMETRY=’LINESTRING’ or OGR_GEOMETRY=’MULTILINESTRING'” C:/test/lines C:\test\2D7DK000.000

the third by selecting all polygon entities present:

ogr2ogr -skipfailures -where “OGR_GEOMETRY=’POLYGON’ or OGR_GEOMETRY=’MULTIPOLYGON'” C:/test/polygons C:/test\2D7DK000.000

The errors displayed correspond to one of the limitations of the shapefile format. Some S57 object attributes are in ‘list’ format, which does not exist in shapefile. Most of these are ‘category’ attributes. If you need these attributes, you need to transform the S57 files into a postgresql/postgis database. This possibility will not be discussed in this article. When the shapefile is created, the list attribute is simply ignored. The rest of the attributes that are not in list format are transformed without problem. The symbology will not be able to take into account the specific type of object, but will only use a generic symbol.

If you now look at the directory contents, you’ll see that the shapes have been created.

So you have up to 73 point-type shape files, 45 line-type shape files and 89 polygon-type shape files, but still no symbology for QGis. The number of shapes depends on the objects present in the map you are processing. If an object type is not present in an ENC file (.000), no shapefile is generated.

QGis symbology resources

You need to download a zip file containing

  • a large number of svg symbols that we have created and grouped together in a “nautical” directory. By default, we advise you to copy this directory to the root of the c: drive.
  • a QGis Project (version 3.34) named S57.qgs with the assignment of each symbol to each shape layer.

If you install the “nautical” directory in another location, you will need to edit the project file and replace all occurrences of C:/nautical with your path.

Keep the S57.qgs file in a safe place without any further modification. For each ENC card, copy it to the directory created with ogr2ogr. It is essential not to use it directly, as any modification, such as the absence of an object, will be memorized and you will no longer have this object on a future map.

To download the file, click here.

Display the ENC map in QGis with the appropriate symbology

Now all you have to do is copy the downloaded QGis project file, s567.qgs, into the directory with the shapes created in the previous step. Then load this project into QGis.

If any objects are missing from the map, you’ll see a window indicating which layers are missing:

missing objects in file S57

Click on the “Remove unusable layers” button and then on the “OK” button. You will then see the data with a nautical map symbology, after zooming in on the new map extent (the M_COVR layer corresponds to the map’s right-of-way).

You’ll notice that something is missing from your map: the soundings values. To add them, consult the article S57 marine maps with QGis: displaying soundings. In fact, to display them, it’s not enough to work on the symbology, as SOUNDG objects have the value of the depth in the geometry (XYZ).

Si cet article vous a intéressé et que vous pensez qu'il pourrait bénéficier à d'autres personnes, n'hésitez pas à le partager sur vos réseaux sociaux en utilisant les boutons ci-dessous. Votre partage est apprécié !

2 thoughts on “Displaying S57 nautical charts in QGis 3.X

  1. Very nice article. Thank you
    I always ask myself why the S57 are always converted to shapes, although the disadvantages of shapes are generally known (e.g. not all layers are convertible).
    I have good experience with converting S57 to SQLite, geopackage and geojson.
    My question is if you can provide appropriate qgs for these backends

    Regards
    BlackSea

    1. Hello,
      It took me a while to reply, as I was in the process of finalizing the project that answers your Geopackage question. The first part is published today, the second on Thursday morning.
      The next part of the project is to do the equivalent, but this time using PostrgreSQL/postgis.

Leave a Reply

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