Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/geoadmin/lib-esrijson
Parser of the infamous ESRI GeoJSON
https://github.com/geoadmin/lib-esrijson
esri geometry managed-by-tf python
Last synced: about 1 month ago
JSON representation
Parser of the infamous ESRI GeoJSON
- Host: GitHub
- URL: https://github.com/geoadmin/lib-esrijson
- Owner: geoadmin
- License: bsd-2-clause
- Created: 2017-06-14T09:29:04.000Z (over 7 years ago)
- Default Branch: master
- Last Pushed: 2023-12-11T14:40:55.000Z (about 1 year ago)
- Last Synced: 2024-10-29T01:18:53.900Z (about 2 months ago)
- Topics: esri, geometry, managed-by-tf, python
- Language: Python
- Homepage:
- Size: 34.2 KB
- Stars: 5
- Watchers: 14
- Forks: 0
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
esrijson
========[![Build Status](https://travis-ci.org/geoadmin/lib-esrijson.svg?branch=master)](https://travis-ci.org/geoadmin/lib-esrijson)
Introduction
------------This module is meant to build a bridge between GDAL `__geo_interface__` property via [Shapely](https://github.com/Toblerity/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](https://github.com/frewsxcv/python-geojson).Usage
-----```python
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}}
>>># 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
---------------------- [Geometry Object](http://resources.arcgis.com/en/help/arcgis-rest-api/index.html#//02r3000000n1000000)
- [Feature Object](http://resources.arcgis.com/en/help/arcgis-rest-api/index.html#/Feature_object/02r3000000n8000000/)