Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Enabling rasterio.vrt.WarpedVRT with xr.open_rasterio #2588

Closed
scottyhq opened this issue Dec 4, 2018 · 0 comments · Fixed by #2589
Closed

Enabling rasterio.vrt.WarpedVRT with xr.open_rasterio #2588

scottyhq opened this issue Dec 4, 2018 · 0 comments · Fixed by #2589

Comments

@scottyhq
Copy link
Contributor

scottyhq commented Dec 4, 2018

This is not a bug, but rather a feature request and discussion opener for changes to the open_rasterio function

Currently open_rasterio (xarray version 0.11) only accepts filepath strings and does not work with In-memory rasterio.vrt.WarpedVRT objects. I have a solution (see pull request), but it's likely not the best one (Many context managers can feel odd), see example below:

# Lazy in-memory warping from UTM to WGS84 lat/lon
with env:
    with rasterio.open(url) as src:
        da = xr.open_rasterio(src)
        print(da.crs, da.sizes)
        with WarpedVRT(src, crs='epsg:4326') as vrt:
            with xr.open_rasterio(vrt) as da:
                print(da.crs, da.sizes)

#+init=epsg:32610 (1, 7531, 7751)
#+init=epsg:4326 +no_defs (1, 5981, 9183)

More detailed gist here:
https://gist.github.com/scottyhq/ae90084adaf25e3b361b096d555c45f1

Problem description

In-memory “virtual” reprojection is a key feature of rasterio (see https://gist.github.com/sgillies/7e5cd548110a5b4d45ac1a1d93cb17a3), and it would be fantastic if this worked w/ xarray and dask distributed. Many workflows require warping between WGS84 lat/lon, UTM, Google Mercator, and rasterio can handle most any other projection.

related to: #1575, #2042, #2288
dask/dask#3255
Seems like some synergy here with geoxarray and salem
@mrocklin, @fmaussion, @geoxarray

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant