The project to integrate ENC maps into QGis in the form of Geopackage is now complete. This article completes the two previously published articles on ENC symbology in the Geopackage database.
Adding symbology to Geopackage
The default symbology of a geopackage’s tables is contained in a table named layer_styles, which is only created if you use the save default option of the style button.
After cloning the tables in the ENC file, the table does not exist. So we’re going to import the table containing all ENC map symbology.
Please note: the layer_styles table is a system table, unlike the natsurf table, which is a simple data table. Unlike data tables, system tables do not appear in the explorer panel. You need to use the QGis Database Manager (Database menu -> DB Manager) to view and manipulate system tables like layer_styles. Natsurf, on the other hand, can be viewed and manipulated like any other data layer.
This geopackage contains a table, named layer_styles, with symbology definitions for 153 S57 tables, as well as a table named natsurf, which will be used to format the rendering of the “nature of seabed” table (SBDARE).
To integrate these tables into your ENC file (here ENC.gpkg):
- Open the database manager in QGis.
- You should already have the geopackage->ENC.gpkg connection. If not, right-click on ‘Geopackage’->new connection, then point to your ENC.gpkg file.
- Connect to the downloaded layers_natsurf.gpkg table (right-click on ‘Geopackage’->new connection, then point to the downloaded geopackage)
- Select layer_styles in layers_natsurf.gpkg, then right-click->add to canvas, and you’ll have the layer_styles table in the list of loaded layers.
- Select natsurf in layers_natsurf.gpkg, then right-click->add to canvas, and you’ll have the natsurf table in the list of loaded layers.
- Select the ENC.gpkg geopackage in the database manager.
- In the Table menu, select Import layer/file.
- In the list of layers, select natsurf, then OK
- Repeat the operation for the layer_styles layer.
The current version of layer_styles contains symbology layouts for 153 layers. Check regularly for updates available for download.
This symbology uses svg symbols that you need to download to your machine. Clicking here will download a ‘nauticalV3’ file containing all the necessary svg symbols, as well as a directory named ‘XML’ with additional symbols for QGis.
To install the nautical directory, please refer to the article Creating a Geopackage database for ENC maps (part 2: adding symbology).
The layer_styles table contains the symbology of 153 layers, the usual layers for ENC files. However, there can be up to 210 possible layers. If, in your case, the layer_styles table does not contain one or more layers from your project, please refer to the article Updating(2) : ENC symbology with Geopackage under QGis for adding these missing symbologies from the .qml style files for all layers (V1, V2 and V3), which can be downloaded here.
Symbologies that change with this new version
The qml files contained in the qmlV3 directory are adapted to the updated processing chain, which not only retrieves primitives and assigns POSACC and QUAPOS values to the various S57 layers, but also to certain symbologies that have been specified. If you start with the V3 processing chain, you don’t need to do anything to set up these symbologies. They are defined by default in layer_stylesV3. If you’re migrating from a Geopackage V2 base to V3, please refer to the article Update(2) : Symbologie ENC avec Geopackage sous QGis for the addition of these missing symbologies from the .qml style files of all layers (V1, V2 and V3).
Soundg (bathymetric probes)
The following table shows the V3 symbology of the SOUNDG layer and the attribute values used to format it.
Obstrn (Obstructions)
The following table shows the V3 symbology of the OBSTRN (points) layer and the attribute values used to format it.
UWTROC (submerged / exposed rock)
The following table shows the V3 symbology of the UWTROC layer and the attribute values used to format it.
Wrecks
The following table shows the V3 symbology of the WRECKS layer and the attribute values used to format it.
DEPCNT (Bathymetric contours)
The new version of the symbology takes into account data quality (approximate isobaths).
Symbole | VALDCO | QUAPOS | Label |
---|---|---|---|
>=0 | Isobathes Depth contours |
||
<0 | Isobathe découvrante Drying contour |
||
4 ou 5 | Isobathes approchées Approximate depth contours |
COALNE (coastline)
A new category has been added: Unsurveyed when the QUAPOS attribute is 4 or 5. It is symbolized by a dashed line
LNDELV (contour lines)
Like isobaths, contour lines are now symbolized with a dashed line when the QUAPOS value is 4 or 5.
LNDMRK, SEAARE,UWTROC , LNDELV, OBSTRN, WRECKS(Point type)
The labels for the depth or elevation values of these layers take the QUAPOS value into account. They now have a PA (Approximate Position) prefix when QUAPOS has a value of 4 and a PD (Doubtful Position) prefix when QUAPOS has a value of 5.
SBDARE (nature of seabed)
The new symbology requires some special work. In earlier versions, we had set up a symbology that used the natsurf table to format the labels required for background types. The whole process was managed at the level of the label generation expression. While this solution was viable for a small number of maps in the database, the calculation times required for larger numbers became prohibitive.
For this final version, we opted for the implementation of a python script that generates a “Label” attribute in the SBDARE table. This attribute is used as a label and enables almost instantaneous display of the layer.
Load the pt_SBDARE layer and the natsurf table into your project.
Create the Label attribute in the pt_SBDARE table:
Open the attribute table -> Field calculator
Name the Label field, of type Text, and enter a default value of ”.
In the python console, load the Label_sbdare.py script, which you can download here.
Once executed, you’ll get the labels in the table’s Label attribute:
LIGHTS
The symbology of lights has been enriched. Three types of lights are now symbolized
- Sector lights
- Directional lights
- Main and secondary lights
For this last category, two types of representation are available
- ECDIS type with colored circles
- Paper map with colored symbols
The qmlV3 directory contains two symbology files for the Lights layer
- pt_lightsPoint.qml
- pt_lightsMultipoint.qml
The Lights table resulting from the V1 and V2 import process is of type Point. However, in order to retrieve primitives, modifications to the ogr2ogr command produce a Multipoint Lights layer. By default, the symbology of the layer_styles V3 table is Multipoint.
If you are working with a base with the Points type table, you can load the corresponding symbology and save it as the default symbology in layer_styles.
Both symbologies have been corrected by an angular deviation compared to previous versions. Working with layers in geographic coordinates means that latitudinal and longitudinal distances are not of a constant ratio. If a delta X and a delta Y have the same length on the equator, the further away you are from the equator, the more the delta X decreases in relation to the delta Y. To draw the lines of the sectors starting from the fire, we create a point at the same distance X and Y in the direction of the sector. To ensure that the resulting angle is that of the sector, apply a correction by multiplying by the tangent of the point’s latitude. The actual angles displayed in previous versions deviated by up to 10° from the value of the SECTR1 and SECTR2 attributes. The tangent(Latitude) correction is an approximation that reduces this deviation to around 1°.