History#
0.19.4 (2025-XX-XX)#
New Features#
Add the development version of the NLDI web service to the
NLDIclass. This version is not stable and is intended for testing purposes only. The default version is still the production version.
0.19.3 (2025-03-07)#
Internal Changes#
Use
orjsoninstead ofujsondue to the package not being maintained anymore. The developer ofujsonraised conrcerns about security vulnerabilities and recommended usingorjsoninstead.Create two new modules called
nldiandpygeoapifor better organization of the codebase.
0.19.0 (2025-01-17)#
Breaking Changes#
Remove
NLDI.getcharacteristic_byidmethod since its endpoint will be removed from the NLDI service. The characteristics can still be accessed via theNLDI.get_characteristicsmethod and only requires specifying the characteristic names and optionally the NHDPlus ComIDs. This method calls thepynhd.nhdplus_attrs_s3function internally.Switch to using the new StreamCat web service link. While the public API of the
pynhd.streamcatfunction did not change the web service itself might return different results and metrics names have been changed. Thus, this change might affect the results of the function and is considered a breaking change.
New Features#
Add a new optional argument to
pynhd.nhdplus_attrs_s3to pass a PyArrow Expression for filtering the query.
Internal Changes#
Switch to using the new NLDI web service link. Note that NLDI web service now has a rate limit of 3600 requests per hour per IP.
0.18.1 (2024-10-08)#
Bug Fixes#
In
GeoConnex, set therequest_type='POST'for all CQL queries. While non-spatial CQL queries are working, spatial CQL queries are still not working due to an issue with the GeoConnex service. For now, it’s recommended to use thebyfiltermethod for most of the queries, including spatial queries. For simple spatial queries, you can use thebyboxmethod then filter the results based on the actual geometry.
0.18.0 (2024-10-05)#
New Features#
Replace the links to NLDI and PyGeoAPI web services to their new URLs.
Add two new methods to
GeoConnexclass for queryingbyboxandbyfilter. Note that CQL query is still not working due to an issue with the GeoConnex service. For now, it’s recommended to use thebyfiltermethod for most of the queries, including spatial queries. For simple spatial queries, you can use thebyboxmethod then filter the results based on the actual geometry.
Breaking Changes#
Drop support for Python 3.8 since its end-of-life date is October 2024.
Remove all exceptions from the main module and raise them from the
exceptionsmodule. This is to declutter the public API and make it easier to maintain.
0.17.0 (2024-05-07)#
New Features#
The function
pynhd.streamcatnow can be called without any arguments to get a dataframe of all available metrics and their descriptions.
Internal Changes#
Add the
exceptionsmodule to the high-level API to declutter the main module. In the future, all exceptions will be raised from this module and not from the main module. For now, the exceptions are raised from both modules for backward compatibility.Switch to using the
srclayout instead of theflatlayout for the package structure. This is to make the package more maintainable and to avoid any potential conflicts with other packages.Add artifact attestations to the release workflow.
0.16.3 (2024-04-26)#
New Features#
Add support for LakeCat dataset in
streamcatfunction. A new argument calledlakes_onlyis added to the function. If set toTrue, only metrics for lake and their associated catchments will be returned. The default isFalseto retain backward compatibility.
Bug Fixes#
Modify
HP3Dclass based on the latest changes to the 3D Hydrography Program service. Hydrolocation layer has now three sub-layers:hydrolocation_waterbodyfor Sink, Spring, Waterbody Outlet,hydrolocation_flowlinefor Headwater, Terminus, Divergence, Confluence, Catchment Outlet,hydrolocation_reachfor Reach Code, External Connection.
Breaking Changes#
EPA’s HMS no longer supports the StreamCat dataset, since they have a dedicated service for it. Thus, the
epa_nhd_catchmentsfunction no longer accepts “streamcat” as an input for thefeatureargument. For all StreamCat queries, use thestreamcatfunction instead. Now, theepa_nhd_catchmentsfunction is essentially useful for getting Curve Number data.
0.16.2 (2024-02-12)#
Bug Fixes#
In
NLDI.get_basins, the indices used to be station IDs but in the previous release they were reset by mistake. This version retains the correct indices.
New Features#
In
nhdplus_l48function, when the layer isNHDFlowline_NetworkorNHDFlowline_NonNetwork, merge allMultiLineStringgeometries toLineString.
0.16.1 (2024-01-03)#
Bug Fixes#
Fix an issue in
network_xsectionandflowline_xsectionrelated to the changes inshapely2 API. Now, these functions should return the correct cross-sections.
0.16.0 (2024-01-03)#
New Features#
Add access to USGS 3D Hydrography Program (3DHP) service. The new class is called
HP3D. It can be queried by IDs, geometry, or SQL where clause.Add support for the new PyGeoAPI endpoints called
xsatpathpts. This new endpoint is useful for getting elevation profile along Ashapely.LineString. You can usepygeoapifunction withservice="elevation_profile"(orPyGeoAPIclass) to access this new endpoint. Previously, theelevation_profileendpoint was used for getting elevation profile along a path from two endpoints and the inputGeoDataFramemust have been aMultiPointwith two coordinates. Now, you must the input must containLineStringgeometries.Switch to using the new smoothing algorithm from
pygeoutilsfor resampling the flowlines and getting their cross-sections. This new algorithm is more robust, accurate, and faster. It has a new argument calledsmoothingfor controlling the number knots of the spline. Higher values result in smoother curves. The default value isNonewhich uses all the points from the input flowline.
0.15.2 (2023-09-22)#
Bug Fixes#
Update
GeoConnexbased on the latest changes in the web service.
0.15.1 (2023-09-02)#
Bug Fixes#
Fix HyRiver libraries requirements by specifying a range instead of exact version so
conda-forgecan resolve the dependencies.
0.15.0 (2023-05-07)#
From release 0.15 onward, all minor versions of HyRiver packages
will be pinned. This ensures that previous minor versions of HyRiver
packages cannot be installed with later minor releases. For example,
if you have py3dep==0.14.x installed, you cannot install
pydaymet==0.15.x. This is to ensure that the API is
consistent across all minor versions.
New Features#
Add a new function, called
nhdplus_h12pp, for retrieving HUC12 pour points across CONUS.Add
use_arrow=Truetopynhd.nhdplus_l48when reading the NHDPlus dataset. This speeds up the process sincepyarrowis installed.In
nhdplus_l48makelayeroption sosqlparameter ofpyogrio.read_dataframecan also be used. This is necessary sincepyogrio.read_dataframedoes not support passing bothlayerandsqlparameters.Update the mainstems dataset link to version 2.0 in
mainstem_huc12_nx.Expose
NHDToolsclass to the public API.For now, retain compatibility with
shapely<2while supportingshapley>=2.
Bug Fixes#
Remove unnecessary conversion of
id_colandtoid_coltoInt64innhdflw2nxandvector_accumulation. This ensures that the input data types are preserved.Fix an issue in
nhdplus_l48, where if the inputdata_diris not absolutepy7zrfails to extract the file.
0.14.0 (2023-03-05)#
New Features#
Rewrite the
GeoConnexclass to provide access to new capabilities of the web service. Support for spatial queries have been added via CQL queries. For more information, check out the updated GeoConnex example notebook.Add a new property to
StreamCat, calledmetrics_dfthat gets a dataframe of metric names and their description.Create a new private
StreamCatValidatorclass to avoid polluting the publicStreamCatclass with private attributes and methods. Moreover, add a new alternative metric names attribute toStreamCatcalledalt_namesfor handling those metric names that do not followMETRIC+YYYYconvention. This attribute is a dictionary that maps the alternative names to the actual metric names, so users can useMETRIC_NAMEcolumn ofmetrics_dfand add a year suffix fromvalid_yearsattribute ofStreamCatto get the actual metric name.In
navigate_by*functions ofNLDIaddstop_comid, which is another criterion for stopping the navigation in addition todistance.Improve
UserWarningmessages ofNLDIandWaterData.
Breaking Changes#
Remove
pynhd.geoconnexfunction since more functionality has been added to the GeoConnex service that existence of this function does not make sense anymore. All queries should be done viapynhd.GeoConnexclass.Rewrite
NLDIto improve code readability and significantly improving performance. Now, its methods do now return tuples if there are failed requests, instead they will be shown as aUserWarning.Bump the minimum required version of
shapelyto 2.0, and use its new API.
Internal Changes#
Sync all minor versions of HyRiver packages to 0.14.0.
0.13.12 (2023-02-10)#
New Features#
Update the link to version 2.0 of the ENHD dataset in
enhd_attrs.
Internal Changes#
Improve columns data types in
enhd_attrsandnhdplus_vaaby usingint32instead ofInt64, where applicable.Sync all patch versions of HyRiver packages to x.x.12.
0.13.11 (2023-01-24)#
New Features#
The
prepare_nhdplusnow supports NHDPlus HR in addition to NHDPlus MR. It automatically detects the NHDPlus version based on the ID column name:nhdplusidfor HR andcomidfor MR.
Internal Changes#
Fully migrate
setup.cfgandsetup.pytopyproject.toml.Convert relative imports to absolute with
absolufy-imports.Improve performance of
prepare_nhdplusby usingpandas.mergeinstead of applying a function to each row of the dataframe.
0.13.10 (2023-01-08)#
New Features#
Add support for the new EPA’s StreamCat Restful API with around 600 NHDPlus catchment level metrics. One class is added for getting the service properties such as valid metrics, called
StreamCat. You can usestreamcatfunction to get the metrics as apandas.DataFrame.Refactor the
show_versionsfunction to improve performance and print the output in a nicer table-like format.
Internal Changes#
Skip 0.13.9 version so the minor version of all HyRiver packages become the same.
Modify the codebase based on the latest changes in
geopandasrelated to empty dataframes.
0.13.8 (2022-12-09)#
New Features#
Add a new function, called
nhdplus_attrs_s3, for accessing the recently released NHDPlus derived attributes on a USGS’s S3 bucket. The attributes are provided in parquet files, so getting them is faster thannhdplus_attrs. Also, you can request for multiple attributes at once whereas innhdplus_attrsyou had to request for each attribute one at a time. This function will replacenhdplus_attrsin a future release, as soon as all data that are available on the ScienceBase version are also accessible from the S3 bucket.Add two new functions called
mainstem_huc12_nxandenhd_flowlines_nx. These functions generate anetworkxdirected graph object of NHD HUC12 water boundaries and flowlines, respectively. They also return a dictionary mapping of COMID and HUC12 to the correspondingnetworkxnode. Additionally, a topologically sorted list of COMIDs/HUC12s are returned. The generated data are useful for doing US-scale network analysis and flow accumulation on the NHD network. The NHD graph has about 2.7 million edges and the mainstem HUC12 graph has about 80K edges.Add a new function for getting the entire NHDPlus dataset for CONUS (Lower 48), called
nhdplus_l48. The entire NHDPlus dataset is downloaded from here. This 7.3 GB file will take a while to download, depending on your internet connection. The first time you run this function, the file will be downloaded and stored in the./cachedirectory. Subsequent calls will use the cached file. Moreover, there are two additional dependencies for using this function:pyogrioandpy7zr. These dependencies can be installed usingpip install pyogrio py7zrorconda install -c conda-forge pyogrio py7zr.
Internal Changes#
Refactor
vector_accumulationfor significant performance improvements.Modify the codebase based on Refurb suggestions.
0.13.7 (2022-11-04)#
New Features#
Add a new function called
epa_nhd_catchmentsto access one of the EPA’s HMS endpoints calledWSCatchment. You can use this function to access 414 catchment-scale characteristics for all the NHDPlus catchments including 16-day average curve number. More information on the curve number dataset can be found at its project page here.
Bug Fixes#
Fix a bug in
NHDToolswhere due to the recent changes inpandasexception handling, theNHDToolsfails in converting columns withNaNvalues to integer type. Now,pandasthrowsIntCastingNaNErrorinstead ofTypeErrorwhen usingastypemethod on a column.
Internal Changes#
Use
pyupgradepackage to update the type hinting annotations to Python 3.10 style.
0.13.6 (2022-08-30)#
Internal Changes#
Add the missing PyPi classifiers for the supported Python versions.
0.13.5 (2022-08-29)#
Breaking Changes#
Append “Error” to all exception classes for conforming to PEP-8 naming conventions.
Internal Changes#
Bump the minimum versions of
pygeoogcandpygeoutilsto 0.13.5 and that ofasync-retrieverto 0.3.5.
Bug Fixes#
Fix an issue in
nhdplus_vaaandenhd_attrsfunctions where ifcachefolder does not exist, it would not have been created, thus resulting to an error.
0.13.3 (2022-07-31)#
Internal Changes#
Use the new
async_retriever.stream_writefunction to download files innhdplus_vaaandenhd_attrsfunctions. This is more memory efficient.Convert the type of list of not found items in
NLDI.comid_bylocandNLDI.feature_bylocto list of tuples of coordinates from list of strings. This matches the type of returned not found coordinates to that of the inputs.Fix an issue with NLDI that was caused by the recent changes in the NLDI web service’s error handling. The NLDI web service now returns more descriptive error messages in a
jsonformat instead of returning the usual status errors.Slice the ENHD dataframe in
NHDTools.clean_flowlinesbefore updating the flowline dataframe to reduce the required memory for theupdateoperation.
0.13.2 (2022-06-14)#
Breaking Changes#
Set the minimum supported version of Python to 3.8 since many of the dependencies such as
xarray,pandas,rioxarrayhave dropped support for Python 3.7.
Internal Changes#
Use micromamba for running tests and use nox for linting in CI.
0.13.1 (2022-06-11)#
New Features#
Add support for all the GeoConnex web service endpoints. There are two ways to use it. For a single query, you can use the
geoconnexfunction and for multiple queries, it’s more efficient to use theGeoConnexclass.Add support for passing any of the supported NLDI feature sources to the
get_basinsmethod of theNLDIclass. The default isnwissiteto retain backward compatibility.
Bug Fixes#
Set the type of “ReachCode” column to
strinstead ofintinpygeoapiandnhdplus_vaafunctions.
0.13.0 (2022-04-03)#
New Features#
Add two new functions called
flowline_resampleandnetwork_resamplefor resampling a flowline or network of flowlines based on a given spacing. This is useful for smoothing jagged flowlines similar to those in the NHDPlus database.Add support for the new NLDI endpoint called “hydrolocation”. The
NLDIclass now has two methods for getting features by coordinates:feature_bylocandcomid_byloc. Thefeature_bylocmethod returns the flowline that is associated with the closest NHDPlus feature to the given coordinates. Thecomid_bylocmethod returns a point on the closest downstream flowline to the given coordinates.Add a new function called
pygeoapifor calling the API in batch mode. This function accepts the input coordinates as ageopandas.GeoDataFrame. It is more performant than calling its counteractPyGeoAPImultiple times. It’s recommended to switch to using this new batch function instead of thePyGeoAPIclass. Users just need to prepare an input data frame that has all the required service parameters as columns.Add a new step to
prepare_nhdplusto convertMultiLineStringtoLineString.Add support for the
simplifiedflag of NLDI’sget_basinsfunction. The default value isTrueto retain the old behavior.
Breaking Changes#
Remove caching-related arguments from all functions since now they can be set globally via three environmental variables:
HYRIVER_CACHE_NAME: Path to the caching SQLite database.HYRIVER_CACHE_EXPIRE: Expiration time for cached requests in seconds.HYRIVER_CACHE_DISABLE: Disable reading/writing from/to the cache file.
You can do this like so:
import os
os.environ["HYRIVER_CACHE_NAME"] = "path/to/file.sqlite"
os.environ["HYRIVER_CACHE_EXPIRE"] = "3600"
os.environ["HYRIVER_CACHE_DISABLE"] = "true"
0.12.2 (2022-02-04)#
New Features#
Add a new class called
NHDfor accessing the latest National Hydrography Dataset. More info regarding this data can be found here.Add two new functions for getting cross-sections along a single flowline via
flowline_xsectionor throughout a network of flowlines vianetwork_xsection. You can specify spacing and width parameters to control their location. For more information and examples please consult the documentation.Add a new property to
AGRBasecalledservice_infoto include some useful info about the service includingfeature_typeswhich can be handy for converting numeric values of types to their string equivalent.
Internal Changes#
Use the new PyGeoAPI API.
Refactor
prepare_nhdplusfor improving the performance and robustness of determiningtocomidwithin a network of NHD flowlines.Add empty geometries that
NLDI.getbasinsreturns to the list ofnot foundIDs. This is because the NLDI service does not include non-network flowlines and instead returns an empty geometry for these flowlines. (GH #48)
0.12.1 (2021-12-31)#
Internal Changes#
Use the three new
ar.retrieve_*functions instead of the oldar.retrievefunction to improve type hinting and to make the API more consistent.Revert to the original PyGeoAPI base URL.
0.12.0 (2021-12-27)#
Breaking Changes#
Rewrite
ScienceBaseto make it applicable for working with other ScienceBase items. A new function has been added for staging the Additional NHDPlus attributes items calledstage_nhdplus_attrs.Refactor
AGRBaseto remove unnecessary functions and make them more general.Update
PyGeoAPIclass to conform to the newpygeoapiAPI. This web service is undergoing some changes at the time of this release and the API is not stable, might not work as expected. As soon as the web service is stable, a new version will be released.
New Features#
In
WaterData.byidshow a warning if there are any missing feature IDs that are requested but are not available in the dataset.For all
by*methods ofWaterDatathrow aZeroMatchedexception if no features are found.Add
expire_afteranddisable_cachingarguments to all functions that useasync_retriever. Set the default request caching expiration time to never expire. You can usedisable_cachingif you don’t want to use the cached responses. Please refer to documentation of the functions for more details.
Internal Changes#
Refactor
prepare_nhdplusto reduce code complexity by grouping all the NHDPlus tools as a private class.Modify
AGRBaseto reflect the latest API changes inpygeoogc.ArcGISRESTfullclass.Refactor
prepare_nhdplusby creating a private class that includes all the previously used private functions. This will make the code more readable and easier to maintain.Add all the missing types so
mypy --strictpasses.
0.11.4 (2021-11-12)#
New Features#
Add a new argument to
NLDI.get_basinscalledsplit_catchmentthat if is set toTruewill split the basin geometry at the watershed outlet.
Internal Changes#
Catch service errors in
PyGeoAPIand show useful error messages.Use
importlib-metadatafor getting the version instead ofpkg_resourcesto decrease import time as discussed in this issue.
0.11.3 (2021-09-10)#
Internal Changes#
More robust handling of inputs and outputs of
NLDI’s methods.Use an alternative download link for NHDPlus VAA file on Hydroshare.
Restructure the codebase to reduce the complexity of
pynhd.pyfile by dividing it into three files:pynhdall classes that provide access to the supported web services,corethat includes base classes, andnhdplus_derivedthat has functions for getting databases that provided additional attributes for the NHDPlus database.
0.11.2 (2021-08-26)#
New Features#
Add support for PyGeoAPI. It offers four functionalities:
flow_trace,split_catchment,elevation_profile, andcross_section.
0.11.1 (2021-07-31)#
New Features#
Add a function for getting all NHD
FCodesas a data frame, callednhd_fcode.Improve
prepare_nhdplusfunction by removing all coastlines and better detection of the terminal point in a network.
Internal Changes#
Migrate to using
AsyncRetrieverfor handling communications with web services.Catch the
ConnectionErrorseparately inNLDIand raise aServiceErrorinstead. So user knows that data cannot be returned due to the out of service status of the server notZeroMatched.
0.11.0 (2021-06-19)#
New Features#
Add
nhdplus_vaato access NHDPlus Value Added Attributes for all its flowlines.To see a list of available layers in NHDPlus HR, you can instantiate its class without passing any argument like so
NHDPlusHR().
Breaking Changes#
Drop support for Python 3.6 since many of the dependencies such as
xarrayandpandashave done so.
Internal Changes#
Use persistent caching for all requests which can help speed up network responses significantly.
Improve documentation and testing.
0.10.1 (2021-03-27)#
Add an announcement regarding the new name for the software stack, HyRiver.
Improve
pipinstallation and release workflow.
0.10.0 (2021-03-06)#
The first release after renaming hydrodata to PyGeoHydro.
Make
mypychecks more strict and fix all the errors and prevent possible bugs.Speed up CI testing by using
mambaand caching.
0.9.0 (2021-02-14)#
Bump version to the same version as PyGeoHydro.
Breaking Changes#
Add a new function for getting basins geometries for a list of USGS station IDs. The function is a method of
NLDIclass calledget_basins. So, nowNLDI.getfeature_byidfunction does not have a basin flag. This change makes getting geometries easier and faster.Remove
characteristics_dataframemethod fromNLDIand make a standalone function callednhdplus_attrsfor accessing NHDPlus attributes directly from ScienceBase.Add support for using hydro or edits webs services for getting NHDPlus High-Resolution using
NHDPlusHRfunction. The new arguments areservicewhich acceptshydrooredits, andautos_switchflag for automatically switching to the other service if the ones passed byservicefails.
New Features#
Add a new argument to
topoogical_sortcallededge_attrthat allows adding attribute(s) to the returned Networkx Graph. By default, it isNone.A new base class,
AGRBasefor connecting to ArcGISRESTful-based services such as National Map and EPA’s WaterGEOS.Add support for setting the buffer distance for the input geometries to
AGRBase.bygeom.Add
comid_byloctoNLDIclass for getting ComIDs of the closest flowlines from a list of lon/lat coordinates.Add
bydistancetoWaterDatafor getting features within a given radius of a point.
0.2.0 (2020-12-06)#
Breaking Changes#
Re-wrote the
NLDIfunction to use API v3 of the NLDI service.The
crsargument ofWaterDatanow is the target CRS of the output dataframe. The service CRS is nowEPSG:4269for all the layers.Remove the
url_onlyargument ofNLDIsince it’s not applicable anymore.
New Features#
Added support for NHDPlus High Resolution for getting features by geometry, IDs, or SQL where clause.
The following functions are added to
NLDI:
getcharacteristic_byid: Getting characteristics of NHDPlus catchments.navigate_byloc: Getting the nearest ComID to a coordinate and performing navigation.characteristics_dataframe: Getting all the available catchment-scale characteristics as a data frame.get_validchars: Getting a list of available characteristic IDs for a specified characteristic type.
The following function is added to
WaterData:
byfilter: Getting data based on any valid CQL filter.bygeom: Getting data within a geometry (polygon and multipolygon).
Add support for Python 3.9 and tests for Windows.
Bug Fixes#
Refactored
WaterDatato fix the CRS inconsistencies (#1).
0.1.3 (2020-08-18)#
Replaced
simplejsonwithorjsonto speed-up JSON operations.
0.1.2 (2020-08-11)#
Add
show_versionsfunction for showing versions of the installed deps.Improve documentation
0.1.1 (2020-08-03)#
Improved documentation
Refactored
WaterDatato improve readability.
0.1.0 (2020-07-23)#
First release on PyPI.