pysal / tobler

Spatial interpolation, Dasymetric Mapping, & Change of Support
https://pysal.org/tobler
BSD 3-Clause "New" or "Revised" License
145 stars 30 forks source link

Add support for `xarray` objects #133

Open darribas opened 3 years ago

darribas commented 3 years ago

Opening up the discussion here to see whether it'd make sense and if so how. Would you @knaaptime be open to explore support for xarray objects instead of paths on disk for rasters?

Taken from #130 :

One more general question I got as I was re-reading your code: why do you tie the raster to a file? I'm thinking the same way we take GeoDataFrame objects instead of shapefile paths, would you consider taking DataArray objects? From a user perspective, I could see myself wanting to do some pre-processing on the raster before feeding it to extract_raster_features (for example combining different values into a binary mask, or compute an index with a threshold for the mask). More generally, it'd decouple analysis from disk objects, so you could use this right away from a file read over the web (although it's true rasterio takes remote paths...). Just a thought and not necessarily for this PR but, if of interest, I'd open an issue to track progress on it...

I think if this is of interest, we could use this issue to centralise discussion about what that'd look like and then try to split it into smaller pieces we can start accomplishing. I think for the project @martinfleis and I are working on, this would be a very nice feature to have since our file on disk is a .vrt that points to many files, etc. Being able to pre-process as we want that before passing to tobler would be a big plus.

knaaptime commented 3 years ago

definitely! :)

knaaptime commented 2 years ago

xref, I wanted to add an example using https://easystac.readthedocs.io/en/latest/ which has super high resolution imagery and uses xarray as their data structure