libpysal.weights.w2da

libpysal.weights.w2da(data, w, attrs={}, coords=None)[source]

Creates xarray.DataArray object from passed data aligned with W object.

Parameters:
dataarray/list/pd.Series

1d array-like data with dimensionality conforming to w

wlibpysal.weights.W

Spatial weights object aligned with passed data

attrsDictionary

Attributes stored in dict related to DataArray, e.g. da.attrs Default is {} empty dictionary.

coordsDictionary/xarray.core.coordinates.DataArrayCoordinates

Coordinates corresponding to DataArray, e.g. da.coords

Returns:
daxarray.DataArray

instance of xarray.DataArray

Examples

>>> from libpysal.raster import da2W, testDataArray, w2da
>>> da = testDataArray()
>>> da.shape
(3, 4, 4)
>>> w = da2W(da, z_value=2)
>>> data = np.random.randint(0, 255, len(w.index))
>>> da1 = w2da(data, w)