MCPcopy Index your code
hub / github.com/carderne/gridfinder

github.com/carderne/gridfinder @v3.1.2

Chat with this repo
repository ↗ · DeepWiki ↗ · release v3.1.2 ↗ · + Follow
38 symbols 135 edges 9 files 18 documented · 47% updated 17mo agov3.1.2 · 2024-04-16★ 75
What it actually does AI analysis from the code graph — generated when you open this
loading…
README

gridfinder

gridfinder uses night-time lights imagery to as an indicator of settlements/towns with grid electricity access. Then a minimum spanning tree is calculated for these connect points, using a many-to-many variant Dijkstra algorithm and using existing road networks as a cost function. Adapted from this work from Facebook. Currently gridfinder only uses road networks, but it would be trivial to add other cost parameters such as slope or terrain.

The algorithm looks as follows in process, guessing the grid network for Uganda:

Animated algorithm

Input requirements

gridfinder requires the following data sources: - VIIRS data, monthly and annual composites available here. - OSM highway data, most easily available using the HOT Export Tool, otherwise geofabrik

Model usage

To get to grips with the API and steps in the model, open the Jupyter notebook example.ipynb. This repository includes the input data needed to do a test run for Burundi, so it should be a matter of openening the notebook and running all cells.

Installation

Install with pip

pip install gridfinder

Note: On some operating systems (Ubuntu 18.04), you may get an error about libspatialindex. To overcome this on Ubuntu, run:

sudo apt install libspatialindex-dev

Development

Download or clone the repository and install the required packages (preferably in a virtual environment):

git clone https://github.com/carderne/gridfinder.git
cd gridfinder
rye sync

Useful commands:

rye fmt
rye lint
rye run check  # type check
rye run test

Core symbols most depended-on inside this repo

flip_arr_values
called by 2
gridfinder/post.py
print_progress
called by 1
gridfinder/gridfinder.py
threshold_arr
called by 1
gridfinder/post.py
thin_arr
called by 1
gridfinder/post.py
true_positives
called by 1
gridfinder/post.py
false_negatives
called by 1
gridfinder/post.py
create_filter
called by 1
gridfinder/prepare.py
add_around
called by 1
gridfinder/prepare.py

Shape

Function 38

Languages

Python100%

Modules by API surface

tests/conftest.py10 symbols
gridfinder/post.py9 symbols
gridfinder/prepare.py8 symbols
tests/test_prepare.py3 symbols
gridfinder/gridfinder.py3 symbols
tests/test_post.py2 symbols
gridfinder/util.py2 symbols
tests/test_gridfinder.py1 symbols

For agents

$ claude mcp add gridfinder \
  -- python -m otcore.mcp_server <graph>

⬇ download graph artifact