Package: pygeoutils
PackageDescriptionStatusPyNHDNavigate and subset NHDPlus (MR and HR) using web servicesPy3DEPAccess topographic data through National Map’s 3DEP web servicePyGeoHydroAccess NWIS, NID, WQP, eHydro, NLCD, CAMELS, and SSEBop databasesPyDaymetAccess daily, monthly, and annual climate data via DaymetPyGridMETAccess daily climate data via GridMETPyNLDAS2Access hourly NLDAS-2 data via web servicesHydroSignaturesA collection of tools for computing hydrological signaturesAsyncRetrieverHigh-level API for asynchronous requests with persistent cachingPyGeoOGCSend queries to any ArcGIS RESTful-, WMS-, and WFS-based servicesPyGeoUtilsUtilities for manipulating geospatial, (Geo)JSON, and (Geo)TIFF dataPyGeoUtils: Utilities for (Geo)JSON and (Geo)TIFF ConversionFeaturesPyGeoUtils is a part ofHyRiversoftware stack that
is designed to aid in hydroclimate analysis through web services. This package provides
utilities for manipulating (Geo)JSON and (Geo)TIFF responses from web services.
These utilities are:Coordinates: Generate validated and normalized coordinates in WGS84.GeoBSpline: Create B-spline from ageopandas.GeoDataFrameof points.smooth_linestring: Smooth ashapely.geometry.LineStringusing B-spline.bspline_curvature: Compute tangent angles, curvature, and radius of curvature
of a B-Spline at any points along the curve.arcgis2geojson: Convert ESRIGeoJSON format to GeoJSON.break_lines: Break lines at specified points in a given direction.gtiff2xarray: Convert (Geo)Tiff byte responses toxarray.Dataset.json2geodf: Creategeopandas.GeoDataFramefrom (Geo)JSON responsessnap2nearest: Find the nearest points on a line to a set of points.xarray2geodf: Vectorize axarray.DataArrayto ageopandas.GeoDataFrame.geodf2xarray: Rasterize ageopandas.GeoDataFrameto axarray.DataArray.xarray_geomask: Mask axarray.Datasetbased on a geometry.query_indices: A wrapper aroundgeopandas.sindex.query_bulk. However, instead of returning an array of
positional indices, it returns a dictionary of indices where keys are the
indices of the input geometry and values are a list of indices of the
tree geometries that intersect with the input geometry.nested_polygons: Determining nested (multi)polygons in ageopandas.GeoDataFrame.multi2poly: For converting aMultiPolygonto aPolygonin ageopandas.GeoDataFrame.geometry_reproject: For reprojecting a geometry
(bounding box, list of coordinates, or anyshapely.geometry) to
a new CRS.gtiff2vrt: For converting a list of GeoTIFF files to a VRT file.You can find some example notebookshere.You can also try using PyGeoUtils without installing
it on your system by clicking on the binder badge. A Jupyter Lab
instance with the HyRiver stack pre-installed will be launched in your web browser, and you
can start coding!Moreover, requests for additional functionalities can be submitted viaissue tracker.CitationIf you use any of HyRiver packages in your research, we appreciate citations:@article{Chegini_2021,author={Chegini, Taher and Li, Hong-Yi and Leung, L. Ruby},doi={10.21105/joss.03175},journal={Journal of Open Source Software},month={10},number={66},pages={1--3},title={{HyRiver: Hydroclimate Data Retriever}},volume={6},year={2021}}InstallationYou can install PyGeoUtils usingpipafter installinglibgdalon your system
(for example, in Ubuntu runsudo apt installlibgdal-dev).$pipinstallpygeoutilsAlternatively, PyGeoUtils can be installed from theconda-forgerepository
usingConda:$condainstall-cconda-forgepygeoutilsQuick startWe start by smoothing ashapely.geometry.LineStringusing B-spline:importpygeoutilsaspgufromshapelyimportLineStringline=LineString([(-97.06138,32.837),(-97.06133,32.836),(-97.06124,32.834),(-97.06127,32.832),])line=pgu.geometry_reproject(line,4326,5070)sp=pgu.smooth_linestring(line,5070,5)line_sp=pgu.geometry_reproject(sp.line,5070,4326)Next, we usePyGeoOGCto accessNational Wetlands Inventoryfrom WMS, andFEMA National Flood Hazardvia WFS, then convert the output toxarray.DatasetandGeoDataFrame, respectively.frompygeoogcimportWFS,WMS,ServiceURLfromshapely.geometryimportPolygongeometry=Polygon([[-118.72,34.118],[-118.31,34.118],[-118.31,34.518],[-118.72,34.518],[-118.72,34.118],])crs=4326wms=WMS(ServiceURL().wms.mrlc,layers="NLCD_2011_Tree_Canopy_L48",outformat="image/geotiff",crs=crs,)r_dict=wms.getmap_bybox(geometry.bounds,1e3,box_crs=crs,)canopy=pgu.gtiff2xarray(r_dict,geometry,crs)mask=canopy>60canopy_gdf=pgu.xarray2geodf(canopy,"float32",mask)url_wfs="https://hazards.fema.gov/gis/nfhl/services/public/NFHL/MapServer/WFSServer"wfs=WFS(url_wfs,layer="public_NFHL:Base_Flood_Elevations",outformat="esrigeojson",crs=4269,)r=wfs.getfeature_bybox(geometry.bounds,box_crs=crs)flood=pgu.json2geodf(r.json(),4269,crs)ContributingContributions are very welcomed. Please readCONTRIBUTING.rstfile for instructions.