AsShape

サマリ

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

構文

AsShape (geojson_struct)
パラメータ説明データ タイプ
geojson_struct

The geojson_struct includes type and coordinates.

type includes the following strings: Point, LineString, Polygon, MultiPoint, and MultiLineString.

Dictionary
リターン
データ タイプ説明
Object

AsShape returns a geometry object (PointGeometry, Multipoint, Polyline, or Polygon) based on the input GeoJSON 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 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 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 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 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)

7/10/2012