Package: seacharts
SeaChartsPython-based API for Electronic Navigational Charts (ENC)FeaturesRead and process spatial depth data fromFileGDBfiles into
shapefiles.Access and manipulate standard geometric shapes such as points and polygon
collections.Visualize colorful seacharts features and vessels.Code styleThis module follows thePEP8convention for Python code.Roadmap1: Add better compatibility for all operating systems (Windows, Linux++). Right
now, GDAL and Cartopy are problematic to install on most platforms.
Consider finding other packages for map loading and charts projections.2: Add support for multiple map data formats (.gis, .gdb, .json) from any region in
the world, in all UTM zones or lat/lon coordinates.3: Use another plotting framework that has higher refresh rate or is feasible for
real-time (Qt?, React?).4: Add options for plotting trajectories, ships, traffic information/AIS data etc.
on the frontend display.5: Add support for reading and loading in weather data (wind and current
maps++) from a separate module.PrerequisitesLinux (Virtual Environment)First, ensure that you have the GDAL and GEOS libraries installed, as these are
required in order to successfully install GDAL and Cartopy:sudo apt-get install libgeos-dev libgdal-devFrom the root folder, one may then install an editable version of the package as
follows:pip install -e .This should preferably be done inside a virtual environment in order to prevent
Python packaging conflicts.AnacondaInstall an edition of theAnacondapackage manager, and then create a newconda environmentwithPython 3.11or higher using e.g. the
graphical user interface ofPyCharm Professionalas detailedhere.The required data processing libraries for spatial calculations and
visualization may subsequently be installed simply by running the following
commands in the terminal of your chosen environment:conda install -c conda-forge fiona cartopy matplotlib
conda install matplotlib-scalebar cerberys pyyamlWindows (Pipwin)First, ensure thatPython 3.11or higher
is installed. Next, install all required packages usingPipwin:python -m pip install --upgrade pip
pip install wheel
pip install pipwin
pipwin install numpy
pipwin install gdal
pipwin install fiona
pipwin install shapely
pip install cartopy
pip install pyyaml
pip install cerberus
pip install matplotlib-scalebarSimply copy and paste the entire block above (including the empty line) into
the terminal of your virtual environment, and go get a cup of coffee while it
does its thing.InstallationAfter the necessary dependencies have been correctly installed, the SeaCharts
package may be installed directly through the Python Package Index (PyPI) by running the following command in the terminal:pip install seachartsor locally inside the SeaCharts root folder as an editable package withpip install -e .UsageThis module supports reading and processingFGDBfiles for sea depth data,
such as the Norwegian coastal data set used for demonstration purposes, foundhere.Downloading regional datasetsTo visualize and access coastal data of Norway, follow the above link to download
theDepth data(Sjøkart - Dybdedata) dataset from theNorwegian Mapping Authorityby adding
it to the Download queue and navigating to the separatedownload page. Choose one or more
county areas (e.g.Møre og Romsdal), and select theEUREF89 UTM sone 33, 2d(UTM zone 33N) projection andFGDB 10.0format. Finally, select your appropriate user group and purpose, and clickDownloadto obtain the ZIP file(s).Configuration and startupUnpack the downloaded file(s) and place the extracted.gdbin a suitable location,
in which the SeaCharts setup may be configured to search. The current
working directory as well as the relativedata/anddata/db/folders are
included by default.The minimal example below imports theENCclass fromseacharts.encwith the
default configuration found inseacharts/config.yaml, and shows the interactive
SeaCharts display. Note that at least one database with spatial data (e.g.Møre og Romsdalfrom the Norwegian Mapping Authority) is required.if__name__=='__main__':fromseacharts.encimportENCenc=ENC()enc.display.show()Theconfig.yamlfile specifies which file paths to open and which area to load.
The correspondingconfig_schema.yamlspecifies how the required setup parameters
must be provided, usingcerberus.API usage and accessing geometric shapesAfter the spatial data is parsed into shapefiles during setup, geometric
shapes based on theShapelylibrary may be
accessed and manipulated through variousENCattributes. The seacharts
feature layers are stored inseabed,shoreandland.if__name__=='__main__':fromseacharts.encimportENC# Values set in user-defined 'seacharts.yaml'# size = 9000, 5062# center = 44300, 6956450enc=ENC("seacharts.yaml")print(enc.seabed[10])print(enc.shore)print(enc.land)enc.display.show()Note how custom settings may be set in a user-defined .yaml-file, if its path is
provided to the ENC during initialization. One may also import and create an
instance of theseacharts.Configdataclass, and provide it directly to the ENC.Environment visualizationTheENC.start_displaymethod is used to show a Matplotlib figure plot of the
loaded sea charts features. Zoom and pan the environment view using the mouse
scroll button, and holding and dragging the plot with left click, respectively.Dark mode may be toggled using thedkey, and an optional colorbar showing
the various depth legends may be toggled using theckey. Images of the
currently shown display may be saved in various resolutions by pressing
Control +s, Shift +sors.LicenseThis project uses theMITlicense.MIT LicenseCopyright (c) 2021 Simon BlindheimPermission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.