Metadata-Version: 2.1
Name: pygeoogc
Version: 0.1.2
Summary: An interface to web services based on ArcGIS RESTful, WFS, and WMS.
Home-page: https://github.com/cheginit/pygeoogc
Author: Taher Chegini
Author-email: cheginit@gmail.com
License: MIT license
Platform: UNKNOWN
Classifier: Development Status :: 3 - Alpha
Classifier: License :: OSI Approved :: MIT License
Classifier: Operating System :: OS Independent
Classifier: Intended Audience :: Science/Research
Classifier: Programming Language :: Python
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3.6
Classifier: Programming Language :: Python :: 3.7
Classifier: Programming Language :: Python :: 3.8
Classifier: Topic :: Scientific/Engineering
Requires-Python: >=3.6
Description-Content-Type: text/x-rst
Requires-Dist: pip
Requires-Dist: owslib
Requires-Dist: pyproj
Requires-Dist: shapely
Requires-Dist: simplejson
Requires-Dist: defusedxml
Requires-Dist: requests
Requires-Dist: dataclasses

.. image:: https://raw.githubusercontent.com/cheginit/hydrodata/develop/docs/_static/pygeoogc_logo.png
    :target: https://github.com/cheginit/pygeoogc
    :align: center

|

.. image:: https://img.shields.io/pypi/v/pygeoogc.svg
    :target: https://pypi.python.org/pypi/pygeoogc
    :alt: PyPi

.. image:: https://codecov.io/gh/cheginit/pygeoogc/branch/master/graph/badge.svg
    :target: https://codecov.io/gh/cheginit/pygeoogc
    :alt: CodeCov

.. image:: https://github.com/cheginit/pygeoogc/workflows/build/badge.svg
    :target: https://github.com/cheginit/pygeoogc/workflows/build/badge.svg
    :alt: Github Actions

.. image:: https://mybinder.org/badge_logo.svg
    :target: https://mybinder.org/v2/gh/cheginit/hydrodata/develop
    :alt: Binder

|

.. image:: https://www.codefactor.io/repository/github/cheginit/pygeoogc/badge
   :target: https://www.codefactor.io/repository/github/cheginit/pygeoogc
   :alt: CodeFactor

.. image:: https://img.shields.io/badge/code%20style-black-000000.svg
    :target: https://github.com/psf/black
    :alt: black

.. image:: https://img.shields.io/badge/pre--commit-enabled-brightgreen?logo=pre-commit&logoColor=white
    :target: https://github.com/pre-commit/pre-commit
    :alt: pre-commit

|

Features
--------

PyGeoOGC is a part of `Hydrodata <https://github.com/cheginit/hydrodata>`__ software stack
and provides interfaces to web services that are based on
`ArcGIS RESTful <https://en.wikipedia.org/wiki/Representational_state_transfer>`__,
`WMS <https://en.wikipedia.org/wiki/Web_Map_Service>`__, and
`WFS <https://en.wikipedia.org/wiki/Web_Feature_Service>`__.

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 Hydrodata
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 <https://github.com/cheginit/pygeoogc/issues>`__.


Installation
------------

You can install PyGeoOGC using ``pip``:

.. code-block:: console

    $ pip install pygeoogc

Quickstart
----------

We can access
`Watershed Boundary Dataset <https://hydro.nationalmap.gov/arcgis/rest/services/wbd/MapServer>`__
via RESTful service,
`National Wetlands Inventory <https://www.fws.gov/wetlands/>`__ from WMS, and
`FEMA National Flood Hazard <https://www.fema.gov/national-flood-hazard-layer-nfhl>`__
via WFS. The output for these functions are of type ``requests.Response`` that
can be converted to ``GeoDataFrame`` or ``xarray.Dataset`` using Hydrodata.

.. code-block:: python

    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[0])
    huc8 = huc8.append([utils.json_togeodf(r) for r in resp[1:]])

    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",
    )
    r = wfs.getfeature_bybox(basin_geom.bounds, box_crs="epsg:4326")
    flood = utils.json_togeodf(r.json(), "epsg:4269", "epsg:4326")

Contributing
------------

Contirbutions are very welcomed. Please read
`CODE_OF_CONDUCT.rst <https://github.com/cheginit/pygeoogc/blob/master/CODE_OF_CONDUCT.rst>`__
and
`CONTRIBUTING.rst <https://github.com/cheginit/pygeoogc/blob/master/CONTRIBUTING.rst>`__
file for instructions.


