GeoJSONchemy [Under Development] 🌍🧪
GeoJSONchemy is a Python library that provides support for GeoJSON spatial data types in SQLAlchemy and SQLModel. It allows you to easily work with GeoJSON data in your database models. It currently supports ONLY PostgreSQL-PostGIS.
Installation 📦
You can install GeoJSONchemy using pip:
pip install geojsonchemy
Usage 🚀
SQLAlchemy
In SQLAlchemy, you can use the GeomJSON and Geomdantic classes from GeoJSONchemy as types for your model fields. Both are subclasses from geoalchemy2.types.Geometry
Here's an example:
from sqlalchemy import Column, Integer
from sqlalchemy.ext.declarative import declarative_base
from sqlalchemy.orm import Mapped, mapped_column
from geojsonchemy import GeomJSON, Geomdantic
from geojson_pydantic.geometries import Geometry, Point, MultiPlolygon
Base = declarative_base()
class FooModel(Base):
__tablename__ = 'foo'
id: Mapped[int] = Column(Integer, primary_key=True)
geom: Mapped[dict] = mapped_column(GeomJSON(geometry_type="POINT", srid=4326), nullable=False, index=True)
geom2: Mapped[Geometry] = mapped_column(Geomdantic(geometry_type="GEOMETRY", srid=4326), nullable=False, index=True)
SQLModel
In SQLModel, you can use the GeomJSON and Geomdantic classes in a similar way:
from sqlmodel import Field, SQLModel
class GeomTable(SQLModel, table=True):
__tablename__ = "bar"
id: int = Field(primary_key=True)
name: str
geom: dict = Field(
sa_type=GeomJSON(geometry_type="GEOMETRY", srid=4326),
nullable=False,
)
geom2: Point = Field(
sa_type=Geomdantic(geometry_type="POINT", srid=4326),
nullable=False,
)
Note 📝
Please note that GeoJSONchemy currently only supports PostgreSQL. If you try to use it with a different database, it will raise a NotImplementedError.
Contributing 🤝
Contributions are welcome! Please feel free to submit a pull request.
TODO
- Add support for MutableDict
License 📄
GeoJSONchemy is licensed under the MIT license. See the LICENSE file for more details.
Metadata
Release files for geojsonchemy 0.1.3
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | |
|---|---|---|---|---|
| geojsonchemy-0.1.3.tar.gz | 3.1 kB | Without provenance | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| geojsonchemy-0.1.3-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 6.8 kB
Release files / geojsonchemy-0.1.3.tar.gz
| Download URL | geojsonchemy-0.1.3.tar.gz |
|---|---|
| Size | 3.1 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
8741cd29b545760909ddb79c1867efad4951bc2e1fc97844b5f0061924f37383
|
|
BLAKE2b-256 checksum How to use checksums |
46e94cf01813396a6cc9c07c675a8a9f0aea8641029320bbf7d315d5ed1fe8f1
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
poetry/1.7.1 CPython/3.11.7 Linux/5.15.133.1-microsoft-standard-WSL2
|
Release files / geojsonchemy-0.1.3-py3-none-any.whl
| Download URL | geojsonchemy-0.1.3-py3-none-any.whl |
|---|---|
| Size | 3.8 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
a950ccfe22b5c3220372229e8a93961da1030a06d572360785aeb8f4608faf7d
|
|
BLAKE2b-256 checksum How to use checksums |
16eddc500f9d4e6c360b235d98228d17460d2b62fc07b44926547ec6b5fb2d7c
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
poetry/1.7.1 CPython/3.11.7 Linux/5.15.133.1-microsoft-standard-WSL2
|
Security for geojsonchemy 0.1.3
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.