!= (Not Equal)

サマリ

Returns 1 for cells where the first raster is not equal to the second raster and 0 for cells where it is equal.

No Equal To (Relational) operator illustration
OutRas = Raster("InRas1") != 2

説明

Returns 1 for cells where the first raster does not equal the second raster and 0 for cells where it does.

ラスタ入力で演算子を使用すると、結果はラスタになります。ただし、すべての入力値が数字の場合、結果は数字になります。

複数の演算子が式に使用されている場合、それらは必ずしも左から右へという順に実行されるわけではありません。優先順位値が最も高い演算子が最初に実行されます。演算子の優先順位に関する詳細については、「演算子の優先順位のテーブル」をご参照ください。実行順序の制御には、括弧が使用できます。

ブール(~&^|)演算子には、関係(<<=>>===!=)演算子よりも高い優先度があります。したがって、ブール演算子が関係演算子と同じ式に使用されている場合、ブール演算子が最初に実行されます。実行の順序を変更するには、括弧を使用します。

複数の関係および(または)ブール演算子が 1 つの式で連続して使用されているときは、場合によっては実行されない可能性があります。このような問題を避けるために、式に適切な括弧を使用して、演算の実行順序を明示的に定義します。詳細については、「複雑なステートメントのルール」をご参照ください。

評価を実行するには、2 つの入力値が必要です。

この演算子では、入力の順序は結果に影響しません。

構文

in_raster_or_constant1 != in_raster_or_constant2
オペランド説明データ タイプ
in_raster_or_constant1

The input that will be compared to for inequality by the second input.

入力値の 1 つがラスタで、もう 1 つがスカラーである場合は、入力ラスタの各セルに実行される評価を持った出力ラスタが作成されます。

Raster Layer | Constant
in_raster_or_constant2

The input that will be compared from for inequality by the first input.

入力値の 1 つがラスタで、もう 1 つがスカラーである場合は、入力ラスタの各セルに実行される評価を持った出力ラスタが作成されます。

Raster Layer | Constant

リターン

名前説明データ タイプ
out_raster

出力ラスタ オブジェクト。

Where cell values in the first input and second inputs are not equal, the output cell value will be 1. If the values are equal, the output value will be 0.

Raster

コードのサンプル

!= (Not Equal) example 1 (Python window)

This sample performs a Not Equal operation on two input rasters.

import arcpy
from arcpy import env
from arcpy.sa import *
env.workspace = "C:/sapyexamples/data"
outNotEqual = Raster("degs") != Raster("negs")
outNotEqual.save("C:/sapyexamples/output/outne")
!= (Not Equal) example 2 (stand-alone script)

This sample performs a Not Equal operation on two input rasters.

# Name: Op_NotEqual_Ex_02.py
# Description: Performs a relational not-equal operation on two
#              inputs on a cell-by-cell basis
# Requirements: Spatial Analyst Extension

# Import system modules
import arcpy
from arcpy import env
from arcpy.sa import *

# Set environment settings
env.workspace = "C:/sapyexamples/data"

# Set local variables
inRaster1 = Raster("degs")
inRaster2 = Raster("negs")

# Check out the ArcGIS Spatial Analyst extension license
arcpy.CheckOutExtension("Spatial")

# Execute NotEqual
outNotEqual = inRaster1 != inRaster2

# Save the output 
outNotEqual.save("C:/sapyexamples/output/outnotequal")

環境

関連項目


7/10/2012