-
Notifications
You must be signed in to change notification settings - Fork 52
Add waterdata demo #208
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
base: main
Are you sure you want to change the base?
Add waterdata demo #208
Conversation
…t contain geometry
jzemmels
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is great! I appreciate the consistent throughline example. I've just a few comments that you might consider, but I'm only requesting changes on the errors I ran into (the double monitoring_location_id error + the GeoPandas-dependent code).
| "metadata": {}, | ||
| "source": [ | ||
| "# Using the `waterdata` module to pull data from the USGS Water Data APIs\n", | ||
| "The `waterdata` module will eventually replace the `nwis` module for accessing USGS water data. It leverages the [Water Data APIs](https://api.waterdata.usgs.gov/) to download metadata, daily values, and instantaneous values. \n", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Partially saves you from updating verb tenses once nwis is officially gone.
| "The `waterdata` module will eventually replace the `nwis` module for accessing USGS water data. It leverages the [Water Data APIs](https://api.waterdata.usgs.gov/) to download metadata, daily values, and instantaneous values. \n", | |
| "The `waterdata` module replaces the `nwis` module for accessing USGS water data. It leverages the [Water Data APIs](https://api.waterdata.usgs.gov/) to download metadata, daily values, and instantaneous values. \n", |
| "id": "4a2b3f0f", | ||
| "metadata": {}, | ||
| "source": [ | ||
| "## Lay of the Land\n", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Smart to start high-level!
| "metadata": {}, | ||
| "source": [ | ||
| "## Lay of the Land\n", | ||
| "Now that your API key is configured, it's time to take a 10,000-ft view of the functions in the `waterdata` module.\n", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Might be good to link to the specific OGC API homepage somewhere -- maybe here? https://api.waterdata.usgs.gov/ogcapi
| "id": "19b5aebf", | ||
| "metadata": {}, | ||
| "source": [ | ||
| "### A few key tips\n", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe link to the docs where there are more general tips? https://api.waterdata.usgs.gov/docs/ogcapi/
| "id": "8f464470", | ||
| "metadata": {}, | ||
| "source": [ | ||
| "In the dataframe above, we are looking at 5 timeseries returned, ordered by monitoring location. You can also see that the first two rows show two different kinds of discharge for the same monitoring location: a mean daily discharge timeseries (with statistic id 00003, which represents \"mean\") and an instantaneous discharge timeseries (with statistic id 00011, which represents \"points\" or \"instantaneous\" values). Look closely and you may also notice that the `parent_timeseries_id` column for daily mean discharge matches the `time_series_id` for the instantaneous discharge. This is because once instantaneous measurements began at the site, they were used to calculate the daily mean." |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe link to the statistic-codes reference table: https://api.waterdata.usgs.gov/ogcapi/v0/collections/statistic-codes/items
| ")\n", | ||
| "latest_instantaneous['datetime'] = latest_instantaneous['time'].astype(str)\n", | ||
| "\n", | ||
| "latest_instantaneous[['geometry', 'monitoring_location_id', 'datetime', 'value', 'unit_of_measure']].set_crs(crs=\"WGS84\").explore(column='value', cmap='YlOrRd', scheme=None, legend=True)" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Assumes you have GeoPandas installed. I'd either tell the reader that the remaining code requires GeoPandas or find a non-GeoPandas workaround.
| "id": "c5c5881e", | ||
| "metadata": {}, | ||
| "source": [ | ||
| "Currently, users may only request 3 years or less of continuous data in one pull. For this example, let's pull the last 1 year of daily mean values and instantaneous values for these Missouri River sites. We'll skip pulling geometry in the `waterdata.get_daily()` function; the `waterdata.get_continuous()` function does not return geometry at all." |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Mention why skipping geometry might be desired (reducing response size/repeated information)
| "id": "ebc2c70d", | ||
| "metadata": {}, | ||
| "outputs": [], | ||
| "source": [ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Add an explanation for this code and/or interpretation of the output
| "id": "87a397a4", | ||
| "metadata": {}, | ||
| "outputs": [], | ||
| "source": [ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Honest question from not knowing matplotlib well: is there a way to save the plot above in an object (or something similar) so you can add on to it here, rather than re-writing all of the code again? Analogous to "plt + geom_point(...)"
| ] | ||
| } | ||
| ], | ||
| "metadata": { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
End the vignette with a list of links/resources to learn more
Built off the PR that adds reference table functions.
Adds a demo of the
waterdatafunctions todrpy. Addresses: #200Also adds a few query parameters to the
get_time_series_metadata()function.