Package: pygeoconv
PygeoconvConvert betweenArcGis Json,WKTandGeoJsonusing python.This tool is inspired by theterraformer-jslibrary. See more in theAknowledgments section.Requirementspygeoconv is a pure Python implementation without dependencies, it only requires python 3.6 or greater to run.Installationpip install pygeoconvUsageimport pygeoconv

wkt_geom = "POINT (30 10)"

# Convert WKT to geojson
geojson_geom = pygeoconv.wkt_to_geojson(wkt_geom)

# Convert WKT to esri json
esri_geom = pygeoconv.wkt_to_esri_json(wkt_geom)ExamplesWKT to GeoJsonimport pygeoconv

wkt = """LINESTRING (495802.21253339015 6677525.294995224, 495161.84831775713 6676871.354153112, 494951.41060731944 6677661.061260023, 495261.41024527606 6677726.681621342, 495227.4686790764 6677826.243548861, 495492.2128954336 6677760.623187543, 495480.89904003375 6677869.236199382, 495657.3951842718 6677871.498970462, 495725.2783166711 6677787.776440503, 496005.861930588 6677905.440536661, 495535.2055459531 6677525.294995226, 495186.73879963695 6677532.083308466, 495225.2059079965 6677274.127405348, 495424.32976303436 6677342.010537747, 495702.6506058713 6677532.083308466, 495942.5043403487 6677663.324031104, 495994.5480751881 6677473.251260386, 495919.87662954896 6677271.864634268, 495652.8696421119 6677133.83559839, 495487.6873532736 6676946.025598751, 495517.10337731335 6676810.259333953, 495605.3514494324 6676710.697406434, 495856.51903930964 6676832.887044753, 495996.8108462681 6677052.375839511, 496026.2268703078 6677222.083670509, 496119.00048458675 6677403.105356907, 496139.36542430654 6677593.178127625, 496066.95674974733 6677726.681621343, 496023.9640992278 6677760.623187543)"""

geojson = pygeoconv.wkt_to_geojson(wkt)WKT to Esri JsonEsri Json format (unlike WKT and GeoJson) requires the spatial reference to be specified on the geometry object. Use the wkid parameter to define which spatial reference system should be used, default is 4326.esri_json = pygeoconv.wkt_to_esri_json(wkt, wkid=3006)GeoJson to WKTimport pygeoconv

geojson = {
      "type": "Point",
      "coordinates": [
        495357.5879157982,
        6677582.037713626
      ]
    }

wkt = pygeoconv.geojson_to_wkt(geojson)GeoJson to Esri JsonEsri Json format (unlike WKT and GeoJson) requires the spatial reference to be specified on the geometry object. Use the wkid parameter to define which spatial reference system should be used, default is EPSG:4326.import pygeoconv

geojson = {
      "type": "Point",
      "coordinates": [
        495357.5879157982,
        6677582.037713626
      ]
    }
esri_json = pygeoconv.geojson_to_esri_json(geojson, wkid=3006)Esri Json to WKTimport pygeoconv

esri_json = {
      "x": 495357.5879157982,
      "y": 6677582.037713626,
      "spatialReference": {
        "wkid": 3006
      }
    }

wkt = pygeoconv.esri_json_to_wkt(esri_json)Esri Json to GeoJSONimport pygeoconv

esri_json = {
      "x": 495357.5879157982,
      "y": 6677582.037713626,
      "spatialReference": {
        "wkid": 3006
      }
    }
esri_json = pygeoconv.esrijson_to_geojson(esri_json)Spatial reference systemEsri JsonWhen converting to Esri Json format, use the wkid parameter to specify which spatial reference system  should be embedded in the json object. The wkid parameter expects a Well Known Id (WKID, EPSG Code) as an integer. The default value is 4326esri_json = pygeoconv.wkt_to_esri_json(wkt, wkid=3006)Neither WKT or GeoJson supports defining a spatial reference system at geometry object level.Conversion matricesWKT to GeoJson or Esri JsonPointLineStringPolygonMultiPointMultiLinestringMultiPolygonGeometryCollectionGeoJsonPointLineStringPolygonMultiPointMultiLinestringMultiPolygonGeometryCollectionEsri JsonPointPolylinePolygonMultiPointPolylinePolygonList of geometriesGeoJson to WKT or Esri JsonPointLineStringPolygonMultiPointMultiLinestringMultiPolygonGeometryCollectionFeatureFeatureCollectionWKTPointLineStringPolygonMultiPointMultiLinestringMultiPolygonGeometryCollection****Esri JsonPointPolylinePolygonMultiPointPolylinePolygonList of geometriesFeatureFeatureSet** Conversion of GeoJson Feature or FeatureCollection to WKT will throw a ValueError since WKT format has no definition for these object types.Esri Json to WKT or GeoJsonPointPolylinePolygonMultiPointFeatureFeatureSetEnvelopeWKTPointLineString / MultiLineString *Polygon / MultiPolygon *MultiPoint****PolygonGeoJsonPointLineString / MultiLineString *Polygon / MultiPolygon *MultiPointFeatureFeatureCollectionPolygon* In Esri standard, MultiLineString is described as Polyline with additional number of paths. MultiPolygon is described as Polygon with additional number of rings. For more information, seehttps://developers.arcgis.com/documentation/common-data-types/geometry-objects.htm** Conversion of Esri Json Feature or FeatureSet to WKT will throw a ValueError since WKT format has no definition for these object types.AknowledgmentsThis tool is heavily inspired byterraformer-js, "A geographic toolkit for dealing with geometry, geography, formats, and building geodatabases" written in javascript.PLYis used for parsing WKT text based format into python dictionaries. Thanks for this awesome Python package David Beazley!