libpysal.weights.wsp2da

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

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

Parameters:
dataarray/list/pd.Series

1d array-like data with dimensionality conforming to wsp

wsplibpysal.weights.WSP

Sparse 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 da2WSP, testDataArray, wsp2da
>>> da = testDataArray()
>>> da.shape
(3, 4, 4)
>>> wsp = da2WSP(da, z_value=2)
>>> data = np.random.randint(0, 255, len(wsp.index))
>>> da1 = w2da(data, wsp)