Comments (5)
The band math attributes below will now be updated.
new_attrs['nodatavals'] = (nodata)
new_attrs['scales'] = (1.0)
new_attrs['offsets'] = (0.0)
I also added a 'vi' attribute. When I merge your examples I will push these changes with version 1.2.5
.
from geowombat.
Maybe I should show the exact issue I am seeing, maybe not related to attributes.
with gw.config.update(sensor='rgbn', scale_factor=0.0001):
with gw.open([rgbn_suba, rgbn_subb],
band_names=['blue', 'green', 'red', 'nir'],
mosaic=True,
bounds_by='union') as ds_mos:
ndvi = ds_mos.gw.ndvi()
# Xarray drops attributes
attrs = ndvi.attrs.copy()
ndvi.attrs['nodatavals'] = (0.0)
ndvi.attrs['scales'] = (1.0)
ndvi.attrs['offsets'] = (0.0)
ndvi.attrs = attrs
print(attrs)
# Write the data to a GeoTiff
ndvi.gw.to_raster( '/home/mmann1123/Desktop/output2.tif',
verbose=1,
n_workers=4, # number of process workers sent to ``concurrent.futures``
n_threads=2, # number of thread workers sent to ``dask.compute``
n_chunks=200) # number of window chunks
throws:
ValueError: Source shape (1, 64) is inconsistent with given indexes 1
I am assuming it has to do with the use of the config, but not sure there is a config for single band...
from geowombat.
I agree, the attributes should be updated for band math.
I will see if I can figure out the shape issue. One quick note--if you specify the sensor in the configuration then you don't have to specify the band names in gw.open()
. But, I see that I named the files incorrectly. They are stored as blue, green, red, NIR, not red, gree, blue, NIR.
from geowombat.
Ok, the attributes were not the issue when writing the results to file. The problem seems to be the chunk size. The image block size is 64x64, which led to a single row/column at the image edge. Using a larger chunk size fixed it.
>>> with gw.config.update(sensor='bgrn', scale_factor=0.0001):
>>>
>>> with gw.open([rgbn_suba, rgbn_subb],
>>> mosaic=True,
>>> bounds_by='union',
>>> chunks=256) as ds_mos:
>>>
>>> attrs = ds_mos.attrs.copy()
>>>
>>> # Calculate the NDVI
>>> ndvi = ds_mos.gw.ndvi()
>>>
>>> # Mask the NDVI
>>> masker = ndvi >= -0.25
>>> ndvi = ndvi * masker
>>>
>>> # The 'no data' values are set as None from `ds_mos.gw.ndvi()`
>>> # After masking, set the 'no data' values as 0.
>>> ndvi.attrs = attrs
>>> ndvi.attrs['nodatavals'] = (0)
>>>
>>> # Write the data to a GeoTiff
>>> ndvi.gw.to_raster('ndvi.tif',
>>> overwrite=True,
>>> n_workers=4, # number of process workers sent to ``concurrent.futures``
>>> n_threads=2, # number of thread workers sent to ``dask.compute``
>>> n_chunks=200, # number of window chunks
>>> compress='lzw')
from geowombat.
I am closing this for now, but we can reopen if there are additional attributes that we want to add.
from geowombat.
Related Issues (20)
- conda-forge issues HOT 13
- angles tests HOT 2
- conda optional extras HOT 13
- Ml no data HOT 2
- gw.open bug?? HOT 5
- Apply example
- Apply on bands error HOT 1
- Apply HOT 2
- Expand pinned python version HOT 1
- Feedstock Issues HOT 1
- Failed to Install Geowombat on pip and conda HOT 12
- Requirement differences between package & conda-forge HOT 6
- Coordinating efforts on potential new geospatial Xarray accessor HOT 2
- Regression capability in geowombat HOT 3
- ARM Installation Issues HOT 9
- Apply interpolation HOT 4
- Stac import HOT 2
- series.apply big tiff / bad block
- EVI equation is wrong HOT 2
- Support for pyproj 3.4.1? HOT 6
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from geowombat.