Framework for Graph-Based Analysis of GIS Vector Data
The SDA workflow is now developed in a separate repository.
The Africapolis workflow is now developed in a separate repository
The core framework contains generic components for the following domains:
- Graph Model and Traversal
- Geometry Model and Sweep Line Algorithms
- I/O for GIS files and Vector Datasets
- Workflow Orchestration and Utility
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-devThen the project can be build as follows:
mkdir build
cd build
cmake ..
cmake --build . <add custom cmake parameters here>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)