Global geometry processing utilities for GeoJSON-safe WGS84 polygons.
To install Polar to WGS84 Converter, run this command in your terminal:
$ pip install git+https://gitlab.cnes.fr/pdssp/common/polar2wgs84.gitThis is the preferred method to install Polar to WGS84 Converter, as it will always install the most recent stable release.
If you don't have pip installed, this Python installation guide can guide you through the process.
To manage the dependencies of Polar to WGS84 Converter, we use [UV](https://docs.astral.sh/uv/). If you don't have UV installed, follow these steps:
-
Install UV:
$ curl -LsSf https://astral.sh/uv/install.sh | sh -
Verify the installation:
$ uv --version
Please note that this project has been tested with UV version 0.9.15.
The sources for Polar to WGS84 Converter can be downloaded from the Gitlab repo.
You can either clone the public repository:
$ git clone https://gitlab.cnes.fr/pdssp/common/polar2wgs84.gitOr download the tarball:
$ curl -OJL https://gitlab.cnes.fr/pdssp/common/polar2wgs84/tarball/mainOnce you have a copy of the source, you can install it with:
$ make # install$ git clone polar2wgs84.git
$ cd polar2wgs84
$ make prepare-dev
$ source .venv/bin/activate
$ make install-devTo get more information about the preconfigured tasks:
$ make helpTo use Polar to WGS84 Converter in a project:
from polar2wgs84 import Footprint
from shapely import Polygon
# Define the vertices of your spherical polygon as a list of (longitude, latitude) tuples.
# Example: A polygon with 4 vertices (e.g., a rectangle near the North Pole).
polygon_vertices = [
(longitude_1, latitude_1), # First vertex
(longitude_2, latitude_2), # Second vertex
(longitude_3, latitude_3), # Third vertex
(longitude_4, latitude_4), # Fourth vertex
(longitude_1, latitude_1), # Close the polygon by repeating the first vertex
]
# Create a Shapely Polygon from the vertices
polygon = Polygon(polygon_vertices)
# Instantiate the Footprint class with the polygon
footprint = Footprint(polygon)
# Convert the polygon to a valid GeoJSON-compatible geometry.
# This ensures the geometry is either a Polygon or MultiPolygon,
# which are the only types supported by the GeoJSON standard.
valid_geom = footprint.make_valid_geojson_geometry()
# Interpolate the geometry to the Plate Carrée (CAR) projection (EPSG:4326)
# and simplify it to reduce complexity while preserving its shape.
# This is useful for visualization and further processing.
simplified_valid_geom = footprint.to_wgs84_plate_carre(valid_geom)
# Additional arguments can be provided to control polygon densification and geometry simplification.With command line:
$ polar2wgs84 -h
To run automatic tests
$make testsTo run manual tests
pytest -m "manual" -sThe documentation is automatically deployed on https://pdssp.io.cnes.fr/polar2wgs84 based on main branch
A container is automatically created on https://gitlab.cnes.fr/pdssp/common/polar2wgs84/container_registry
👤 Jean-Christophe Malapert
Contributions, issues and feature requests are welcome!<br />Feel free to check [issues page](https://gitlab.cnes.fr/pdssp/common/polar2wgs84/issues). You can also take a look at the [contributing guide](https://gitlab.cnes.fr/pdssp/common/polar2wgs84/blob/main/CONTRIBUTING.rst)
This project is [Apache V2.0](https://gitlab.cnes.fr/pdssp/common/polar2wgs84/blob/main/LICENSE) licensed.