Concept • Installation • Example • Testing
Covjsonkit is an ECMWF library for encoding and decoding coverageJSON files/objects of meteorlogical features such as vertical profiles and time series.
- Encodes and decodes CoverageJSON objects
- Convert CoverageJSON files to and from xarray
- Works in conjunction with ECMWFs Polytope feature extraction library
Current features implemented:
- Time Series
- Vertical Profile
- Bounding Box
- Frame
- Path
- Wkt Polygons
- Shapefiles
Install the covjsonkit with Python 3 (>=3.7) from GitHub directly with the command
python3 -m pip install git+ssh://git@github.com/ecmwf/covjsonkit.git@develop
or from PyPI with the command
python3 -m pip install covjsonkit
The library consists of an encoder and a decoder element. The decoder can be used to decode valid coverageJSON files that can be then be edited and accessed via the api. It can also be used to convert to ther formats such as xarray.
from covjsonkit.api import Covjsonkit
decoder = Covjsonkit().decode(coverage.covjson)
print(decoder.type)
print(decoder.parameters)
print(decoder.get_referencing())
ds = decoder.to_xarray()
The following example encodes data output from the polytope feature extraction library assuming polytope_output is a valid output from polytope.
from covjsonkit.api import Covjsonkit
encoder = Covjsonkit().encode("CoverageCollection", "BoundingBox")
res = encoder.from_polytope(polytope_output)
Python unit tests can be run with pytest:
python -m pytest
When a pull request is merged into develop or main a github actions CI pipeline is triggered to test formatting and unit tests.