mheberger / delineator

Fast, accurate watershed delineation using hybrid vector- and raster-based methods and data from MERIT-Hydro
MIT License
84 stars 20 forks source link

Delineation error showing series object has no attribute uparea #8

Open SSD-77 opened 4 months ago

SSD-77 commented 4 months ago

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

mheberger commented 4 months ago

Can you post or send me your outlets.csv file or at least the coordinates for the outlet where the script failed?

And until we can fix this, feel free to use the web app: https://mghydro.com/watersheds. It seems to work fine in Saudi Arabia.

On Thu, Apr 25, 2024 at 4:26 PM SSD-77 @.***> wrote:

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

  • Delineating watershed 1 of 1, with outlet id = 6401070 Traceback (most recent call last): File "c:\Users\ssdas\Downloads\delineator-main\delineator-main\delineate.py", line 730, in delineate() File "c:\Users\ssdas\Downloads\delineator-main\delineator-main\delineate.py", line 441, in delineate up_area = rivers_gdf.loc[terminal_comid].uparea ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "C:\Users\ssdas\AppData\Local\Programs\Python\Python311\Lib\site-packages\pandas\core\generic.py", line 5989, in getattr return object.getattribute(self, name) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ AttributeError: 'Series' object has no attribute 'uparea'

— Reply to this email directly, view it on GitHub https://github.com/mheberger/delineator/issues/8, or unsubscribe https://github.com/notifications/unsubscribe-auth/ADYEMR2JWJPHRW2OU43K3ZLY7EHCRAVCNFSM6AAAAABGZAIGV2VHI2DSMVQWIX3LMV43ASLTON2WKOZSGI3DGNZTG4ZDAOI . You are receiving this because you are subscribed to this thread.Message ID: @.***>

SSD-77 commented 4 months ago

I have attached the outlet csv file for your reference. Since it will be a batch delineation for 600 locations, the website won't be a handy option outlets_sample.csv .

kushagrob commented 4 months ago

Hi, I am getting the following error when trying to run the script:

