mheberger / delineator Goto Github PK
View Code? Open in Web Editor NEWFast, accurate watershed delineation using hybrid vector- and raster-based methods and data from MERIT-Hydro
License: MIT License
Fast, accurate watershed delineation using hybrid vector- and raster-based methods and data from MERIT-Hydro
License: MIT License
How different are the standard catchment files to the ones marked 'minor bug fix for coastline pixels'. I tried batch delineating a couple of points using the standard catchment shapefiles, and for a point in basin 78, there seems to be a missing feature / gap in the polygon. I noticed that this is not the case in the bug-fixed file and was wondering which one was better to use in general
Hi Matthew!
I currently try to delineate catchments in Germany (Basin 23).
I followed your instructions from the front page to download the data for Germany and set up everything in config.py
.
When I run python delineate.py
in the terminal, I get the following output and error:
$ python delineate.py
/home/alexander/Github/camels/camelsp/merit_hydro/delineator/venv/lib/python3.9/site-packages/geopandas/_compat.py:123: UserWarning: The Shapely GEOS version (3.10.3-CAPI-1.16.1) is incompatible with the GEOS version PyGEOS was compiled with (3.10.4-CAPI-1.16.2). Conversions between both will be slow.
warnings.warn(
/home/alexander/Github/camels/camelsp/merit_hydro/delineator/venv/lib/python3.9/site-packages/geopandas/_compat.py:123: UserWarning: The Shapely GEOS version (3.10.3-CAPI-1.16.1) is incompatible with the GEOS version PyGEOS was compiled with (3.10.4-CAPI-1.16.2). Conversions between both will be slow.
warnings.warn(
Reading your outlets data in: /home/alexander/Github/camels/camelsp/merit_hydro/data/outlets.csv
Finding out which Level 2 megabasin(s) your points are in
Your watershed outlets are in 1 basin(s)
Beginning delineation for 10 outlet point(s) in Level 2 Basin #23.
Reading catchment geodata in /home/alexander/Github/camels/camelsp/merit_hydro/data/shp/merit_catchments/cat_pfaf_23_MERIT_Hydro_v07_Basins_v01.shp
Traceback (most recent call last):
File "/home/alexander/Github/camels/camelsp/merit_hydro/delineator/delineate.py", line 701, in <module>
delineate()
File "/home/alexander/Github/camels/camelsp/merit_hydro/delineator/delineate.py", line 449, in delineate
catchments_gdf.to_crs(crs, inplace=True)
File "/home/alexander/Github/camels/camelsp/merit_hydro/delineator/venv/lib/python3.9/site-packages/geopandas/geodataframe.py", line 1364, in to_crs
geom = df.geometry.to_crs(crs=crs, epsg=epsg)
File "/home/alexander/Github/camels/camelsp/merit_hydro/delineator/venv/lib/python3.9/site-packages/geopandas/geoseries.py", line 1124, in to_crs
self.values.to_crs(crs=crs, epsg=epsg), index=self.index, name=self.name
File "/home/alexander/Github/camels/camelsp/merit_hydro/delineator/venv/lib/python3.9/site-packages/geopandas/array.py", line 762, in to_crs
raise ValueError(
ValueError: Cannot transform naive geometries. Please set a crs on the object first.
I think this error occurs because there is no .prj
file for the merit catchments on Google Drive (linked in your instruction): https://drive.google.com/drive/folders/1owkvZQBMZbvRv3V4Ff3xQPEgmAC48vJo
Your sample data for Iceland includes the file cat_pfaf_27_MERIT_Hydro_v07_Basins_v01.prj
which I cannot find for my area.
There are also some incompatibility warnings at the beginning of the output but I do not think that those are causing the problem.
I tried to run python delineate.py
in a fresh conda and a fresh venv environemnt, both produce the same error.
Let me know if you need anything else and thank you!
I am able to run the sample data file. However, when trying to run for Saudi Arabia (Catchment number 29) got the following error.
Beginning delineation for 1 outlet point(s) in Level 2 Basin #29.
Fetching BASIN # 29 catchment data from pickle file.
Reading data table for rivers in basin 29
Fetching BASIN # 29 catchment data from pickle file.
Performing spatial join on 1 outlet points in basin #29
I'm trying to run the delineation on a batch of points, and some of them are outside the merit basins. I tried using the buffered merit basins but I run into a nan error cause it's outside of the catchment basins, so there's no terminal_comid for it. Is there a fix for this? What would you recommend I do so they are delineated?
Some of such points are:
{'id': 217697, 'lat': 49.348897, 'lng': -124.428403}
{'id': 217808, 'lat': 49.23117, 'lng': -123.97092}
{'id': 217714, 'lat': 50.6102, 'lng': -127.2367}
An ecoregion is "an area with characteristic flora, fauna, and climatic conditions, and related human settlement patterns, and can be comprised of several different watersheds, if the plants and animals are similar." (More on watersheds, ecoregions, and bioregions).
This is useful to organizing and planning in ways that are more ecologically focused (as opposed to relying on administrative demarcations). Also, from the experience of the Cascadia Bioregion in the PNW, many people are interested in seeing their local ecoregions — and don't quite know where to begin or find it, as this may require more technical mapmaking and natural science experience.
Given that ecoregions are a superset of watersheds, and @mheberger's excellent watershed tool , would an ecoregional map project interest you? This could take many different forms. It could simply be an image of a map/shapefiles, which illustrates ecoregions around the world. That shapefile likewise be a layer in online interactive maps, including a layer in the Global Watershed map. It could likewise be an interactive map, which allows you to traverse different scales — from local watersheds, to wider ecoregions, to widest bioregions ("bioregions: the full extent of watersheds within an interconnected area. Bioregional borders tend to be jagged, and hard, such as mountain ranges, peaks, ridges, volcanoes, continental uplifts, tectonic plates and faults, defining how energy flows within a set of boundaries.")
As I write this, it does indeed seem that analytical work to identify ecoregions and bioregions could come first — that analysis could be rendered into shapefiles, which could then easily be integrated into interactive online maps etc.
At the same time, perhaps there could be online tools and data to help bootstrap and assist with that analysis. For example, taking into account the different characteristics relevant to ecoregions:
Is a project/collaboration like this something that would interest you?
I'm running the delineator tool on over 300 points in my basin csv, and I get this error after 228 watersheds have been delineated:
IndexError: index 0 is out of bounds for axis 0 with size 0
All the data I'm using is as provided in the README except my basins csv:
basins.csv
When I run the delineator script, I come across this error:
AttributeError: 'MultiPolygon' object has no attribute 'exterior'
It stems from the line calling the get_subdivided_merit_polygon function in delineator
poly, lat_snap, lng_snap = py.merit_detailed.get_subdivided_merit_polygon(wid, basin, lat, lng, catchment_poly, bSingleCatchment)
and subsequently in this line in the merit_detailed script:
filled_poly = Polygon(poly.exterior.coords)
looks like my catchment_poly is a Multipolygon, so converting it to a polygon and then back to multipolygon doesn't work, but if I skip those steps, it still doesn't work
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.