Skip to main content

A set of utilities for manipulating (Geo)JSON and GeoTIFF data.

Project description

https://raw.githubusercontent.com/cheginit/hydrodata/develop/docs/_static/pygeoogc_logo.png

PyPi Conda Version CodeCov Github Actions Binder

CodeFactor black pre-commit

Features

PyGeoOGC is a part of Hydrodata software stack and provides interfaces to web services that are based on ArcGIS RESTful, WMS, and WFS.

You can try using PyGeoOGC without installing it on you system by clicking on the binder badge below the PyGeoOGC banner. A Jupyter notebook instance with the Hydrodata software stack pre-installed will be launched in your web browser and you can start coding!

Moreover, requests for addiitonal functionalities can be submitted via issue tracker.

Installation

You can install PyGeoOGC using pip:

$ pip install pygeoogc

Alternatively, PyGeoOGC can be installed from the conda-forge repository using Conda:

$ conda install -c conda-forge pygeoogc

Quickstart

We can access Watershed Boundary Dataset via RESTful service, National Wetlands Inventory from WMS, and FEMA National Flood Hazard via WFS. The output for these functions are of type requests.Response that can be converted to GeoDataFrame or xarray.Dataset using Hydrodata.

from pygeoogc import ArcGISREST, WFS, wms_bybox, MatchCRS
from hydrodata import NLDI, utils

basin_geom = NLDI().getfeature_byid(
    "nwissite",
    "USGS-11092450",
    basin=True
).geometry[0]

rest_url = "https://hydro.nationalmap.gov/arcgis/rest/services/wbd/MapServer/4"
wbd8 = ArcGISRESTful(rest_url)
wbd8.get_featureids(basin_geom)
resp = wbd8.get_features()
huc8 = utils.json_togeodf(resp)

url_wms = "https://www.fws.gov/wetlands/arcgis/services/Wetlands_Raster/ImageServer/WMSServer"
layer = "0"
r_dict = wms_bybox(
    url_wms,
    layer,
    basin_geom.bounds,
    1e3,
    "image/tiff",
    box_crs="epsg:4326",
    crs="epsg:3857",
)
geom = MatchCRS.geometry(basin_geom, "epsg:4326", "epsg:3857")
wetlands = utils.wms_toxarray(r_dict, geom, "epsg:3857")

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="epsg:4269",
)
bbox = basin_geom.bounds
bbox = (bbox[1], bbox[0], bbox[3], bbox[2])
r = wfs.getfeature_bybox(bbox, box_crs="epsg:4326")
flood = utils.json2geodf(r.json(), "epsg:4269", "epsg:4326")

Contributing

Contirbutions are very welcomed. Please read CODE_OF_CONDUCT.rst and CONTRIBUTING.rst file for instructions.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

pygeoogc-0.1.3.tar.gz (28.0 kB view hashes)

Uploaded Source

Built Distribution

pygeoogc-0.1.3-py2.py3-none-any.whl (15.5 kB view hashes)

Uploaded Python 2 Python 3

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page