Closed mmann1123 closed 4 years ago
Looks like the issue is data.filename, not sure if that was intentional or not. see #28
` # Open the input file on disk def to_vrt():
with rio.open(data.filename) as src:
with WarpedVRT(src,
src_crs=src.crs, # the original CRS
crs=data.crs, # the transformed CRS
src_transform=src.transform, # the original transform
transform=data.transform, # the new transform
dtype=data.gw.dtype,
resampling=resampling,
nodata=nodata,
init_dest_nodata=init_dest_nodata,
warp_mem_limit=warp_mem_limit) as vrt:
rio_shutil.copy(vrt, filename, driver='VRT')`
Thanks for catching this. The filename
attribute is a geowombat
attribute. I replaced data.filename
with data.gw.filename
in 4d50e2e.
New issue...
with gw.open(glob('./data/NDWI/*2020*tif'), band_names=['NDWI'],
time_names=['01-01-2020'],
bounds_by='union',mosaic=True,
num_workers=5) as ds:
print(ds)
# Write the data to a VRT
ds.gw.to_vrt('./data/NDWI/NDWI_01-01-2020.vrt')
File "/home/mmann1123/anaconda3/envs/geowombat/lib/python3.7/site-packages/geowombat/core/io.py", line 366, in to_vrt
with rio.open(data.gw.filename) as src:
AttributeError: 'GeoWombatAccessor' object has no attribute 'filename'
Not sure if this is related but it seems like you have two class definitions for GeoWombatAccessor
Yeah, that will have to be an enhancement. At the moment, the geowombat.to_vrt()
function only supports a single raster input file from geowombat.open()
.
I am closing this issue and will open a new one specific to the enhancement of using multiple files with to_vrt()
.
Ran into an issue when mosaicing a single band image and writing to vrt. Sorry not quite sure how to address it. If you point me in the right direction I can try to figure it out. For a working example see a nearly identical dataset here here
`with gw.open(glob('./data/NDWI/2020tif'), band_names=['NDWI'], time_names=['01-01-2020'], bounds_by='union',mosaic=True, num_workers=5) as ds: print(ds)
ds.sel(band=['NDWI']).gw.imshow(robust=True)
File "", line 12, in
gw.to_vrt(data=ds, filename='./data/NDWI/NDWI_01-01-2020.vrt', nodata=0.0)
File "/home/mmann1123/anaconda3/envs/geowombat/lib/python3.7/site-packages/geowombat/core/io.py", line 366, in to_vrt with rio.open(data.filename) as src:
File "/home/mmann1123/anaconda3/envs/geowombat/lib/python3.7/site-packages/xarray/core/common.py", line 233, in getattr "{!r} object has no attribute {!r}".format(type(self).name, name)
AttributeError: 'DataArray' object has no attribute 'filename'
`