Reading your outlets data in: /Users/kushagro/Documents/erw-downstream/results/brazil_argentina_alkalinity_locations.csv
Finding out which Level 2 megabasin(s) your points are in
Traceback (most recent call last):
  File "/Users/kushagro/Documents/delineator/delineate.py", line 806, in <module>
    delineate()
  File "/Users/kushagro/Documents/delineator/delineate.py", line 360, in delineate
    gages_basins_join = gpd.sjoin(
  File "/Users/kushagro/.pyenv/versions/3.10.0/lib/python3.10/site-packages/geopandas/tools/sjoin.py", line 121, in sjoin
    indices = _geom_predicate_query(left_df, right_df, predicate)
  File "/Users/kushagro/.pyenv/versions/3.10.0/lib/python3.10/site-packages/geopandas/tools/sjoin.py", line 213, in _geom_predicate_query
    sindex = right_df.sindex
  File "/Users/kushagro/.pyenv/versions/3.10.0/lib/python3.10/site-packages/geopandas/base.py", line 3548, in sindex
    return self.geometry.values.sindex
  File "/Users/kushagro/.pyenv/versions/3.10.0/lib/python3.10/site-packages/geopandas/array.py", line 316, in sindex
    self._sindex = _get_sindex_class()(self._data)
  File "/Users/kushagro/.pyenv/versions/3.10.0/lib/python3.10/site-packages/geopandas/sindex.py", line 741, in __init__
    non_empty[mod.is_empty(non_empty)] = None
  File "/Users/kushagro/.pyenv/versions/3.10.0/lib/python3.10/site-packages/shapely/decorators.py", line 77, in wrapped
    return func(*args, **kwargs)
  File "/Users/kushagro/.pyenv/versions/3.10.0/lib/python3.10/site-packages/shapely/predicates.py", line 162, in is_empty
    return lib.is_empty(geometry, **kwargs)
TypeError: One of the arguments is of incorrect type. Please provide only Geometry objects.

brazil_argentina_alkalinity_locations.csv

I have downloaded the raster/vector/simple data for regions 62-65 and have attached my csv below.

Thank you for open-sourcing this repo and in advance for your help!

mheberger commented 4 months ago

Make sure you have not downloaded the files called 'bugfix' from MERIT-Basins. For some reason, those do not work.

On Wed, May 15, 2024 at 9:18 PM kushagrob @.***> wrote:

Hi, I am getting the following error when trying to run the script:

Reading your outlets data in: /Users/kushagro/Documents/erw-downstream/results/brazil_argentina_alkalinity_locations.csv Finding out which Level 2 megabasin(s) your points are in Traceback (most recent call last): File "/Users/kushagro/Documents/delineator/delineate.py", line 806, in delineate() File "/Users/kushagro/Documents/delineator/delineate.py", line 360, in delineate gages_basins_join = gpd.sjoin( File "/Users/kushagro/.pyenv/versions/3.10.0/lib/python3.10/site-packages/geopandas/tools/sjoin.py", line 121, in sjoin indices = _geom_predicate_query(left_df, right_df, predicate) File "/Users/kushagro/.pyenv/versions/3.10.0/lib/python3.10/site-packages/geopandas/tools/sjoin.py", line 213, in _geom_predicate_query sindex = right_df.sindex File "/Users/kushagro/.pyenv/versions/3.10.0/lib/python3.10/site-packages/geopandas/base.py", line 3548, in sindex return self.geometry.values.sindex File "/Users/kushagro/.pyenv/versions/3.10.0/lib/python3.10/site-packages/geopandas/array.py", line 316, in sindex self._sindex = _get_sindex_class()(self._data) File "/Users/kushagro/.pyenv/versions/3.10.0/lib/python3.10/site-packages/geopandas/sindex.py", line 741, in init non_empty[mod.is_empty(non_empty)] = None File "/Users/kushagro/.pyenv/versions/3.10.0/lib/python3.10/site-packages/shapely/decorators.py", line 77, in wrapped return func(*args, kwargs) File "/Users/kushagro/.pyenv/versions/3.10.0/lib/python3.10/site-packages/shapely/predicates.py", line 162, in is_empty return lib.is_empty(geometry, kwargs) TypeError: One of the arguments is of incorrect type. Please provide only Geometry objects.

brazil_argentina_alkalinity_locations.csv https://github.com/mheberger/delineator/files/15326012/brazil_argentina_alkalinity_locations.csv

I have downloaded the raster/vector/simple data for regions 62-65 and have attached my csv below.

Thank you for open-sourcing this repo and in advance for your help!

— Reply to this email directly, view it on GitHub https://github.com/mheberger/delineator/issues/8#issuecomment-2113295109, or unsubscribe https://github.com/notifications/unsubscribe-auth/ADYEMR2HP27PC3XN6LFRUXDZCOYKBAVCNFSM6AAAAABGZAIGV2VHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDCMJTGI4TKMJQHE . You are receiving this because you commented.Message ID: @.***>

kushagrob commented 4 months ago

Thanks for the quick response!

I downloaded it from here: https://drive.google.com/drive/folders/1uCQFmdxFbjwoT9OYJxw-pXaP8q_GYH1a

Is that the wrong link?

mheberger commented 4 months ago

Seems that you have downloaded the correct data needed by the script.

I'm not able to reproduce this error. I googled that error and found this has been reported as a bug in GeoPandas: https://github.com/geopandas/geopandas/issues/3054

It seems it may have something to do with incompatible software versions.

Are you using Python 3.12? Have you created a virtual environment and installed the versions of libraries in requirements.txt? Do the scripts run OK with the sample files provided?

On Wed, May 15, 2024 at 11:06 PM kushagrob @.***> wrote:

Thanks for the quick response!

I downloaded it from here: https://drive.google.com/drive/folders/1uCQFmdxFbjwoT9OYJxw-pXaP8q_GYH1a

Is that the wrong link?

— Reply to this email directly, view it on GitHub https://github.com/mheberger/delineator/issues/8#issuecomment-2113455857, or unsubscribe https://github.com/notifications/unsubscribe-auth/ADYEMR2336X3Q3PWHIBHCZ3ZCPE5LAVCNFSM6AAAAABGZAIGV2VHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDCMJTGQ2TKOBVG4 . You are receiving this because you commented.Message ID: @.***>

mheberger commented 4 months ago

I have attached the outlet csv file for your reference. Since it will be a batch delineation for 600 locations, the website won't be a handy option outlets_sample.csv .

@SSD-77, Sorry, I can't recreate this issue. Please verify that you have downloaded the correct data. You want the datasets from MERIT-Basins that are labeled "based on MERIT-Hydro v0.7/v1.0," and not the ones that are labeled "bug fix."