Gaia Density Computations Example

This document contains an example of the Gaia Density Computations plugin.

The original Python notebook is available in the plugin source code under the docs/examples folder.

In [1]:
# Import required modules
import folium
import numpy as np
from folium.plugins import ImageOverlay
from gaia_densitycomputations.processes import SimpleGridDensityProcess
from gaia.geo.geo_inputs import VectorFileIO

Create a SimpleGridDensityProcess instance to determine number of points within each cell of a 200 column x 100 row grid, covering the same geographic extent as the input layer.

In [2]:
# Point dataset to calculate density of
ports = VectorFileIO(uri='../../tests/data/ports_and_harbours.geojson')

# Grid resolution to use for density calculation
resolution = {
        "nCol": 200,
        "nRow": 100
}

# Create an instance of the Simple Density Process
sdp = SimpleGridDensityProcess(inputs = [ports], resolution=resolution)

Compute the least cost path

In [3]:
sdp.compute()

Display the density on a map

In [5]:
world_map = folium.Map([50,-90],
                  zoom_start=4,
                  tiles='cartodbpositron')

temparray = np.array(sdp.output.read().GetRasterBand(1).ReadAsArray())
overlay = ImageOverlay(temparray, [[-90.0,-180.0],[90.0,180.0]], mercator_project=True, control=True)
overlay.layer_name = 'Port Density'

world_map.add_children(overlay)

folium.LayerControl().add_to(world_map)
world_map
Out[5]:
In [ ]: