RasterToXarray

概要

Converts a multidimensional raster to an xarray.Dataset containing labeled arrays (data array objects) with aligned dimensions.

ディスカッション

xarray is a Python module that supports multidimensional arrays with labels of dimensions, coordinates, and attributes. It builds on and integrates NumPy and pandas, and deals with multidimensional data in the Python SciPy ecosystem for numerical computing. For more information, refer to the xarray documentation.

You may want to convert an ArcGIS multidimensional raster to an xarray dataset to perform the following kinds of operations:

  • Implement one of the many functions in the xarray module, for example, run multidimensional interpolation, resampling, and grouped operations on an xarray.DataArray object.
  • Take advantage of other Python modules that directly work with xarray.DataArray objects in various domains including geosciences, machine learning, and more. For example, the import EOF (Empirical Orthogonal Functions) Python package and perform EOF analysis on data in xarray.DataArray.
  • Convert a multidimensional raster to xarray.DataArray and then to another Python data type or formats, for example, to pandas DataFrame objects, or to netCDF.

構文

RasterToXarray (in_raster)
パラメーター説明データ タイプ
in_raster

The input multidimensional raster to convert to an xarray. It can be a Raster object, a file path to a multidimensional raster dataset, or a netCDF file.

Raster
戻り値
データ タイプ説明
xarray.Dataset

The output xarray.Dataset object.

コードのサンプル

RasterToXarray example

Python window sample for the RasterToXarray function.

import arcpy
import xarray

# Get input Raster multidimensional information
inRas = arcpy.Raster('C:/data/temperature_3hour.crf', True)
inRas.mdinfo

# Convert Raster to Xarray Dataset
xrr = arcpy.ia.RasterToXarray(inRas)

# Upsample the data from originally 3 hour to hourly time interval
newXrr = xrr.resample(StdTime='1H').nearest(tolerance="1H")

#Convert Xarray dataset back to raster 
newRaster = arcpy.ia.RasterToXarray(newXrr)
newRaster.save("C:/output/temperature_hourly.crf")