跳转到主要内容

一个将ArcGIS JSON转换为GeoJSON的Python库

项目描述

Run tests codecov PyPI Version License Python Compatibility Code style: black

arcgis2geojson.py

A Python library for converting ArcGIS JSON to GeoJSON: A partial port of ESRI's arcgis-to-geojson-utils.

安装

pip install arcgis2geojson

使用

作为库

将ArcGIS JSON字符串转换为GeoJSON字符串

>>> from arcgis2geojson import arcgis2geojson

>>> input = """{
...     "attributes": {"OBJECTID": 123},
...     "geometry": {   "rings": [   [   [41.8359375, 71.015625],
...                                      [56.953125, 33.75],
...                                      [21.796875, 36.5625],
...                                      [41.8359375, 71.015625]]],
...                     "spatialReference": {"wkid": 4326}}}"""
>>> output = arcgis2geojson(input)

>>> output
'{"type": "Feature", "geometry": {"type": "Polygon", "coordinates": [[[41.8359375, 71.015625], [21.796875, 36.5625], [56.953125, 33.75], [41.8359375, 71.015625]]]}, "properties": {"OBJECTID": 123}, "id": 123}'

>>> type(output)
<class 'str'>

将python字典转换为python字典

>>> from arcgis2geojson import arcgis2geojson

>>> input = {
...     'attributes': {'OBJECTID': 123},
...     'geometry': {   'rings': [   [   [41.8359375, 71.015625],
...                                      [56.953125, 33.75],
...                                      [21.796875, 36.5625],
...                                      [41.8359375, 71.015625]]],
...                     'spatialReference': {'wkid': 4326}}}
>>> output = arcgis2geojson(input)

>>> output
{'type': 'Feature', 'geometry': {'type': 'Polygon', 'coordinates': [[[41.8359375, 71.015625], [21.796875, 36.5625], [56.953125, 33.75], [41.8359375, 71.015625]]]}, 'properties': {'OBJECTID': 123}, 'id': 123}

>>> type(output)
<class 'dict'>

在控制台

# convert ArcGIS json file to GeoJOSN file
$ arcgis2geojson arcgis.json > geo.json

# fetch ArcGIS json from the web and convert to GeoJSON
$ curl "https://myserver.com/arcgis.json" | arcgis2geojson

许可

arcgis2geojson是ESRI的arcgis-to-geojson-utils的衍生作品。原始代码由Esri于2015年版权所有,并许可在Apache许可证2.0版本下。

arcgis2geojson在MIT许可证下提供。

项目详情


下载文件

下载适用于您的平台的文件。如果您不确定选择哪个,请了解更多关于安装包的信息。

源分布

arcgis2geojson-3.0.3.tar.gz (5.2 kB 查看哈希值)

上传时间

构建的发行版

arcgis2geojson-3.0.3-py3-none-any.whl (6.1 kB 查看散列值)

上传时间 Python 3

支持