Skip to content

LoloGruber/fishnet

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Fishnet

Framework for Graph-Based Analysis of GIS Vector Data

Table of Contents

Workflows

Settlement Delineation and Analysis (SDA)

Delineate urban clusters using a settlement graph and edge contraction and then analyze the centrality of the aggregated settlement clusters.

.

Deployment

To run the Settlement Delineation and Analysis workflow, the easiest way is to use SettlementDelineationAnalysis.py, which wraps the command line interface of the main binary and executes it in a container using docker (which has to be installed in the deployment environment).

python3 SettlementDelineationAnalysis.py -i <input> -c <config>.json -o <output>.shp
  • input: Input GIS file (GeoTIFF | Shapefile) on settlement location (e.g. WSF)
  • config: JSON file containing the config for the workflow run (e.g. Example Config )
  • output: Path of output shapefile

Development

Alternatively the SDA workflow can be installed on the system using the install script. Make sure that the install prefix location is referenced in PATH (e.g. usr/local/bin).

./install.sh

Additionally, a cwl runner must be installed to execute the individual stages of the workflow. The reference executor cwltool is recommended and can be installed as follows:

sudo apt-get install cwltool

Furthermore, a running instance of the Memgraph database joined with the Memgraph Lab web interface can be obtained using docker compose:

cd prod/database
docker compose up -d

The workflow can then be executed as follows:

SettlementDelineation -i <path-to-input> -c <path-to-cfg> -o <path-to-output.shp>

Africapolis (WiP)

In contrast, the Africapolis Workflow is completely orchestrated with the Common Workflow Language (CWL), with each stage being a command line program, composed using Fishnet.

Installation

The required binaries of Africapolis currently have to be manually install on the system. This can be achieved with the install script. Make sure that the install prefix location ($INSTALL_PREFIX) is referenced in PATH (e.g. usr/local/bin).

./install.sh

Additionally, a CWL Runner must be installed to execute the workflow. The reference executor cwltool is recommended and can be installed as follows:

sudo apt-get install cwltool

Running the Workflow

cwltool Africapolis.cwl <CWL-Job>.json

Framework

Architecture

The core framework contains generic components for the following domains:

Installation

Before the library can be build using cmake, the GDAL and SSL libraries have to be installed on the machine. On Ubuntu-based system this can be achieved using the following command:

sudo apt-get install -y libgdal-dev libssl-dev

Then the project can be build as follows:

mkdir build
cd build
cmake ..
cmake --build . <add custom cmake parameters here>

Framework Usage

The following example shows how to store polygons, obtained from a Shapefile, in a graph. Thereafter, the degree centrality measures is calculated on the graph and the results stored as features in the output shapefile.

#include <fishnet/Fishnet.hpp>

using namespace fishnet;

int main() {
    using G = geometry::Polygon<double>;
    Shapefile input {"/path/to/file.shp"};
    auto inputLayer = VectorIO::read<G>(input);
    auto polygons = inputLayer.getGeometries();
    // scale aaBB of polygon by this factor; intersecting buffers -> adjacent
    double bufferMultiplier = 2; 
    size_t maximumNumberOfNeighbours = 5;
    auto adjacencies = geometry::findNeighbouringPolygons(polygons,bufferMultiplier,maximumNumberOfNeighbours);
    auto polygonGraph = graph::GraphFactory::UndirectedGraph<G>();
    polygonGraph.addEdges(adjacencies);
    // copy spatial reference from input layer
    auto resultLayer = VectorLayer<G>(inputLayer.getSpatialReference());
    auto degreeCentralityField = resultLayer.addSizeField("degCent").value_or_throw();
    for(const G & polygon: polygonGraph.getNodes()){
        Feature<G> feature {polygon};
        auto degreeCentrality = fishnet::util::size(polygonGraph.getNeighbours(polygon));
        feature.addAttribute(degreeCentralityField,degreeCentrality);
        resultLayer.addFeature(std::move(feature));
    }   
    Shapefile output = input;
    output.appendToFilename("_degree_centrality") ;
    VectorIO::overwrite(resultLayer, output);
}

To link the Fishnet framework to the program the following CMake file can be used:

add_executable(polygonGraph PolygonGraph.cpp)
target_link_libraries(polygonGraph PRIVATE Fishnet::Fishnet)

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published