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()
import flatgeobuf as fgb
# All features
data = fgb.load_http("https://raw.githubusercontent.com/flatgeobuf/flatgeobuf/master/test/data/countries.fgb")
# ...or features within a bounding box
data = 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": [...] }
load_http_async()
import flatgeobuf as fgb
# All features
data = await fgb.load_http_async("https://raw.githubusercontent.com/flatgeobuf/flatgeobuf/master/test/data/countries.fgb")
# ...or features within a bounding box
data = await fgb.load_http_async(
"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
import flatgeobuf as fgb
# All features
reader = fgb.HTTPReader("https://raw.githubusercontent.com/flatgeobuf/flatgeobuf/master/test/data/countries.fgb")
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)
)
for feature in reader:
print(feature)
# { "type": "Feature", "properties": {...}, "geometry": {...} }
AsyncHTTPReader
import flatgeobuf as fgb
# All features
reader = fgb.AsyncHTTPReader("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.AsyncHTTPReader(
"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.1.1.tar.gz
(22.2 kB
view hashes)
Built Distribution
flatgeobuf-0.1.1-py3-none-any.whl
(32.1 kB
view hashes)
Close
Hashes for flatgeobuf-0.1.1-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | aa6082d1c46b2ad6253bdb14d4bc839eec6bbd07b3f10efd3e45148796b2c495 |
|
MD5 | 7aea2ce36e2105adcc23b1633b85b964 |
|
BLAKE2b-256 | e5dcb26e188687a106aa43183402a809376b0a4f4f3bb593ef23fe5b032bdfa8 |