Using our Python library, the Geo Engine can be integrated into Python projects and Jupyter notebooks. This results in a variety of possibilities. Available data sets and calculation results of the Geo Engine, can be used in Python as GeoPandas Dataframes and Numpy Arrays. Complex calculations such as data preparation and data enrichment can be outsourced to the Geo Engine. Special algorithms can then be developed or reused in Python. This allows the Geo Engine to be seamlessly integrated into your data science workflows.

Installation

The installation is done using a PyPI package:

  • Optional: Create a new Python project and a Python virtual environment medium python3 -m venv env and activate it by source env/bin/activate
  • Install the geoengine package with pip install geoengine
  • Start the Python console or a Jupyter notebook (optional: select the kernel of the virtual environment you are creating)
  • Include the package using import geoengine as ge

Demo

First we import the used packages

import geoengine as ge
from datetime import datetime

Then the connection to a (local) Geo Engine is initialized. To use an instance provided by us, feel free to contact us.

ge.initialize("http://localhost:3030")

The workflow is defined as JSON (or alternatively via an ID that can be copied in the web UI via the layer context menu):

workflow = ge.register_workflow({
    "type": "Vector",
    "operator": {
        "type": "RasterVectorJoin",
        "params": {
                "names": ["NDVI"],
                "aggregation": "none"
        },
        "sources": {
            "vector": {
                "type": "OgrSource",
                "params": {
                    "dataset": {
                        "type": "internal",
                        "datasetId": "a9623a5b-b6c5-404b-bc5a-313ff72e4e75"
                    },
                    "attributeProjection": None
                }
            },
            "rasters": [{
                "type": "GdalSource",
                "params": {
                    "dataset": {
                        "type": "internal",
                        "datasetId": "36574dc3-560a-4b09-9d22-d5945f2b8093"
                    }
                }
            }]
        },
    }
})

The result is retrieved using a method from the geoengine package. Vector data is loaded from Geo Engine via WFS:

time = datetime.strptime('2014-04-01T12:00:00.000Z', "%Y-%m-%dT%H:%M:%S.%f%z")

data = workflow.get_dataframe(
    ge.Bbox(
        [-111.533203125, -4.482421875, 114.345703125, 73.388671875],
        [time, time]
        )
    )

Subsequently, the data can be visualized, for example:

data.plot('NDVI', figsize=(16, 8));

Summary

Our library allows to integrate the Geo Engine via Python into Data Science work.

  • The installation is done manually or via pip
  • Workflows can be defined in Python and calculated by the Geo Engine
  • Results can be used in Python e.g. as GeoPandas dataframes