hyriver / pygeohydro

A part of HyRiver software stack for accessing hydrology data through web services
https://docs.hyriver.io
Other
68 stars 23 forks source link

Error when using readme tutorial on gh.nlcd_bygeom() and gh.cover_statistics()... Updated syntax? #86

Closed Flash-Of-Thunder closed 2 years ago

Flash-Of-Thunder commented 2 years ago

Hello,

First of all thanks for this tutorial & code, super helpful. Just wondering if the syntax has been updated or if I'm just misunderstanding:

I tired to run the following code in the readme:

import pygeohydro as gh
from pynhd import NLDI

basins = NLDI().get_basins(["01031450", "01031500", "01031510"])
lulc = gh.nlcd_bygeom(geometry, 100, years={"cover": [2016, 2019]})
stats = gh.cover_statistics(lulc.cover_2016) 

and got the following error: NameError: name 'geometry' is not defined

Well no surprise... I changed "geometry" to "basins" and reran to get the follow error message: AttributeError: 'dict' object has no attribute 'cover_2016

So ultimate I ran something like this:


basins = NLDI().get_basins(["01031450", "01031500", "01031510"])
lulc = gh.nlcd_bygeom(basins, 100, years={"cover": [2016, 2019]})
stats = gh.cover_statistics(lulc["01031450"]['cover_2016'])
stats

{'classes': {'Open Water': 2.846106932303314, 'Developed, Open Space': 2.240292742427323, 'Developed, Low Intensity': 0.5488920512299248, 'Developed, Medium Intensity': 0.1910957511689368, 'Developed, High Intensity': 0.028461069323033134, 'Deciduous Forest': 28.660296808294365, 'Evergreen Forest': 14.474486684285424, 'Mixed Forest': 29.58731449481602, 'Shrub-Forest': 11.20552957918276, 'Herbaceous-Forest': 2.4232567595039645, 'Shrub/Scrub': 0.14637121366131328, 'Grassland/Herbaceous': 0.028461069323033134, 'Pasture/Hay': 0.5976824557836958, 'Cultivated Crops': 0.06505387273836145, 'Woody Wetlands': 6.753405163651148, 'Emergent Herbaceous Wetlands': 0.20329335230737955}, 'categories': {'Background': 0.0, 'Unclassified': 0.0, 'Water': 2.846106932303314, 'Developed': 3.0087416141492174, 'Barren': 0.0, 'Forest': 86.35088432608254, 'Shrubland': 0.14637121366131328, 'Herbaceous': 0.028461069323033134, 'Planted/Cultivated': 0.6627363285220573, 'Wetlands': 6.956698515958529}}

cheginit commented 2 years ago

Thanks for letting me know. Yes, v0.12.x was a breaking change release and the syntax and output of nlcd_* functions have changed. I updated the examples in the tutorials repo but forgot to update the README file. I will take care of it.