# libpysal.weights.wsp2da

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

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

  Parameters:
    data array/list/pd.Series

      1d array-like data with dimensionality conforming to wsp

    wsp `libpysal.weights.WSP`

      Sparse weights object aligned with passed data

    attrs `Dictionary`

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

    coords Dictionary/xarray.core.coordinates.DataArrayCoordinates

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

  Returns:
    da `xarray.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)