AsShape (arcpy)

サマリ

Converts Esri JSON or GeoJSON to ArcPy geometry objects. GeoJSON is a geospatial data interchange format for encoding geographic data structures.

構文

AsShape (geojson_struct, {esri_json})
パラメータ説明データ タイプ
geojson_struct

The geojson_struct includes type and coordinates.

The following strings are included for type: Point, LineString, Polygon, MultiPoint, and MultiLineString.

Dictionary
esri_json

The esri_json geometry properties and spatial reference.

The properties for geometry include points, paths, rings. The Following geometry types are supported: Point, Polyline, Polygon, multipart features and Feature Set, and Record Set.

(デフォルト値は次のとおりです False)

Boolean
戻り値
データ タイプ説明
Geometry

AsShape returns a geometry object (PointGeometry, Multipoint, Polyline, or Polygon) based on the input GeoJSON or esriJSON object.

import arcpy
gjPoint = {"type": "Point", "coordinates": [5.0, 5.0]}
ptGeometry = arcpy.AsShape(gjPoint)

コードのサンプル

Create a PointGeometry object using a GeoJSON object.
import arcpy
gjPoint = {"type": "Point", "coordinates": [5.0, 5.0]}
ptGeometry = arcpy.AsShape(gjPoint)
Create a PointGeometry object using an Esri JSON object.
import arcpy
esri_json = {"x": -122.65, "y": 45.53, "spatialReference": {"wkid": 4326}}
# Set the second parameter to True to use an esri JSON
ptGeometry = arcpy.AsShape(esri_json, True)
Create a Multipoint object using a GeoJSON object.
import arcpy
gjMultiPoint = {
    "type": "MultiPoint",
    "coordinates": [[5.0, 4.0], [8.0, 7.0]]}
multiPoint = arcpy.AsShape(gjMultiPoint)
Create a Multipoint object using an Esri JSON object.
import arcpy
esri_json = {
    "points" : [
        [-97.06138, 32.837],
        [-97.06133, 32.836],
        [-97.06124, 32.834],
        [-97.06127, 32.832]],
    "spatialReference" : {"wkid" : 4326}}
# Set the second parameter to True to use an esri JSON
multiPoint = arcpy.AsShape(esri_json, True)
Create a Polyline object using a GeoJSON object.
import arcpy
gjLineString = {
    "type": "LineString",
    "coordinates": [[5.0, 4.0], [8.0, 7.0]]}
polyLine = arcpy.AsShape(gjLineString)
Create a Polyline object using an Esri JSON object.
import arcpy
esri_json = {
    "paths" : [
        [[-97.08, 32.8], [-97.05, 32.6], [-97.06, 32.7], [-97.07, 32.6]],
        [[-97.4, 32.5], [-97.2, 32.75]]],
    "spatialReference" : {"wkid" : 4326}}
# Set the second parameter to True to use an esri JSON
polyLine = arcpy.AsShape(esri_json, True)
Create a multipart Polyline object using a GeoJSON object.
import arcpy
gjMultiLineString = {
    "type": "MultiLineString",
    "coordinates": [
        [[5.0, 4.0], [8.0, 7.0]],
        [[4.0, 5.0], [7.0, 8.0]]]}
mpPolyLine = arcpy.AsShape(gjMultiLineString)
Create a Polygon object using a GeoJSON object.
import arcpy
gjPolygon = {
    "type": "Polygon",
    "coordinates": [
        [[10.0, 0.0], [20.0, 0.0], [20.0, 10.0], [10.0, 10.0], [10.0, 0.0]]]}
polygon = arcpy.AsShape(gjPolygon)
Create a Polygon with a hole object using a GeoJSON object.
import arcpy
gjPolygonWithHole = {
    "type": "Polygon",
    "coordinates": [
        [[10.0, 0.0], [20.0, 0.0], [20.0, 10.0], [10.0, 10.0], [10.0, 0.0]],
        [[12.0, 2.0], [18.0, 2.0], [18.0,  8.0], [12.0,  8.0], [12.0, 2.0]]]}
polygonWithHole = arcpy.AsShape(gjPolygonWithHole)

関連トピック

9/14/2013