# libpysal.weights.w2da

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

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

  Parameters:
    data array/list/pd.Series

      1d array-like data with dimensionality conforming to w

    w `libpysal.weights.W`

      Spatial 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 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)