Display electronic navigational charts

Electronic navigational charts (ENCs) are georeferenced vector datasets for the visualization and analysis of hydrographic and maritime information. ArcGIS Runtime supports ENCs that conform to the International Hydrographic Organization (IHO) S-57 standard. Use ENCs in your ArcGIS Runtime apps to:

  • Visualize S-57 data in compliance with S-52 standards and specifications for chart content display
  • Use S-57 data as an additional data source for situational awareness and decision making
  • Combine S-57 datasets with other sources of information for geospatial analysis

Get started

Before ENC data can be displayed in an application, you must add code to:

  • Set the path to the resource directory that contains the styles required to render the ENC data. The directory contents is available for download from developers.arcgis.com.
  • Set a location for the SENC data. The first time that ENC data is displayed it is processed and placed into the SENC directory. Subsequent displays of the ENC data will be faster because the data is already processed and is read directly from the SENC directory.
settings = AGSENCEnvironmentSettings.shared()
settings.resourceDirectory = URL(fileURLWithPath: "pathToHydrographyDirectory")
settings.sencDataDirectory = URL(fileURLWithPath: "pathToSENCDirectory")

Anatomy of an Electronic Navigational Chart (ENC)

An ENC cell represents a navigational chart of a rectangular geographic area at a particular scale. Cells are bounded by meridians and parallels, though the actual area of coverage contained in the cell may be any shape. All the data in a single cell corresponds to a single navigational use, such as overview, general, or coastal. (A navigational use corresponds to a scale range suitable for a particular use.)

Cells are stored in a single base dataset file and zero or more update dataset files. Each dataset file has a unique name. A base dataset file plus its update files (if any) when loaded together comprise the updated geographic data of one cell.

ENC data is distributed in exchange sets, which can contain many cells. On the file system, each exchange set resides in its own folder named ENC_ROOT. Each ENC_ROOT folder contains a collection of dataset files (*.000), update files (*.001-*.999), a catalog file containing metadata about the exchange set (CATALOG.031), and other optional files with data referenced by the exchange set, such as text and image files.

See S-57 Appendix B for additional details about S-57 ENC exchange sets and their content.

Display an electronic navigational chart

Access an exchange set on the file system using an object. An exchange set can be loaded using the path to the exchange set's CATALOG.031 file, and optionally the paths to CATALOG.031 files in other exchange sets (in other folders) that contain additional update dataset files. If an exchange set that only contains update dataset files is one of those specified, then the exchange set with the corresponding base dataset files must be loaded simultaneously. See the topic section Working with updates for more information.

AGSENCDataset objects represent datasets. Each AGSENCDataset contains the base data for a cell and any updates that were also loaded when the exchange set was loaded, and provides access to metadata about the cell. Retrieve a collection of AGSENCDataset objects contained in an AGSENCExchangeSet using the datasets property.

ENC cells (individual charts) are represented by AGSENCCell objects. You can construct these objects in two ways:

  • From a dataset represented by an AGSENCDataset object. This approach will include the base dataset file and all corresponding update dataset files. This is the preferred approach.
  • From a base dataset file. This approach will only include the base dataset file, and not any corresponding update dataset files. This is not a typical use case.

Display an ENC cell by constructing an AGSENCLayer object from an AGSENCCell object. AGSENCLayer is derived from AGSLayer, so you add an AGSENCLayer to a map like you do other layers.

You can add all the charts in the exchange set by iterating through the exchange set's datasets, creating an AGSENCCell for each, creating an AGSENCLayer for each AGSENCCell, and adding each AGSENCLayer to the map.

// create an exchange set
let catalogURL = URL(fileURLWithPath: "pathToENCData/CATALOG.031")
encExchangeSet = AGSENCExchangeSet(fileURLs: [catalogURL])
//load the exchange set
self.encExchangeSet.load {[weak self] (error) in
    if let error = error {
        print("Error loading exchange dataset \(error.localizedDescription)")
        return
    }
    //Loop through the exchange set datasets
    self?.encExchangeSet.datasets.forEach {(dataset) in
        //create the ENC Cell from the dataset
        let encCell = AGSENCCell(dataset: dataset)
        // create the ENC layer
        let encLayer = AGSENCLayer(cell: encCell)
        encLayer.name = dataset.name
        // add the ENC layer to the map
        self?.map.basemap.baseLayers.add(encLayer)
    }
}

