Parser of the infamous ESRI GeoJSON | Read-only mirror of https://github.com/geoadmin/lib-esrijson — Bundesamt für Landestopografie swisstopo. Issues & pull requests at the source.
Find a file
Repository files (latest commit first)
Filename Latest commit message Latest commit date
Marc Sommerhalder dc719abb7b
Merge pull request #16 from geoadmin/feat-PB-1477-retire-lib-esrijson
PB-1477: Add retirement message
2025-10-07 13:08:28 +02:00
esrijson Merge pull request #8 from geoadmin/gal_fault_tolerant_bbox 2017-07-27 12:21:44 +02:00
tests Merge pull request #8 from geoadmin/gal_fault_tolerant_bbox 2017-07-27 12:21:44 +02:00
.gitignore Add missing ignore 2017-06-27 18:17:17 +02:00
buildspec.yml BGDIINF_SB-2208: Migrating CI from travis to codebuild 2022-03-24 14:10:17 +01:00
LICENSE Add LICENSE (#11) 2019-03-08 18:17:05 +01:00
README.md PB-1477: Add retirement message 2025-10-07 11:44:36 +02:00
setup.py adding python 3.8 (#14) 2020-09-03 12:17:54 +02:00

esrijson

Warning

This project is no longer under active development

Introduction

This module is meant to build a bridge between GDAL __geo_interface__ property via Shapely. There is no concept of GeometryCollection in esrijson syntax, so there is only a limited support for this concept. Currently, we only take the first geometry and drop the rest. This library is heavily inspired by python-geojson.

Usage

import esrijson
from shapely import geometry

# Create an esrijson feature
feat = esrijson.Feature(geometry=geometry.Point(1, 4), attributes={'name': 'dummy', 'val': 1}, wkid=2056)
# Dump to json
dumped = esrijson.dumps(feat)
# Load to Feature back again
loaded = esrijson.loads(dumped)
print(loaded)
print(type(loaded))

>>> {'geometry': {'y': 4.0, 'x': 1.0}, 'spatialReference': {u'wkid': 2056}},'attributes': {u'name': u'dummy', u'val': 1}}
>>> <class 'esrijson.feature.Feature'>

# You can also transform an esri json like object into a shapely object
geom = esrijson.to_shape({"paths": [[[0.0, 0.0], [1.0, 1.0]], [[-1.0, 0.0], [1.0, 0.0]]]})
print(getattr(geom, '__geo_interface__')

>>> {'type': 'MultiLineString', 'coordinates': (((0.0, 0.0), (1.0, 1.0)), ((-1.0, 0.0), (1.0, 0.0)))}

# And of your do the same operation back again
esri_geom = esrijson.from_shape(geom)
print(esri_geom)
>>> {'paths': (((0.0, 0.0), (1.0, 1.0)), ((-1.0, 0.0), (1.0, 0.0)))}

ESRI specs references