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.2.0.tar.gz
(2.7 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.0.tar.gz.
File metadata
- Download URL: msgspec_geojson-0.2.0.tar.gz
- Upload date:
- Size: 2.7 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 |
1123e31ebb8ea486e9b1156b0e15bd9c67b146a47d970f2eb6b02ff01d5d2aed
|
|
| MD5 |
6bd155a7c273461c119c1c6def6379d6
|
|
| BLAKE2b-256 |
86423952406e01e263c6cf7325f35c2e1ca534b2365bc4ee45361c9344278049
|
File details
Details for the file msgspec_geojson-0.2.0-py3-none-any.whl.
File metadata
- Download URL: msgspec_geojson-0.2.0-py3-none-any.whl
- Upload date:
- Size: 3.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 |
c090da010431f078ab9291f90c9df4f16de42553de5269829d01bda592846b39
|
|
| MD5 |
8fe24ef3b0a340171e422fc76210bf08
|
|
| BLAKE2b-256 |
d664b5750189c09efea052dc74aa15abf8e2b811ef293017c664b5a88926bb81
|