<< (Bitwise Left Shift) operator

Disponible con una licencia de Spatial Analyst.

Disponible con licencia de Image Analyst.

Resumen

Performs a Bitwise Left Shift operation on the binary values of two input rasters.

Ilustración

Bitwise Left Shift illustration
OutRas = Raster("InRas1") << 1

Debate

Cuando se utilice un operador con una entrada de ráster, el resultado será un ráster. Sin embargo, si todas las entradas son números, entonces el resultado es un número.

Cuando se utilizan varios operadores en una expresión, no necesariamente se ejecutan por orden de izquierda a derecha. El operador con el valor de jerarquía más alto será el que se ejecute primero. Para obtener más información sobre la jerarquía del operador, consulte la tabla de jerarquía del operador. Puede utilizar paréntesis para controlar el orden de ejecución.

The bitwise operators work on 32-bit integers.

If floating-point values are input, they are converted to integer values through truncation before the bitwise operation is performed. The output values are always integer.

Two inputs (rasters or numbers) are necessary for the bitwise operation to take place.

The order of input is relevant in the Bitwise Left Shift operation.

Binary values are stored in two's complement.

The leftmost bit position is reserved for the sign of the value (positive or negative). If the integer is positive, the bit position is zero; if it's negative, the bit position is one.

The Bitwise Left Shift operation does no wrapping of bits. The leftmost bit is dropped.

Another way to perform the Bitwise Left Shift operation is a <<= b, which is an alternative way to write a = a << b.

Si ambas entradas son rásteres de una banda o una de las entradas es una constante, la salida será un ráster de una única banda.

Si ambas entradas son rásteres multibanda o una de las entradas es una constante, la salida será un ráster multibanda. El número de bandas en cada entrada multibanda debe ser el mismo.

El operador realizará la operación en cada banda de una entrada con respecto a la banda correspondiente de la otra entrada. Si una de las entradas es un ráster multibanda y la otra entrada es una constante, el operador realizará la operación con respecto al valor constante de cada banda de la entrada multibanda.

Sintaxis

in_raster_or_constant1 << in_raster_or_constant2
OperandoExplicaciónTipo de datos
in_raster_or_constant1

El ráster de entrada en el cual se realiza el cambio.

La entrada puede ser entera o punto flotante, pero los valores de puntos flotantes se convertirán en enteros antes de que se realice la operación de bit a bit.

If the first input is a raster and the second is a scalar, an output raster is created with each input raster value being bitwise left shifted by the scalar value.

Raster Layer | Constant
in_raster_or_constant2

The input raster defining the number of positions to shift the bits.

La entrada puede ser entera o punto flotante, pero los valores de puntos flotantes se convertirán en enteros antes de que se realice la operación de bit a bit.

If the first input is a scalar and the second is a raster, an output raster is created with each input raster value defining the bitwise left shift for the scalar value.

Raster Layer | Constant

Valor de retorno

NombreExplicaciónTipo de datos
out_raster

El objeto ráster de salida.

The cell values are the result of a Bitwise Left Shift operation on the inputs.

Raster

Muestra de código

<< (Bitwise Left Shift) example 1 (Python window)

This sample performs a Bitwise Left Shift operation on two input rasters.

import arcpy
from arcpy import env
from arcpy.ia import *
env.workspace = "C:/iapyexamples/data"
outBitwiseLS = Raster("degs") << Raster("negs")
outBitwiseLS.save("C:/iapyexamples/output/outbitls.tif")
<< (Bitwise Left Shift) example 2 (stand-alone script)

This sample performs a Bitwise Left Shift operation on two input rasters.

# Name: Op_BitwiseLeftShift_Ex_02.py
# Description: Performs a Bitwise Left Shift operation on the binary
#     values of two input rasters
# Requirements: Image Analyst Extension

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

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

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

# Execute BitwiseLeftShift
outBitwiseLShift = inRaster1 << inRaster2

# Save the output 
outBitwiseLShift.save("C:/iapyexamples/output/outlshift")

Temas relacionados