Python library for FlatGeobuf
Project description
python-flatgeobuf
A Python library for FlatGeobuf. Ported from the official TypeScript implementation.
Installation
pip install flatgeobuf
Usage
Loaders
load()
import flatgeobuf as fgb
# All features
with open("example.fgb", "rb") as f:
data = fgb.load(f)
# ...or features within a bounding box
with open("example.fgb", "rb") as f:
data = fgb.load(f, bbox=(-26.5699, 63.1191, -12.1087, 67.0137))
print(data)
# { "type": "FeatureCollection", "features": [...] }
load_http()
(Async)
import flatgeobuf as fgb
# All features
data = await fgb.load_http("https://raw.githubusercontent.com/flatgeobuf/flatgeobuf/master/test/data/countries.fgb")
# ...or features within a bounding box
data = await fgb.load_http(
"https://raw.githubusercontent.com/flatgeobuf/flatgeobuf/master/test/data/countries.fgb",
bbox=(-26.5699, 63.1191, -12.1087, 67.0137)
)
print(data)
# { "type": "FeatureCollection", "features": [...] }
Readers
Reader
import flatgeobuf as fgb
# All features
with open("example.fgb", "rb") as f:
reader = fgb.Reader(f)
for feature in reader:
print(feature)
# { "type": "Feature", "properties": {...}, "geometry": {...} }
# ...or features within a bounding box
with open("example.fgb", "rb") as f:
reader = fgb.Reader(f, bbox=(-26.5699, 63.1191, -12.1087, 67.0137))
for feature in reader:
print(feature)
# { "type": "Feature", "properties": {...}, "geometry": {...} }
HTTPReader
(Async)
import flatgeobuf as fgb
# All features
reader = fgb.HTTPReader("https://raw.githubusercontent.com/flatgeobuf/flatgeobuf/master/test/data/countries.fgb")
async for feature in reader:
print(feature)
# { "type": "Feature", "properties": {...}, "geometry": {...} }
# ...or features within a bounding box
reader = fgb.HTTPReader(
"https://raw.githubusercontent.com/flatgeobuf/flatgeobuf/master/test/data/countries.fgb",
bbox=(-26.5699, 63.1191, -12.1087, 67.0137)
)
async for feature in reader:
print(feature)
# { "type": "Feature", "properties": {...}, "geometry": {...} }
Roadmap
- Read FlatGeobuf
- Read top-level (
FeatureCollection
) properties
- Read top-level (
- Write FlatGeobuf
- Rewrite some parts in Rust (parcked R-tree, geometry intersection)
License
MIT
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
flatgeobuf-0.2.0.tar.gz
(22.1 kB
view hashes)
Built Distribution
flatgeobuf-0.2.0-py3-none-any.whl
(32.0 kB
view hashes)
Close
Hashes for flatgeobuf-0.2.0-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | e2f2a2bb3eaa979646ee8c834456e0e45ab14782f7055b3d67811d07f51ff54e |
|
MD5 | 70bdb6c41b1c2a6855ed0f4727822000 |
|
BLAKE2b-256 | 3be0d3fd6f76598d258d5cbe8f2e1aa0874a23afd0d3373a18f1f1ac0a32ae94 |