Comments (9)
Rasterio supports geotiff, which means that they should be supported: https://rasterio.readthedocs.io/en/latest/
Did you try using grid.read_raster
or grid.from_raster
on your geotiff? It seems to work for me.
from pysheds.
@lz80521: Were you able to resolve this problem?
from pysheds.
Hi @mdbartos ! What if I do not have grid defined from beforehand and want to read the tiff file and define the grid file based on the properties of the tiff file?
Is there a way to define the grid geospatial properties manually?
Please let me know..
I tried grid = Grid(['affine=dataset.transform','shape=(219,564)','nodata=-1.79769313486231571e+308','crs=dataset.crs'])
but it fails!
Please let me know.....
from pysheds.
Greetings,
If you call:
grid = Grid.from_raster('/path/to/file.tiff', 'dataset_name')
It should populate the affine transform, shape, and other metadata of grid
automatically.
Alternatively, read_raster
will populate the metadata if it is the first dataset in the grid:
grid = Grid()
grid.read_raster('/path/to/file.tiff', 'dataset_name')
These are probably the most preferred ways of doing it.
If you need to set attributes manually, you can also do so after instantiating a grid:
grid.affine = dataset.transform
grid.shape = dataset.shape
grid.crs = dataset.crs
grid.nodata = -1.79769313486231571e+308
There are some other ways that may be easier or harder depending on your situation, but see if any of those help.
from pysheds.
Hi @mdbartos !
Thanks for the quick reply. After going through other issues with pysheds, I found the problem to be in version of rasterio. I use anaconda's rasterio and the latest release on anaconda does not play well with gdal. I did a pip install of rasterio and it works. And thankfully, it does not messes my other gdal related packages :)
Thanks for the help, I think I can now get my assignment done tomorrow morning!
from pysheds.
lol, no problem
from pysheds.
1 issue though, grid.view('dem') instead of plotting a raster gives this:-
Raster([[-1.79769313e+308, -1.79769313e+308, -1.79769313e+308, ...,
-1.79769313e+308, -1.79769313e+308, -1.79769313e+308],
[-1.79769313e+308, -1.79769313e+308, -1.79769313e+308, ...,
-1.79769313e+308, -1.79769313e+308, -1.79769313e+308],
[-1.79769313e+308, -1.79769313e+308, -1.79769313e+308, ...,
-1.79769313e+308, -1.79769313e+308, -1.79769313e+308],
...,
[-1.79769313e+308, -1.79769313e+308, -1.79769313e+308, ...,
-1.79769313e+308, -1.79769313e+308, -1.79769313e+308],
[-1.79769313e+308, -1.79769313e+308, -1.79769313e+308, ...,
-1.79769313e+308, -1.79769313e+308, -1.79769313e+308],
[-1.79769313e+308, -1.79769313e+308, -1.79769313e+308, ...,
-1.79769313e+308, -1.79769313e+308, -1.79769313e+308]])
Any workaround for this?
from pysheds.
To plot, it just call:
from matplotlib import pyplot as plt
plt.imshow(grid.view('dem'))
This was omitted in the readme for brevity, but can be seen in the quickstart:
https://github.com/mdbartos/pysheds/blob/master/examples/quickstart.ipynb
grid.view
returns a Raster object (essentially an ndarray with metadata) that represents a "view" of the data at the grid's current affine transform, shape, crs, and nodata value.
from pysheds.
issue closed? @mdbartos
from pysheds.
Related Issues (20)
- How to create Flow Distance raster same shape as DEM raster?
- Re-evaluate Numba performance HOT 2
- Allow Numba to perform polymorphic dispatching HOT 5
- Can't 'imshow' DEM for some unkown reason HOT 1
- extract_profiles function returning wrong connections when neighbouring cells drain to outlet
- strang plots HOT 1
- Allow user to disable `parallel=True` with numba HOT 2
- Why stream network `LineStrings` do not pass through the centroid of each grid cell? HOT 1
- accumulation issue HOT 3
- Preprocessing DEM with pysheds seems to produce incorrect accumulations HOT 11
- Using catchment() with discharge point outside of extents crashes program
- sGrid and pGrid have major differences
- Pysheds Cupy / Cuspatial support HOT 1
- Accumulation disconnections HOT 4
- setup fail by github repo of latest release version
- Pixels that should be accumulation watercourses are shown as nodata HOT 2
- Wrong bbox when using `ViewFinder` HOT 3
- issue in pygrid with np.int and np.warnings
- D8 and Dinf flow directions look incorrect HOT 4
- Indexing Error in _d8_distance_from_ridge
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 pysheds.