Skip to content

Commit 87e1ec8

Browse files
authored
Python docs website & improved rtree & kdtree docs (#93)
* Python docs website & improved rtree docs * Add kdtree docs * typo * Remove homepage readme
1 parent ad3c185 commit 87e1ec8

File tree

11 files changed

+2195
-147
lines changed

11 files changed

+2195
-147
lines changed

python/README.md

Lines changed: 2 additions & 76 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,8 @@
77

88
Fast, memory-efficient 2D spatial indexes for Python.
99

10+
This documentation is for the Python bindings. [Refer here for the Rust crate documentation](https://docs.rs/geo-index).
11+
1012
## Install
1113

1214
```
@@ -18,79 +20,3 @@ or with Conda:
1820
```
1921
conda install geoindex-rs
2022
```
21-
22-
## API
23-
24-
### `KDTree`
25-
26-
#### `KDTree.from_interleaved`
27-
28-
Construct an KDTree from a 2D numpy array of `x` and `y`. This must have two dimensions, with the second dimension having length two.
29-
30-
#### `KDTree.from_separated`
31-
32-
Construct an KDTree from two separated 1D numpy arrays of `x` and `y`. Each array must have one dimension and both arrays must have the same length.
33-
34-
#### `KDTree.range`
35-
36-
Search the index for items within a given bounding box.
37-
38-
Arguments:
39-
40-
- `min_x`: float
41-
- `min_y`: float
42-
- `max_x`: float
43-
- `max_y`: float
44-
45-
Returns indices of found items
46-
47-
#### `KDTree.within`
48-
49-
Search the index for items within a given radius.
50-
51-
- `qx` (`float`): x value of query point
52-
- `qy` (`float`): y value of query point
53-
- `r` (`float`): radius
54-
55-
Returns indices of found items
56-
57-
### `RTree`
58-
59-
#### `RTree.from_interleaved`
60-
61-
Construct an RTree from a 2D numpy array of `minx`, `miny`, `maxx`, `maxy`. This must have two dimensions, with the second dimension having length four.
62-
63-
For example, the output of `shapely.bounds` is in this format.
64-
65-
```py
66-
import numpy as np
67-
from geoindex_rs import RTree
68-
69-
geometries = shapely.polygons(...)
70-
bounds = shapely.bounds(geometries)
71-
tree = RTree.from_separated(bounds)
72-
```
73-
74-
#### `RTree.from_separated`
75-
76-
Construct an RTree from four separate 1D numpy arrays of `minx`, `miny`, `maxx`, `maxy`. Each array must have one dimension and all arrays must have the same length.
77-
78-
```py
79-
import numpy as np
80-
from geoindex_rs import RTree
81-
82-
minx = np.array([-10, ...], dtype=np.float64)
83-
miny = np.array([-20, ...], dtype=np.float64)
84-
maxx = np.array([10, ...], dtype=np.float64)
85-
maxy = np.array([20, ...], dtype=np.float64)
86-
tree = RTree.from_separated(minx, miny, maxx, maxy)
87-
```
88-
89-
#### `RTree.search`
90-
91-
Search within an RTree for the given bounding box. Returns the indices of the input array that match the output.
92-
93-
```py
94-
tree = RTree.from_separated(...)
95-
tree.search(minx, miny, maxx, maxy)
96-
```

python/docs/api/kdtree.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
# KDTree
2+
3+
::: geoindex_rs.kdtree

python/docs/api/rtree.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
# RTree
2+
3+
::: geoindex_rs.rtree
4+

python/docs/index.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
../README.md

python/mkdocs.yml

Lines changed: 131 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,131 @@
1+
site_name: geo-index
2+
repo_name: kylebarron/geo-index
3+
repo_url: https://github.com/kylebarron/geo-index
4+
site_description: A Python library and Rust crate for packed, immutable, zero-copy spatial indexes.
5+
site_author: Kyle Barron
6+
# Note: trailing slash recommended with mike:
7+
# https://squidfunk.github.io/mkdocs-material/setup/setting-up-versioning/#publishing-a-new-version
8+
site_url: https://kylebarron.dev/geo-index/
9+
docs_dir: docs
10+
11+
extra:
12+
social:
13+
- icon: "fontawesome/brands/github"
14+
link: "https://github.com/kylebarron"
15+
- icon: "fontawesome/brands/twitter"
16+
link: "https://twitter.com/kylebarron2"
17+
- icon: "fontawesome/brands/linkedin"
18+
link: "https://www.linkedin.com/in/kylebarrongeo/"
19+
version:
20+
provider: mike
21+
22+
nav:
23+
- "index.md"
24+
- API Reference:
25+
- api/rtree.md
26+
- api/kdtree.md
27+
28+
watch:
29+
- python
30+
- docs
31+
32+
theme:
33+
name: material
34+
palette:
35+
# Palette toggle for automatic mode
36+
- media: "(prefers-color-scheme)"
37+
toggle:
38+
icon: material/brightness-auto
39+
name: Switch to light mode
40+
41+
# Palette toggle for light mode
42+
- media: "(prefers-color-scheme: light)"
43+
primary: default
44+
accent: deep orange
45+
toggle:
46+
icon: material/brightness-7
47+
name: Switch to dark mode
48+
49+
# Palette toggle for dark mode
50+
- media: "(prefers-color-scheme: dark)"
51+
scheme: slate
52+
primary: default
53+
accent: deep orange
54+
toggle:
55+
icon: material/brightness-4
56+
name: Switch to system preference
57+
58+
font:
59+
text: Roboto
60+
code: Roboto Mono
61+
62+
features:
63+
- content.code.annotate
64+
- content.code.copy
65+
- navigation.indexes
66+
- navigation.instant
67+
- navigation.tracking
68+
- search.suggest
69+
- search.share
70+
71+
plugins:
72+
- search
73+
- social
74+
- mike:
75+
alias_type: "copy"
76+
canonical_version: "latest"
77+
- mkdocstrings:
78+
enable_inventory: true
79+
handlers:
80+
python:
81+
paths: [obstore/python]
82+
options:
83+
# We set allow_inspection: false to ensure that all docstrings come
84+
# from the pyi files, not the Rust-facing doc comments.
85+
allow_inspection: false
86+
docstring_section_style: list
87+
docstring_style: google
88+
line_length: 80
89+
separate_signature: true
90+
show_root_heading: true
91+
show_signature_annotations: true
92+
show_source: false
93+
show_symbol_type_toc: true
94+
signature_crossrefs: true
95+
extensions:
96+
- griffe_inherited_docstrings
97+
98+
import:
99+
- https://docs.python.org/3/objects.inv
100+
- https://kylebarron.dev/arro3/latest/objects.inv
101+
102+
# https://github.com/developmentseed/titiler/blob/50934c929cca2fa8d3c408d239015f8da429c6a8/docs/mkdocs.yml#L115-L140
103+
markdown_extensions:
104+
- admonition
105+
- attr_list
106+
- codehilite:
107+
guess_lang: false
108+
- def_list
109+
- footnotes
110+
- md_in_html
111+
- pymdownx.arithmatex
112+
- pymdownx.betterem
113+
- pymdownx.caret:
114+
insert: false
115+
- pymdownx.details
116+
- pymdownx.emoji:
117+
emoji_index: !!python/name:material.extensions.emoji.twemoji
118+
emoji_generator: !!python/name:material.extensions.emoji.to_svg
119+
- pymdownx.escapeall:
120+
hardbreak: true
121+
nbsp: true
122+
- pymdownx.magiclink:
123+
hide_protocol: true
124+
repo_url_shortener: true
125+
- pymdownx.smartsymbols
126+
- pymdownx.superfences
127+
- pymdownx.tasklist:
128+
custom_checkbox: true
129+
- pymdownx.tilde
130+
- toc:
131+
permalink: true

python/pyproject.toml

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,4 +19,18 @@ module-name = "geoindex_rs._rust"
1919
python-source = "python"
2020

2121
[tool.uv]
22-
dev-dependencies = ["maturin>=1.7.4", "numpy>=1", "pip>=24.2", "pytest>=8"]
22+
dev-dependencies = [
23+
"griffe-inherited-docstrings>=1.0.1",
24+
"ipykernel>=6.29.5",
25+
"maturin>=1.7.4",
26+
"mike>=2.1.3",
27+
"mkdocs-material[imaging]>=9.5.40",
28+
"mkdocs>=1.6.1",
29+
"mkdocstrings-python>=1.13.0",
30+
"mkdocstrings>=0.27.0",
31+
"numpy>=1",
32+
"pip>=24.2",
33+
"pyarrow>=17.0.0",
34+
"pytest>=8.3.3",
35+
"ruff>=0.8.4",
36+
]

0 commit comments

Comments
 (0)