# Can a reprojection/change of CRS operation be done lazily using rioXarray?

**URL:** <https://discourse.pangeo.io/t/can-a-reprojection-change-of-crs-operation-be-done-lazily-using-rioxarray/4468>\
**Category:** Science\
**Created:** [September 2, 2024, 3:13pm UTC](https://discourse.pangeo.io/t/can-a-reprojection-change-of-crs-operation-be-done-lazily-using-rioxarray/4468 "2024-09-02T15:13:51Z")\
**Posts on this page:** 1\
**Showing post:** 21

<div class="post-metadata">

**Author:** ![Len](https://yyz2.discourse-cdn.com/flex030/user_avatar/discourse.pangeo.io/len/32/2954_2.png) [@Len](https://discourse.pangeo.io/u/Len)\
**Post date:** [September 23, 2024, 5:10pm UTC](https://discourse.pangeo.io/t/can-a-reprojection-change-of-crs-operation-be-done-lazily-using-rioxarray/4468/21 "2024-09-23T17:10:09Z")

</div>

I added an example of using gdal with zarr (on gcs) to build a vrt for resampling and opening with rioxarray [here](https://discourse.pangeo.io/t/resampling-zarr-backed-xarray-wth-vrts-and-gdal-support-for-zarr/3829/6):

```auto
gdalbuildvrt -tr .1 .1 test.vrt "vrt://ZARR:/vsigs/store/group:/variable_1:1?a_ullr=-180,90,180,-90"

```

Then you can open lazily like

```auto
rioxarray.open_rasterio("test.vrt", chunks="auto")

```

You could likely do the same thing but with gdal warped for reprojection.

I regularly use vrt inside rioxarray.open\_rasterio and it supports lazy evaluation pretty well. I have even used gdalwarp to reproject all to many disjoint tiles into a common crs, then used gdalbuildvrt to resample all being done in a lazy fashion with dask and finally open with rioxarray with chunks.

My most common use case is going from COG to Zarr though. I don’t actively reproject/resample zarr this way.

For the case with many many cogs to Zarr, I have found these GDAL env vars are important to tune:

```auto
GDAL_HTTP_MULTIPLEX
CPL_VSIL_CURL_CACHE_SIZE
VSI_CACHE
GDAL_CACHEMAX
GDAL_HTTP_VERSION
VSI_CACHE_SIZE
GDAL_DISABLE_READDIR_ON_OPEN
GDAL_HTTP_MERGE_CONSECUTIVE_RANGES

```

I added a gist [here](https://gist.github.com/ljstrnadiii/f3e2e76fdbc81cd9abcbf7c242510d8c) to show how I first build a mosaic for all tifs in a crs (think one UTM zone) using gdalbuildvrt, then reproject resample with gdalwarp for each crs, then finally merge into one large mosaic with gdalbuildvrt and open with rioxarray.open\_raster using dask.

---

_[View the full topic](https://discourse.pangeo.io/t/can-a-reprojection-change-of-crs-operation-be-done-lazily-using-rioxarray/4468)._
