Skip to main content

クラスの引数の変更

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

モデリングしている現象について追加情報を入手したり、別のシナリオをテストしたり、エラーまたは感度分析を実施したり、あるいはエラーを修正したりするために、個々の引数をパラメーターに変更できます。 さまざまな入力引数を変更する方法を次に示します。

クラス値またはプロパティ

  • クラス オブジェクトの値を変更するために、クラスを再作成できます。

    neighborhood = NbrCircle(5, "MAP")
    # The neighborhood object can be changed from a circle to a rectangle
    neighborhood = NbrRectangle(3, 3, "MAP")
    
  • 単一の引数を直接変更するには、オブジェクト内で引数を格納するプロパティにアクセスします。

    >>> neighborhood = NbrCircle(5, "MAP")
    >>> # The following statements change the radius to 7 and the units to CELL
    >>> neighborhood.radius = 7
    >>> neighborhood.units = "CELL"
    >>> print(neighborhood)
    CIRCLE 7 CELL
    
  • オブジェクト内にプロパティとして格納されている数値引数は、代数的に変更できます。

    circle = NbrCircle(5, "CELL")
    # The following statement changes the radius to 5.5
    circle.radius = circle.radius * 1.1
    

    また、代入演算子を使用して値を変更することもできます。

    # The following statement changes the radius to 5.5
    circle.radius *= 1.1
    

Python リストを使用して作成したクラス

  • リストから作成されたクラスの inFeatures リストにエレメントを追加できます。

    >>> arguments = TopoStream(["features1", "features2"])
    >>> arguments.inFeatures.append("features3")
    >>> arguments.inFeatures += ["features4", "features5"]
    >>> print(arguments.inFeatures)
    ['features1', 'features2', 'features3', 'features4', 'features5']
    
  • また、入力リストからエレメントを削除することもできます。

    >>> arguments = TopoStream(["features1", "features2", "features3", "features4", "features5"])
    >>> del arguments.inFeatures[2]
    >>> print(arguments.inFeatures)
    ['features1', 'features2', 'features4', 'features5']
    
  • リスト内の特定のエントリーを変更できます。

    >>> arguments = TopoStream(["features1", "features2"])
    >>> arguments.inFeatures[1] = "lake2"
    >>> print(arguments.inFeatures)
    ['features1', 'lake2']
    

リスト内のリストで作成したクラス

  • リスト内のリストから作成したクラスに対し、分類テーブルのエントリーを変更できます (内部リスト内のエントリーが変更されます)。

    >>> remap = RemapValue([[1, 11], [2, 12], [3, 13]])
    >>> # Change the newValue 12 in the second reclassification to a 10
    >>> remap.remapTable[1][1] = 10
    >>> print(remap.remapTable)
    [[1, 11], [2, 10], [3, 13]]
    
  • 再分類テーブルの個別エントリーは、代数的に変更できます。

    remap = RemapRange([[1, 10, 5], [10, 20, 8], [20, 30, 10]])
    # The following statement increases the endValue 20 by 5 percent
    remap.remapTable[1][1] *= 1.05
    # Another implementation of increasing an entry by 5 percent
    remap.remapTable[1][1] = remapTable.table[1][1] * 1.05
    
  • 再分類テーブルの個々の行を変更できます (内部リスト全体が変更されます)。

    >>> remap = RemapValue([[1, 11], [2, 12], [4, 13]])
    >>> # Change the second reclassification [2, 12] to [3,10]
    >>> remap.table[1] = [3, 10]
    >>> print(remap.remapTable)
    [[1, 11], [3, 10], [4, 13]]
    
  • 再分類テーブルにエントリーを追加できます (内部リストが追加されます)。

    >>> remap = RemapValue([[1, 11], [2, 12], [3, 13]])
    >>> # Add a forth reclassification, [4, 14] to the end
    >>> remap.remapTable.append([4, 14])
    >>> # Another approach for adding a row
    >>> remap.remapTable += [[5, 15]]
    >>> print(remap.remapTable)
    [[1, 11], [2, 12], [3, 13], [4, 14], [5, 15]]
    
  • 再分類テーブルからエントリーを削除できます (内部リストが削除されます)。

    >>> remap = RemapValue([[1, 11], [2, 12], [3, 13], [4, 14], [5, 15]])
    >>> # Delete the entire second reclassification
    >>> del remap.remapTable[1]
    >>> print(remap.remapTable)
    [[1, 11], [3, 13], [4, 14], [5, 15]]
    

リスト内の一連のクラスから作成されたクラス

  • リスト内の一連のクラスから作成されたクラスについて、リスト内の特定のポイントを変更できます。

    >>> points = [Point(0, 5), Point(15, 175)]
    >>> # Change the X value of the second input to 25
    >>> points[1].X = 25
    >>> print(points)
    [<Point (0.0, 5.0, #, #)>, <Point (25.0, 175.0, #, #)>]