-
Notifications
You must be signed in to change notification settings - Fork 195
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
grid.catchment ..... TypeError: '<' not supported between instances of 'AxesSubplot' and 'float' #174
Comments
The way that projections are handled was changed in v0.3. See subheading "Converting the Raster coordinate reference system" in the docs: https://mattbartos.com/pysheds/raster.html The For your case, consider something like this: # Specify outlet
x, y = 1824187., 5456997.
# specify crs
crs = 'EPSG:2193'
# new_crs = pyproj.Proj('+init=epsg:2193') # pyproj syntax has changed
crs_proj = pyproj.CRS(crs)
# Resolve flats in DEM
inflated_dem = grid.resolve_flats(dem)
# Project DEM to new CRS
proj_dem = inflated_dem.to_crs(crs_proj)
# Set grid's viewfinder to projected viewfinder
grid.viewfinder = proj_dem.viewfinder
# Compute flow directions
fdir = grid.flowdir(proj_dem)
# Delineate a catchment
catch = grid.catchment(x=x, y=y, fdir=fdir, xytype='coordinate') The error message you are getting makes me think that a matplotlib plot was passed in as one of the arguments though. |
Cheers! I was getting a type error (TypeError:
needs to be:
your link to the docs got me sorted. Cheers |
and good thought on the matplotlib If I run this block of code:
I get the error. If I skip it, then grid.catchment runs. This is made even more strange by the fact that I don't even call fdir in the block. Maybe it's a jupyter issue? |
It's because x is being set to plt.subplot |
classic...good catch |
TypeError Traceback (most recent call last)
~\AppData\Local\Temp/ipykernel_6164/1784417402.py in
1 # Delineate a catchment
----> 2 catch = grid.catchment(x=x, y=y, fdir=fdir, xytype='coordinate')
3
4 # Clip the view to the catchment
5 grid.clip_to(catch)
~\miniconda3\envs\CatchDelin\lib\site-packages\pysheds\sgrid.py in catchment(self, x, y, fdir, pour_value, dirmap, nodata_out, xytype, routing, snap, **kwargs)
685 xmin, ymin, xmax, ymax = fdir.bbox
686 if xytype in {'label', 'coordinate'}:
--> 687 if (x < xmin) or (x > xmax) or (y < ymin) or (y > ymax):
688 raise ValueError('Pour point ({}, {}) is out of bounds for dataset with bbox {}.'
689 .format(x, y, (xmin, ymin, xmax, ymax)))
TypeError: '<' not supported between instances of 'AxesSubplot' and 'float'
Based on the plotting:
the coordinate values seem to be within the graphical space.
The text was updated successfully, but these errors were encountered: