2. Develop a first model

This little land cover change model is to show how to use some basic functions of Ocelet. As often, we proceed in steps, incrementally. At each intermediate step, the model is incomplete but is able to run.

Create a new project (e.g. Fournaise) with the button. A new subfolder is created in the "workspace" folder. A Shapefile will be needed in "..\workspace\Fournaise\data" and can be obtained after unzipping the following file (AgPlots_Fournaise.zip).

Read entities from a Shapefile and write them in a Kml file

Define the "Agricultural Plot" entity

First, we need to define the entity type used in the model: PlotAg (Agricultural Plot).

This definition is done in the "Fournaise.oclt" file located in "..\workspace\Fournaise\oclt", either before or after (but not inside) the scenario definition:

Note that together with the path to the Shapefile, we give an EPSG code that defines the spatial reference system. The match PlotAg part defines how the Shapefile attribute data are read into the property of entities.

Use the entities and the datafacers in a scenario

A service must now be added to the definition of the PlotAg entity so that they can be written in the Kml file,

In "..\workspace\Fournaise\output" you will find the resulting Kml: Fournaise_LandCover.kml

Add a land cover change process and simulate over a period of 10 years

We can now include a land cover change process. Inspired by the Game of Life, the land cover of a plot is modified according to those of neighbouring plots.

Define a neighbourhood relation between plots

The neighbourhood relation defined below contains a filter, an interaction and an aggregation function.

The filter function near with the input parameter dist will keep those edges with a distance between the geometries of plots p1 and p2 less than dist in the condition (p1.geom.distance(p2.geom)< dist. The first condition p1.geom.envelope.distance(p2.geom.envelope) < dist is quicker and will screen out of the test the pairs of geometries whose envelopes are already not close enough.

The interaction function changeLC is meant to be applied on each of the edges of the graph. A plot then takes the land cover type lct of its neighbour. As a plot normally has many neighbours, an aggregation function is defined to decide which lct value is assigned to the plot property. Here a user-defined Majority function will choose the most frequent lct among the possible values. But if the selected lct is “too present”, a random value is chosen instead.

The neighbourhood relation can then be used in the scenario. A graph gN is instantiated with all the agricultural plots included but unconnected.

gN.complete.near(20).connect()

In the above instruction, the near filter is applied to the complete graph, and those agricultural plots that are neighbours less than 20 m apart are connected.

The land cover change function is also applied in the scenario, at each time step, once the states of the agricultural plots are saved in the output files.

for (year : 2014..2024) {
println(year)
// Write land cover state in kml file
for (p:lplotAg) {
p.outputKml(year, kmln) // write to Kml for each PlotAg of the list
}
// Change land cover according to neighbourhood
gN.changeLC()
}

3. Visualize model outputs

From the scenario above we have seen how the states of the agricultural plots are sent to a kml file at each time step in order to visualize changing land cover types with Google Earth.

Another possibility of displaying animated maps is with QGIS provided the time manager plugin is installed. Time attributes must be added to the agricultural plots before being sent to the output shapefile.