geomet
geomet is a pure Python library designed for converting between various common geospatial data formats, including Well-Known Text (WKT), Well-Known Binary (WKB), GeoJSON, and EsriJSON. The current version is 1.1.0, with releases occurring a few times a year, primarily for compatibility updates and bug fixes.
Warnings
- breaking Support for Python 2.7, 3.4, 3.5, and 3.6 was dropped in version 1.0.0. Users on these older Python versions must use `geomet<1.0.0`.
- gotcha Conversions involving EsriJSON, especially with coordinate value structures or custom SRIDs, had known bugs in versions prior to 1.1.0.
- gotcha Previous versions of `geomet` (specifically before 1.0.0) had issues with handling floating point representation, particularly with exponential coordinate values, which could lead to subtle precision errors during WKT/WKB parsing and generation.
Install
-
pip install geomet
Imports
- wkt
from geomet import wkt
- geojson
from geomet import geojson
- esrijson
from geomet import esrijson
Quickstart
from geomet import wkt, geojson
wkt_string = "POINT (30 10)"
# Convert WKT to GeoJSON dictionary
geom_dict = wkt.loads(wkt_string)
print(f"WKT loaded as: {geom_dict}")
# Expected: {'type': 'Point', 'coordinates': (30.0, 10.0)}
# Convert GeoJSON dictionary back to GeoJSON string
json_string = geojson.dumps(geom_dict)
print(f"GeoJSON dumped as: {json_string}")
# Expected: {"type": "Point", "coordinates": [30.0, 10.0]}