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 propeties, 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
>>> type PoiFeature = Feature[Point, PoiProperties]
>>> 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=PoiFeature)
>>> 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.1.0.tar.gz
(2.0 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.1.0.tar.gz.
File metadata
- Download URL: msgspec_geojson-0.1.0.tar.gz
- Upload date:
- Size: 2.0 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via:
uv/0.11.32 {"installer":{"name":"uv","version":"0.11.32","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 |
b38d49ab02e8564e6753e2bba491d867ec7be7d836a680873d572a688fad5b5f
|
|
| MD5 |
ff17e2c96756f8a9fe39e2ebed0451f9
|
|
| BLAKE2b-256 |
aa22e7bb2ea485e2685484e80bf96ce287ed3f19830ea76a087369041c70b4fe
|
File details
Details for the file msgspec_geojson-0.1.0-py3-none-any.whl.
File metadata
- Download URL: msgspec_geojson-0.1.0-py3-none-any.whl
- Upload date:
- Size: 2.9 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via:
uv/0.11.32 {"installer":{"name":"uv","version":"0.11.32","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 |
b7e3f58840737f2dbd2e273b1acb12b9a24bb9453402729527b937b5a4b302c3
|
|
| MD5 |
09ef9be733aee49700fae65ede685def
|
|
| BLAKE2b-256 |
34bd8e450da41bdbc2f3c1ad9bab9622fc8a8aed448c8da9fb43034084135340
|