Working with updates

ENC charts are often distributed as base cells (.000 files) with one or more update cells (.001, .002, etc. files). An exchange set can consist exclusively of update cells; in order to load an update exchange set, the path to the base exchange set must be provided simultaneously.

let pathToOriginal = URL(fileURLWithPath: "pathToOriginalDirectory")
let pathToUpdate = URL(fileURLWithPath: "pathToUpdateDirectory")
 let encExchangeSetUpdate = AGSENCExchangeSet(fileURLs: [pathToOriginal, pathToUpdate])

When loading an ENC cell, it is important to use the dataset-based constructor. If updates for a cell are part of an exchange set, they will only be found by the runtime when the dataset-based constructor is used. Loading the cell from a path will not load any associated updates.

Set ENC environment settings

ENC layers are displayed in accordance with the IHO S-52 standard. You can define the display properties of your ENC layers by using the static AGSEncEnvironmentSettings class. These settings apply to all ENC layers in all maps. Settings fall under three categories: mariner settings, text group visibility settings, and viewing group settings. Text group settings control the display of labels for features, mariner settings control the symbolization and presentation of ENC features, and viewing group settings allow for quickly applying settings to logical groups of feature types.

settings.displaySettings.textGroupVisibilitySettings.natureOfSeabed = true

Runtime’s ENC implementation works with ENC content via compiled SENC files. SENC is an acronym for System Electronic Navigational Chart. After an ENC cell has been loaded, all future loads of that cell will reference the underlying SENC file directly. You can use the SENCDataDirectory property of the environment settings to find or set the location where SENC files are stored.

Identify and select ENC features

ENC layers support identify through the common geoview feature identification mechanism, which takes a screen point and tolerance in pixels. Identify will return a collection of AGSIdentifyLayerResult objects, one per matching layer. For ENC layers, the results will have a geoElements property, which is a collection of AGSEncFeatures.

Once a feature has been identified, you can call select on the layer that contains the feature to select it.

func geoView(_ geoView: AGSGeoView, didTapAtScreenPoint screenPoint: CGPoint, mapPoint: AGSPoint) {
         self.mapView.identifyLayer(self.encLayer, screenPoint: screenPoint, tolerance: 12, returnPopupsOnly: false, maximumResults: 10) { (identifyLayerResult: AGSIdentifyLayerResult) -> Void in
        //check for errors and ensure identifyLayerResult is not nil
        if let error = identifyLayerResult.error {
            print(error)
            return
        }
        // get the layer identified and cast it to an ENC Layer
        if let theENCLayer = identifyLayerResult.layerContent as? AGSENCLayer {
            // iterate each identified GeoElement in the results
            for geoElement in identifyLayerResult.geoElements
            {
                // select the ENC feature in the ENC layer
                if let theENCFeature = geoElement as? AGSENCFeature {
                    theENCLayer.select(theENCFeature)
                                     }
            }
        }
    }
}

Performance Considerations

Runtime works with ENC content via internal SENC files. When an ENC cell is loaded, an SENC representation is generated. Subsequent loads only read the generated SENC files. When developing Runtime apps for working with ENC content, understand that:

  • The SENC data path must be set before attempting to read ENC content.
  • SENC files are device- and version-specific. These files should not be exposed to users, backed up, or shared between devices. The SENC format is internal to Runtime and may change between versions. On iOS, consider setting the SENC path to a subdirectory of the documents directory that is excluded from iCloud and iTunes backup. See Apple Technical Q&A QA1719 for more information about excluding iOS directories from backup.
  • SENC files take time to generate - this will delay the loading of new ENC cells. It may take a long time to load large ENC exchange sets consisting of many cells - potentially hours. Never block the UI when loading these files.
  • Because the initial load of an ENC cell (before the SENC files have been generated) can take some time to complete, consider pre-loading them to ensure availability before depending on them for navigation.
  • Do not attempt to read or manipulate SENC files. Changes to generated SENC files will invalidate them, requiring Runtime to re-generate them the next time the corresponding cells are loaded.