Skip to main content

UnitConversion

汇总

将像素从一个单位转换到另一个单位。 它支持转换距离、速度和温度。

讨论

有关此函数工作原理的详细信息,请参阅 单位转换 栅格函数。

栅格对象所引用的栅格数据集是临时性的。 要将其设置为永久,可以调用栅格对象的 save 方法。

语法

UnitConversion(raster, {from_unit}, {to_unit})

参数 说明 数据类型

raster

The input raster that will contain the converted units.

Raster

from_unit

The original unit type of the pixels.

  • MetersPerSecond—Meters per second

  • KilometersPerHour—Kilometers per hour

  • Knots—Knots

  • FeetPerSecond—Feet per second

  • MilesPerHour—Miles per hour

  • Celsius—Celsius

  • Fahrenheit—Fahrenheit

  • Kelvin—Kelvin

  • inches—Inches

  • Feet—Feet

  • Yards—Yards

  • Miles—Miles

  • NauticalMiles—Nautical miles

  • Millimeters—Millimeters

  • Centimeters—Centimeters

  • Meters—Meters

(默认值为 None)

String

to_unit

The converted unit type of the pixels.

  • MetersPerSecond—Meters per second

  • KilometersPerHour—Kilometers per hour

  • Knots—Knots

  • FeetPerSecond—Feet per second

  • MilesPerHour—Miles per hour

  • Celsius—Celsius

  • Fahrenheit—Fahrenheit

  • Kelvin—Kelvin

  • inches—Inches

  • Feet—Feet

  • Yards—Yards

  • Miles—Miles

  • NauticalMiles—Nautical miles

  • Millimeters—Millimeters

  • Centimeters—Centimeters

  • Meters—Meters

(默认值为 None)

String

返回值

数据类型 说明

Raster

输出栅格。

代码示例

UnitConversion 示例 1

本示例将计算从米/秒到千米/小时的输入栅格。

from arcpy.sa import *
out_unit_raster = UnitConversion("wind_speed_meter_per_second.tif",
                                 "MetersPerSecond'", "KilometersPerHour")
out_unit_raster.save("C:/arcpyExamples/outputs/wind_speed_km_per_hour.tif")
UnitConversion 示例 2

本示例将计算从摄氏度到开氏度的输入温度栅格。

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

# Set the analysis environments
arcpy.env.workspace = "C:/arcpyExamples/data"

# Set the local variables
inRaster_File = "temperature_celcius.tif"
from_unit = 'Celsius'
to_unit = 'Kelvin'

# Run UnitConversion function
out_unit_raster = UnitConversion(inRaster_File, from_unit, to_unit)

# Save the output
out_unit_raster.save("C:/arcpyExamples/outputs/temperature_kelvin.tif")