Skip to content

LoloGruber/fishnet

Repository files navigation

Fishnet

Framework for Graph-Based Analysis of GIS Vector Data

Table of Contents

Workflows

Settlement Delineation and Analysis (SDA)

The SDA workflow is now developed in a separate repository.

Africapolis

The Africapolis workflow is now developed in a separate repository

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

Framework for Graph-based Analysis of GIS Vector Data

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages