Skip to content

Commit 5bc5892

Browse files
Merge pull request #70 from ai4er-cdt/feature/misc-issues
Misc Issues PR
2 parents 7ac51e5 + 9675843 commit 5bc5892

File tree

8 files changed

+233
-97
lines changed

8 files changed

+233
-97
lines changed

PYPI_README.md

Lines changed: 28 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,24 +1,41 @@
11
<p align="center">
2-
<img src="https://raw.githubusercontent.com/ai4er-cdt/gtc-biodiversity/main/docs/images/geograph_logo.png" alt="GeoGraph" width="300px">
2+
<img src="https://raw.githubusercontent.com/ai4er-cdt/geograph/main/docs/images/geograph_logo.png" alt="GeoGraph" width="300px">
33
</p>
44

5-
_Created as part of the AI4ER Group Team Challenge 2021 by the Biodiversity Team._
6-
7-
8-
[![Binder](https://mybinder.org/badge_logo.svg)](https://mybinder.org/v2/gh/ai4er-cdt/gtc-biodiversity/main?urlpath=lab%2Ftree%2Fnotebooks)
5+
[![Binder](https://mybinder.org/badge_logo.svg)](https://mybinder.org/v2/gh/ai4er-cdt/geograph/main?urlpath=lab%2Ftree%2Fnotebooks)
96
[![License: MIT](https://img.shields.io/badge/License-MIT-blue.svg)](https://opensource.org/licenses/MIT)
107
<a href="https://github.com/psf/black"><img alt="Code style: black" src="https://img.shields.io/badge/code%20style-black-000000.svg"></a>
118
[![Documentation Status](https://readthedocs.org/projects/geograph/badge/?version=latest)](https://geograph.readthedocs.io/en/latest/?badge=latest)
129

13-
See the [Github repository](https://github.com/ai4er-cdt/gtc-biodiversity) for full details.
1410

15-
## 1. Features
11+
__Table of contents:__
12+
1. Description
13+
2. Installation
14+
3. Requirements
15+
4. Documentation
16+
17+
## 1. Description
18+
19+
GeoGraph provides a tool for analysing habitat fragmentation and related problems in landscape ecology. GeoGraph builds a geospatially referenced graph from land cover or field survey data and enables graph-based landscape ecology analysis as well as interactive visualizations. Beyond the graph-based features, GeoGraph also enables the computation of common landscape metrics.
20+
21+
## 2. Installation
22+
23+
GeoGraph is available via pip, so you can install it using
24+
25+
```
26+
pip install geograph
27+
```
28+
29+
Done, you're ready to go!
30+
31+
You can also visit the [Github repository](https://github.com/ai4er-cdt/geograph).
32+
33+
See the [documentation](https://geograph.readthedocs.io/) for a full getting started guide or check out the [binder](https://mybinder.org/v2/gh/ai4er-cdt/geograph/main?urlpath=lab%2Ftree%2Fnotebooks) for tutorials on how to get started .
1634

17-
GeoGraph provides a full-stack tool for analysing habitat fragmentation, and other related problems. It includes models to predict land cover classes, a method to extract graph structure from the resulting land cover maps and an extensive range of visualisation and analysis tools.
35+
## 3. Requirements
1836

19-
## 2. Requirements
37+
GeoGraph is written in Python 3.8 and builds on [NetworkX](https://github.com/NetworkX/NetworkX), [ipyleaflet](https://github.com/jupyter-widgets/ipyleaflet), [geopandas](https://geopandas.org/), [rasterio](https://rasterio.readthedocs.io/en/latest/) and many more packages. See the [requirements directory](./requirements) for a full list of dependencies.
2038

21-
GeoGraph is written in Python 3.8 and builds on [NetworkX](https://github.com/NetworkX/NetworkX), [ipyleaflet](https://github.com/jupyter-widgets/ipyleaflet) and many more packages. See the [requirements directory](https://github.com/ai4er-cdt/gtc-biodiversity/tree/main/requirements) for a full list of dependencies.
22-
## 3. Documentation
39+
## 4. Documentation
2340

2441
Our documentation is available at [geograph.readthedocs.io](https://geograph.readthedocs.io/).

README.md

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,11 @@
33
</p>
44

55

6-
[![Binder](https://mybinder.org/badge_logo.svg)](https://mybinder.org/v2/gh/ai4er-cdt/gtc-biodiversity/main?urlpath=lab%2Ftree%2Fnotebooks)
6+
[![Binder](https://mybinder.org/badge_logo.svg)](https://mybinder.org/v2/gh/ai4er-cdt/geograph/main?urlpath=lab%2Ftree%2Fnotebooks)
77
[![License: MIT](https://img.shields.io/badge/License-MIT-blue.svg)](https://opensource.org/licenses/MIT)
88
<a href="https://github.com/psf/black"><img alt="Code style: black" src="https://img.shields.io/badge/code%20style-black-000000.svg"></a>
99
[![Documentation Status](https://readthedocs.org/projects/geograph/badge/?version=latest)](https://geograph.readthedocs.io/en/latest/?badge=latest)
10+
[![PyPI version](https://badge.fury.io/py/geograph.svg)](https://badge.fury.io/py/geograph)
1011

1112
![GeoGraphViewer demo gif](docs/images/viewer_demo.gif)
1213

@@ -39,4 +40,4 @@ GeoGraph is written in Python 3.8 and builds on [NetworkX](https://github.com/Ne
3940

4041
## 4. Documentation
4142

42-
Our documentation is available at [geograph.readthedocs.io](https://geograph.readthedocs.io/).
43+
Our documentation is available at [geograph.readthedocs.io](https://geograph.readthedocs.io/).

geograph/binary_graph_operations.py

Lines changed: 14 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515

1616

1717
class NodeMap:
18-
"""Class to store node mappings between two graphs (the src_graph and trg_graph)"""
18+
"""Class to store node mappings between two graphs (the src_graph and trg_graph)."""
1919

2020
def __init__(
2121
self,
@@ -24,7 +24,7 @@ def __init__(
2424
mapping: Dict[int, List[int]],
2525
) -> None:
2626
"""
27-
Class to store node mappings between two graphs (`trg_graph` and `src_graph`)
27+
Class to store node mappings between two graphs (`trg_graph` and `src_graph`).
2828
2929
This class stores a dictionary of node one-to-many relationships of nodes from
3030
`src_graph` to `trg_graph`. It also provides support for convenient methods for
@@ -45,36 +45,36 @@ def __init__(
4545

4646
@property
4747
def src_graph(self) -> geograph.GeoGraph:
48-
"""Keys in the mapping dict correspond to node indices in the `src_graph`"""
48+
"""Keys in the mapping dict correspond to node indices in the `src_graph`."""
4949
return self._src_graph
5050

5151
@property
5252
def trg_graph(self) -> geograph.GeoGraph:
53-
"""Values in the mapping dict correspond to node indices in the `trg_graph`"""
53+
"""Values in the mapping dict correspond to node indices in the `trg_graph`."""
5454
return self._trg_graph
5555

5656
@property
5757
def mapping(self) -> Dict[int, List[int]]:
58-
"""
59-
Look-up table connecting node indices from `src_graph` to those of `trg_graph`.
60-
"""
58+
"""Look-up table connecting node indices from `src_graph` to `trg_graph`."""
6159
return self._mapping
6260

6361
def __invert__(self) -> NodeMap:
64-
"""Compute the inverse NodeMap"""
62+
"""Compute the inverse NodeMap."""
6563
return self.invert()
6664

67-
def __eq__(self, other: NodeMap) -> bool:
68-
"""Check two NodeMaps for equality"""
65+
def __eq__(self, other: object) -> bool:
66+
"""Check two NodeMaps for equality."""
67+
if not isinstance(other, NodeMap):
68+
return False
6969
return (
7070
self.src_graph == other.src_graph
7171
and self.trg_graph == other.trg_graph
7272
and self.mapping == other.mapping
7373
)
7474

7575
def invert(self) -> NodeMap:
76-
"""Compute the inverse NodeMap from `trg_graph` to `src_graph`"""
77-
inverted_mapping = {index: [] for index in self.trg_graph.df.index}
76+
"""Compute the inverse NodeMap from `trg_graph` to `src_graph`."""
77+
inverted_mapping: Dict = {index: [] for index in self.trg_graph.df.index}
7878

7979
for src_node in self.src_graph.df.index:
8080
for trg_node in self.mapping[src_node]:
@@ -117,7 +117,7 @@ def identify_graphs(
117117
graph1: geograph.GeoGraph, graph2: geograph.GeoGraph, mode: str
118118
) -> NodeMap:
119119
"""
120-
Idenitfy all nodes from `graph1` with nodes from `graph2` based on the given `mode`
120+
Idenitfy all nodes from `graph1` with nodes from `graph2` based on the given `mode`.
121121
122122
Args:
123123
graph1 (GeoGraph): The GeoGraph whose node indicies will form the domain
@@ -143,8 +143,7 @@ def identify_graphs(
143143

144144
def graph_polygon_diff(node_map: NodeMap) -> Tuple[gpd.GeoDataFrame, gpd.GeoDataFrame]:
145145
"""
146-
Return the (multi)polygon areas that were added/removed when going
147-
from `src_graph` to `trg_graph`.
146+
Return the polygons that were added/removed going from `src_graph` to `trg_graph`.
148147
149148
Args:
150149
node_map (NodeMap): The node map from `src_graph` to `trg_graph`
@@ -193,7 +192,6 @@ def node_polygon_diff(
193192
Tuple[BaseGeometry, BaseGeometry]: Added part and removed part as shapely
194193
BaseGeometry objects.
195194
"""
196-
197195
src_polygon: Polygon = node_map.src_graph.df.geometry.loc[src_node_id]
198196
trg_node_ids: List[int] = node_map.mapping[src_node_id]
199197

geograph/constants.py

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,4 @@
1-
"""
2-
This file is used to save all project wide constants such as the path of the
3-
source folder, the project path, etc.
4-
"""
5-
1+
"""All project wide constants are saved in this module."""
62
# Place all your constants here
73
import os
84
import pathlib

0 commit comments

Comments
 (0)