ArcGIS for Desktop

  • ドキュメント
  • 価格
  • サポート

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

ArcGIS Online

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

ArcGIS for Desktop

完全なプロ仕様の GIS

ArcGIS for Server

エンタープライズ GIS

ArcGIS for Developers

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

ArcGIS Solutions

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

ArcGIS Marketplace

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

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

ヘルプ

  • ホーム
  • はじめに
  • マップ
  • 解析
  • データ管理
  • ツール
  • その他...

解析レイヤーにフィールドを追加 (Add Field to Analysis Layer)

Network Analyst のライセンスで利用可能。

  • サマリ
  • 使用法
  • 構文
  • コードのサンプル
  • 環境
  • ライセンス情報

サマリ

ネットワーク解析レイヤーのサブレイヤーにフィールドを追加します。

使用法

  • このツールは [ロケーションの追加 (Add Locations)] ツールとともによく使用され、入力フィーチャからサブレイヤーへフィールドを転送します。たとえば、UniqueID と呼ばれるフィールドを入力フィーチャから到達圏レイヤーの施設サブレイヤーに転送したい場合、このツールを使用して最初に UniqueID フィールドを施設サブレイヤーに追加して、次に [ロケーションの追加 (Add Locations)] ツールのフィールド割り当てを使用して、UniqueID フィールドへの入力値を設定します。

  • フィールドはネットワーク解析レイヤーのすべてのサブレイヤーに追加することができます。

構文

AddFieldToAnalysisLayer_na (in_network_analysis_layer, sub_layer, field_name, field_type, {field_precision}, {field_scale}, {field_length}, {field_alias}, {field_is_nullable})
パラメータ説明データ タイプ
in_network_analysis_layer

新しいフィールドを追加するネットワーク解析レイヤー。

Network Analyst Layer
sub_layer

新しいフィールドを追加するネットワーク解析レイヤーのサブレイヤー。

String
field_name

ネットワーク解析レイヤーの指定されたサブレイヤーに追加されるフィールド名。

String
field_type

新しいフィールドの作成に使用されるフィールドのタイプ。

  • LONG — Whole numbers between -2,147,483,648 and 2,147,483,647.
  • TEXT —Any string of characters.
  • FLOAT — Fractional numbers between -3.4E38 and 1.2E38.
  • DOUBLE — Fractional numbers between -3.4E38 and 1.2E38.
  • SHORT — Whole numbers between -32,768 and 32,767.
  • DATE —Date and/or time.
  • BLOB —Long sequence of binary numbers. You need a custom loader or viewer or a third-party application to load items into a BLOB field or view the contents of a BLOB field.
String
field_precision
(オプション)

フィールドに格納できる桁数。小数点以下であるかどうかにかかわらず、すべての桁が対象になります。

パラメーター値は数値フィールド タイプのみに有効です。

Long
field_scale
(オプション)

フィールドに格納できる小数点以下の桁数。このパラメーターは、float タイプと double タイプのデータ フィールドのみで使用します。

Long
field_length
(オプション)

追加するフィールドの長さ。この値は、フィールドの各レコードに許容される文字の最大数を設定します。このオプションは、タイプがテキストまたはブロブのフィールドに対してのみ適用されます。

Long
field_alias
(オプション)

フィールド名に割り当てる別名。この名前は、あいまいなフィールド名にわかりやすい名前を付けるために使用します。フィールド エイリアスのパラメーターは、ジオデータベースとカバレッジに対してのみ適用されます。

String
field_is_nullable
(オプション)

このフィールドに NULL 値を含めることができるかどうかを指定します。NULL 値は、ゼロや空のフィールドとは異なり、ジオデータベースのフィールドのみでサポートされます。

  • NON_NULLABLE —フィールドで NULL 値を使用できません。
  • NULLABLE —フィールドで NULL 値を使用できます。これがデフォルトです。
Boolean

コードのサンプル

AddFieldToAnalysisLayer (解析レイヤーにフィールドを追加) の例 1 (Python ウィンドウ)

次の Python ウィンドウ スクリプトは、UniqueID フィールドを到達圏ネットワーク解析レイヤーの 施設サブレイヤーに追加する方法を示しています。

arcpy.na.AddFieldToAnalysisLayer("Service Area", "Facilities", "UniqueID",
                                    "LONG")
AddFieldToAnalysisLayer (解析レイヤーにフィールドを追加) の例 2 (ワークフロー)

次のスタンドアロン Python スクリプトは、AddFieldToAnalysisLayer (解析レイヤーにフィールドを追加) 機能を使用して、入力の消防署フィーチャの StationID フィールドを到達圏解析から計算される 2 分、3 分、5 分以内の到達圏ポリゴン フィーチャに転送する方法を示しています。StationID フィールドは、消防署フィーチャの他の属性を到達圏ポリゴン フィーチャと結合するために使用することができます。

