Skip to main content

GeodataFlow backend implementation with GDAL/OGR library (OSGeo).

Project description

geodataflow.spatial

GeodataFlow backend implementation with GDAL/OGR library (OSGeo).

GeodataFlow is a Geoprocessing framework for fetching, translating and manipulating Geospatial data (Raster, Vector, EO/STAC collections) by using a Pipeline or sequence of operations on input data. It is very much like the GDAL library which handles raster and vector data.

The project is split up into several namespace packages. geodataflow.spatial implements a backend for GeodataFlow using the GDAL/OGR library and other common OSGeo python packages. This package includes the geodataflow.core subpackage.

Although geodataflow.spatial provides a list of useful modules, since Backend implementations for GeodataFlow load them using the paradigm of plugins, developers can easily write new operations and the list may grow up in the future.

Workflow examples

Assuming you are using geodataflow.spatial (GDAL/OGR) as active backend implementation, GeodataFlow can run workflows as the following:

  • Converting a Shapefile to GeoPackage:

    # ==============================================================
    # Pipeline sample to convert a Shapefile to GeoPackage.
    # ==============================================================
    {
      "pipeline": [
        {
          "type": "FeatureReader",
          "connectionString": "input.shp"
        },
        # Extract the Centroid of input geometries.
        {
          "type": "GeometryCentroid"
        },
        # Transform CRS of geometries.
        {
          "type": "GeometryTransform",
          "sourceCrs": 4326,
          "targetCrs": 32630
        },
        # Save features to Geopackage.
        {
          "type": "FeatureWriter",
          "connectionString": "output.gpkg"
        }
      ]
    }
    
  • Fetching metadata of a S2L2A Product (STAC):

    # ==============================================================
    # Pipeline sample to fetch metadata of a S2L2A Product (STAC).
    # ==============================================================
    {
      "pipeline": [
        {
          "type": "FeatureReader",
    
          # Define the input AOI in an embedded GeoJson.
          "connectionString": {
            "type": "FeatureCollection",
            "crs": {
              "type": "name",
              "properties": { "name": "EPSG:4326" }
            },
            "features": [
              {
                "type": "Feature",
                "properties": { "id": 0, "name": "My AOI for testing" },
                "geometry": {
                  "type": "Polygon",
                  "coordinates": [[
                      [-1.746826,42.773227],
                      [-1.746826,42.860866],
                      [-1.558685,42.860866],
                      [-1.558685,42.773227],
                      [-1.746826,42.773227]
                  ]]
                }
              }
            ]
          }
        },
        # Transform CRS of geometries.
        {
          "type": "GeometryTransform",
          "sourceCrs": 4326,
          "targetCrs": 32630
        },
        # Fetch metadata of EO Products that match one SpatioTemporial criteria.
        {
          "type": "EOProductCatalog",
    
          "driver": "STAC",
          "provider": "https://earth-search.aws.element84.com/v0/search",
          "product": "sentinel-s2-l2a-cogs",
    
          "startDate": "2021-09-25",
          "endDate": "2021-10-05",
          "closestToDate": "2021-09-30",
          "filter": "",
    
          "preserveInputCrs": true
        },
        # Save features to Geopackage.
        {
          "type": "FeatureWriter",
          "connectionString": "output.gpkg"
        }
      ]
    }
    

Installation

In order to read and write Cloud Optimized Geotiffs (COG), GDAL version 3.1 or greater is required. If your system GDAL is older than version 3.1, consider using Docker or Conda to get a modern GDAL.

Using pypi

To install the latest stable version from pypi, write this in the command-line:

> pip install geodataflow.spatial[eodag,gee]

Optional extras:

  • eodag

    EODAG - Earth Observation Data Access Gateway is a Python package for searching and downloading remotely sensed images while offering an unified API for data access regardless of the data provider.

    Installing this extra EODAG adds access to more EO Products from different providers to EOProductCatalog and EOProductDataset modules.

  • gee

    GEE - Google Earth Engine API is a geospatial processing service. With Earth Engine, you can perform geospatial processing at scale, powered by Google Cloud Platform. GEE requires authentication, please, read available documentation here.

    Installing this extra GEE makes possible the access to Google Cloud Platform to GEEProductCatalog and GEEProductDataset modules.

To view all available CLI tool commands and options:

> geodataflow --help

Listing all available modules:

> geodataflow --modules

Run a workflow in the command-line interface:

> geodataflow --pipeline_file "/geodataflow/spatial/tests/data/test_eo_stac_catalog.json"

Using docker

Building the container with:

> docker build -f ./Dockerfile.spatial -t geodataflow/cli:1.0.0 .

Getting start:

> docker run --rm --name gdf geodataflow/cli:1.0.0 --help
> docker run --rm --name gdf geodataflow/cli:1.0.0 --modules

Creating an interactive bash shell:

> docker run --rm -it --entrypoint "bash" geodataflow/cli:1.0.0

To run workflows in Linux:

> docker run \
    --rm --name gdf -v "$PWD/geodataflow/spatial/tests/data:/tests/data" geodataflow/cli:1.0.0 \
    --pipeline_file "/tests/data/test_eo_stac_catalog.json"

To run workflows in Windows:

> docker run ^
    --rm --name gdf -v "%cd%/geodataflow/spatial/tests/data:/tests/data" geodataflow/cli:1.0.0 ^
    --pipeline_file "/tests/data/test_eo_stac_catalog.json"

Contribute

Have you spotted a typo in our documentation? Have you observed a bug while running GeodataFlow? Do you have a suggestion for a new feature?

Don't hesitate and open an issue or submit a pull request, contributions are most welcome!

License

GeodataFlow is licensed under Apache License v2.0. See LICENSE file for details.

Credits

GeodataFlow is built on top of amazingly useful open source projects. See NOTICE file for details about those projects and their licenses.

Thank you to all the authors of these projects!

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

geodataflow.spatial-0.2.1.tar.gz (52.6 kB view details)

Uploaded Source

Built Distribution

geodataflow.spatial-0.2.1-py3-none-any.whl (98.5 kB view details)

Uploaded Python 3

File details

Details for the file geodataflow.spatial-0.2.1.tar.gz.

File metadata

  • Download URL: geodataflow.spatial-0.2.1.tar.gz
  • Upload date:
  • Size: 52.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.1 CPython/3.9.12

File hashes

Hashes for geodataflow.spatial-0.2.1.tar.gz
Algorithm Hash digest
SHA256 87afbc5aec53372d70733c31675dd5046eef7a87c62aaa77d240eb41b5443afd
MD5 c725c314db7d721de8bc6009f2eac7bc
BLAKE2b-256 1c6ca614ca4f336b2b13c75726390a6b02161acbb327ef3db5d7a5915099c248

See more details on using hashes here.

File details

Details for the file geodataflow.spatial-0.2.1-py3-none-any.whl.

File metadata

File hashes

Hashes for geodataflow.spatial-0.2.1-py3-none-any.whl
Algorithm Hash digest
SHA256 76c95fe0d944727d94a672fe9b3bacf50437881a6f43ec1349545eeb0bda9cc0
MD5 1be7b2887f7a237cdd2a4b2e7fc04be5
BLAKE2b-256 ce9f8f5741acf8f7c5ec968c7ad8128b48a21f57c151951aac9843dffb2e07f4

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page