Convert Canadian ice service (CIS) ESRI shapefiles to ascii format (dex).
CIS daily ice analysis charts (dailys) and regional analysis charts (weeklys) are collected every day on mixing and processed to provide information such as,
- Ice thickness maps.
- First occurence maps.
- Total gulf, Newfoundland shelf and Scotian Shelf ice volumes.
- Comparisons to climatology.
These analyses are performed by a combination of Perl/awk routines and are facilitated by first transforming the shapefiles to gridded ascii plain text in a format called dex, containing geographical coordinates and egg code data. Time information is carried by the file name (YYYYMMDD) and the columns in the file are ordered as follows,
- Longitude (west)
- Latitude
- Total ice concentration
- Partial ice concentration (thickest ice)
- Stage of developpment (thickest ice)
- Form of ice (thickest ice)
- Partial ice concentration (second thickest ice)
- Stage of developpment (second thickest ice)
- Form of ice (second thickest ice)
- Partial ice concentration (third thickest ice)
- Stage of developpment (third thickest ice)
- Form of ice (third thickest ice)
This module performs the conversion and is meant to be called from command line. Command line interface description can be shown by entering,
$ shp2dex -h
Create a virtual environment containing this package's dependencies. In conda
conda create -n shp2dex Python=3.12 pandas cartopy termcolor xarray pyproj ipython
should install all the appropriate dependencies. This is the recommended method for setting up a
virtual environment for shp2dex
, and has been tested on MacOs, Windows and Linux. Then,
navigate to the virtual environment's site-packages
directory and clone this git repository.
cd /path/to/anaconda/envs/shp2dex/lib/python3.12/site-packages
git clone https://github.com/jeanlucshaw/shp2dex.git shp2dex
For this utility to be available at the command line, add a
file called shp2dex
on your shell path, for example
at /usr/local/bin/
containing the following lines,
#!/path/to/bash
/path/to/python /path/to/shp2dex/shp2dex.py "$@"
To test the installation, run shp2dex -h
from the command line or run the included
examples of command-line and scripted use cases.
More background information can be found at the following links:
Have a look at
- example_python.py
- example_julien.py
which demonstrate use of this module as part of a Python script, and at
- example_shell.sh
which demonstrates how to use the module via its command line interface.
Although advantageous for software designed to ingest it, the .dex format can be cumbersome to integrate to new software because
it mixes string characters and numbers in some data columns, and has different numbers of columns accros its rows. To facilitate
the use of existing .dex file data bases, the dex2nc
module included in this package reads the .dex format into xarray
dataset objects.
Conversion to netCDF, a common format for the storage of raster data can then be performed via user scripts:
from shp2dex.dex2nc import dex2ds
ds = dex2ds('my_file_YYYYMMDD.dex')
ds.to_netcdf('my_file_YYYYMMDD.nc')
or using the module as a command line application
$ python /path/to/dex2nc.py /path/to/my_file_YYYYMMDD.dex
$ python /path/to/dex2nc.py /path/to/*.dex