msgspec-geojson
A collection of GeoJSON types for msgspec.
Inspired by the msgspec GeoJSON example code and geojson-pydantic.
This lets you parse GeoJSON into type-safe objects, including properties, and serialize those objects back to GeoJSON:
>>> import msgspec.json
>>> from msgspec import Struct
>>> from msgspec_geojson import Feature, Point
>>> class PoiProperties(Struct):
... name: str
... kind: str
>>> obj = msgspec.json.decode("""
... {"type": "Feature", "id": 1,
... "properties": {"name": "Zoo Zürich", "kind": "tourism/zoo"},
... "geometry": {"type": "Point", "coordinates": [8.574695, 47.384510]}}
... """, type=Feature[Point, PoiProperties])
>>> obj.id
1
>>> obj.geometry
Point(coordinates=(8.574695, 47.38451))
>>> obj.properties
PoiProperties(name='Zoo Zürich', kind='tourism/zoo')
>>> feature = Feature(
... Point(coordinates=(7.5823576, 47.5489249)),
... PoiProperties(name="Zoo Basel", kind="tourism/zoo"),
... )
>>> msgspec.json.encode(feature)
b'{"type":"Feature","geometry":{"type":"Point","coordinates":[7.5823576,47.5489249]},"properties":{"name":"Zoo Basel","kind":"tourism/zoo"}}'
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
msgspec_geojson-0.2.1.tar.gz
(2.8 kB
view details)
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file msgspec_geojson-0.2.1.tar.gz.
File metadata
- Download URL: msgspec_geojson-0.2.1.tar.gz
- Upload date:
- Size: 2.8 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via:
uv/0.12.7 {"installer":{"name":"uv","version":"0.12.7","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"macOS","version":null,"id":null,"libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
bc312e87351d7e08e1c58ab8e1a1e4fa5466ab9097f8f40eac7a6bfe9bce88c2
|
|
| MD5 |
121645bc1edc93e423b275c26f6d532a
|
|
| BLAKE2b-256 |
d4b64d328451255944c106756e0ff28b47e895bf37f6baa8c31f224b59bcecf6
|
File details
Details for the file msgspec_geojson-0.2.1-py3-none-any.whl.
File metadata
- Download URL: msgspec_geojson-0.2.1-py3-none-any.whl
- Upload date:
- Size: 3.9 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via:
uv/0.12.7 {"installer":{"name":"uv","version":"0.12.7","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"macOS","version":null,"id":null,"libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
15bd8100462b5a2a0b1753bff5c3593ef847ab5535fab6afdd377d7bf8f7e7e8
|
|
| MD5 |
f486ece75dcf10b9fb00c5c591786360
|
|
| BLAKE2b-256 |
d0a556cbdd849dca6e9f8cb9ee090dd96ad6c7030da5c55e5af751ab08022f64
|