# Name: AddFieldToAnalysisLayer_Workflow.py
# Description: Transfers the Address field from the input fire station 
#              features to the 2-,3-, and 5-minute service area polygon features
#              calculated from a service area analysis. The Address field can 
#              be used to join other attributes from the fire station features 
#              to the service area polygon features.
# Requirements: Network Analyst Extension 

#Import system modules
import arcpy
from arcpy import env

try:
    #Check out the Network Analyst extension license
    arcpy.CheckOutExtension("Network")

    #Set environment settings
    env.workspace = "C:/data/SanFrancisco.gdb"
    env.overwriteOutput = True
    
    #Set local variables
    inNetworkDataset = "Transportation/Streets_ND"
    outNALayerName = "FireStationsCoverage"
    impedanceAttribute = "TravelTime"
    defaultBreakValues = "2 3 5"   
    fieldName = "Address"
    fieldType = "TEXT"
    inFeatures = "Analysis/FireStations"
    searchTolerance = "2 Miles"
    outFeatures = outNALayerName + "Area"
    saFacilities = "Facilities"
    saPolygons = "SAPolygons"
    
    #Create a new service area analysis layer. For this scenario, the default 
    #value for all the remaining parameters statisfies the analysis requirements
    outNALayer = arcpy.na.MakeServiceAreaLayer(inNetworkDataset, outNALayerName,
                                               impedanceAttribute,"",
                                               defaultBreakValues)
    
    #Get the layer object from the result object. The service layer can now be
    #referenced using the layer object.
    outNALayer = outNALayer.getOutput(0)
    
    #Get the names of all the sublayers within the service area layer.
    subLayerNames = arcpy.na.GetNAClassNames(outNALayer)
    #Stores the layer names that we will use later
    facilitiesLayerName = subLayerNames[saFacilities]
    polygonLayerName = subLayerNames[saPolygons]
    
    #Get the layer objects for all the sublayers within the service area layer
    #The first layer returned by ListLayers is the Service area layer itself
    #which we don't want to use.
    subLayers = {}
    for layer in arcpy.mapping.ListLayers(outNALayer)[1:]:
        subLayers[layer.datasetName] = layer
    #Store the layer objects that we will use later
    facilitiesLayer = subLayers[saFacilities]
    polygonLayer = subLayers[saPolygons]
    
    #Add a Address field to the Facilities sublayer of the service area layer.
    #This is done before loading the fire stations as facilities so that the 
    #Address values can be transferred from the input features to the 
    #Facilities sublayer. The service area layer created previously is 
    #referred by the layer object.
    arcpy.na.AddFieldToAnalysisLayer(outNALayer,facilitiesLayerName,fieldName,
                                     fieldType)
    
    #Add the fire station features as Facilities and map the Name and the 
    #Address properties from the Name and Address fields from fire station
    #features using the field mappings.
    fieldMappings = arcpy.na.NAClassFieldMappings(outNALayer, facilitiesLayerName)
    fieldMappings['Name'].mappedFieldName = "Name"
    fieldMappings['Address'].mappedFieldName = "Address"
    arcpy.na.AddLocations(outNALayer,facilitiesLayerName,inFeatures,
                          fieldMappings, searchTolerance)
    
    #Solve the service area layer
    arcpy.na.Solve(outNALayer)
    
    #Transfer the Address field from Facilities sublayer to Polygons sublayer 
    #of the service area layer since we wish to export the polygons. The 
    #FacilityID field in Polygons sub layer is related to the ObjectID field in
    #the Facilities sub layer. 
    arcpy.management.JoinField(polygonLayer, "FacilityID",facilitiesLayer,
                               "ObjectID", fieldName)
    
    #Export the Polygons sublayer to a feature class on disk.
    arcpy.management.CopyFeatures(polygonLayer, outFeatures)
    
    print "Script completed successfully"
    
except Exception as e:
    # If an error occurred, print line number and error message
    import traceback, sys
    tb = sys.exc_info()[2]
    print "An error occured on line %i" % tb.tb_lineno
    print str(e)

環境

  • 現在のワークスペース

ライセンス情報

  • ArcGIS for Desktop Basic: ○
  • ArcGIS for Desktop Standard: ○
  • ArcGIS for Desktop Advanced: ○

関連トピック

  • 解析ツールセットの概要
このトピックへのフィードバック

ArcGIS for Desktop

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

ArcGIS プラットフォーム

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

Esri について

  • 会社概要
  • 採用情報
  • スタッフ ブログ
  • ユーザ カンファレンス
  • デベロッパ サミット
Esri
© Copyright 2016 Environmental Systems Research Institute, Inc. | プライバシー | リーガル