jgrss / geowombat

GeoWombat: Utilities for geospatial data

Home Page:https://geowombat.readthedocs.io

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Masking with reproject

mmann1123 opened this issue · comments

@jgrss

It looks like reprojecting is happening before masking no data. Not sure this is urgent but wanted to put it on the radar. Given the way nodata is implemented could we just run mask_nodata() before projection?

import geowombat as gw
import matplotlib.pyplot as plt
from geowombat.data import l8_224078_20200518    

fig, ax = plt.subplots(dpi=200)

# set desired CRS with config.update
with gw.config.update(ref_crs='epsg:32618'):
    # define resampling method
    with gw.open(l8_224078_20200518, 
                 resampling='cubic',
                 nodata=0) as src:
        print(src.crs)
        src.gw.mask_nodata().plot.imshow(robust=True, ax=ax)
plt.tight_layout(pad=1)

output

Thanks, I'll look into this. I think this is happening in WarpedVRT because we pass nodata and the destination CRS and transform to that rasterio method. And this occurs with method='cubic' because 0s (nodata in this image) are converted to 1s.