ArcGIS Desktop

  • ArcGIS Pro
  • ArcMap

  • My Profile
  • ヘルプ
  • Sign Out
ArcGIS Desktop

ArcGIS Online

組織のマッピング プラットフォーム

ArcGIS Desktop

完全なプロ仕様の GIS

ArcGIS Enterprise

エンタープライズ GIS

ArcGIS for Developers

位置情報利用アプリの開発ツール

ArcGIS Solutions

各種業界向けの無料のテンプレート マップおよびテンプレート アプリケーション

ArcGIS Marketplace

組織で使えるアプリとデータを取得

  • ドキュメント
  • サポート
Esri
  • サイン イン
user
  • マイ プロフィール
  • サイン アウト

ArcMap

  • ホーム
  • はじめに
  • マップ
  • 解析
  • データ管理
  • ツール
  • エクステンション

AsShape

  • サマリー
  • 説明
  • 構文
  • コードのサンプル

サマリー

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

説明

注意:

AsShape does not support GeoJSON coordinate reference system objects; the spatial reference of a geometry object created from GeoJSON will be Unknown.

構文

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

Sets whether the input JSON is evaluated as Esri JSON or GeoJSON. If True, the input is evaluated as Esri JSON.

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

Boolean

戻り値

データ タイプ説明
Geometry

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

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

If the Esri JSON is a feature set, AsShape will return a FeatureSet. ArcGIS REST API specification defines feature set as a collection of features with a specific geometry type, fields, and a spatial reference. The JSON to Features tool can be used to convert Esri JSON directly into a feature class.

コードのサンプル

AsShape example 1

Create a PointGeometry object using a GeoJSON object.

import arcpy

geojson_point = {
    "type": "Point", 
    "coordinates": [5.0, 5.0]}
point = arcpy.AsShape(geojson_point)
AsShape example 2

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
point = arcpy.AsShape(esri_json, True)
AsShape example 3

Create a Multipoint object using a GeoJSON object.

import arcpy

geojson_multipoint = {
    "type": "MultiPoint",
    "coordinates": [[5.0, 4.0], [8.0, 7.0]]}
multipoint = arcpy.AsShape(geojson_multipoint)
AsShape example 4

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)
AsShape example 5

Create a Polyline object using a GeoJSON object.

import arcpy

geojson_linestring = {
    "type": "LineString",
    "coordinates": [[5.0, 4.0], [8.0, 7.0]]}
polyline = arcpy.AsShape(geojson_linestring)
AsShape example 6

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)
AsShape example 7

Create a multipart Polyline object using a GeoJSON object.

import arcpy

geojson_multilinestring = {
    "type": "MultiLineString",
    "coordinates": [
        [[5.0, 4.0], [8.0, 7.0]],
        [[4.0, 5.0], [7.0, 8.0]]]}
polyline = arcpy.AsShape(geojson_multilinestring)
AsShape example 8

Create a Polygon object using a GeoJSON object.

import arcpy

geojson_polygon = {
    "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(geojson_polygon)
AsShape example 9

Create a Polygon with a hole object using a GeoJSON object.

import arcpy

geojson_polygon = {
    "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]]]}
polygon = arcpy.AsShape(geojson_polygon)

関連トピック

  • FromWKB
  • FromWKT

ArcGIS Desktop

  • ホーム
  • ドキュメント
  • サポート

ArcGIS プラットフォーム

  • ArcGIS Online
  • ArcGIS Desktop
  • ArcGIS Enterprise
  • ArcGIS for Developers
  • ArcGIS Solutions
  • ArcGIS Marketplace

Esri について

  • 会社概要
  • 採用情報
  • Esri ブログ
  • ユーザ カンファレンス
  • デベロッパ サミット
Esri
ご意見・ご感想をお寄せください。
Copyright © 2019 Esri. | プライバシー | リーガル