Getting Started
Installation
FCPGtools can be installed from PyPI into a virtual environment containing GDAL, and for full functionality, TauDEM as well.
pysheds only quick-start: If you are planning to only use functions supported by the pysheds “terrain engine” you install fcpgtools into your virtual environment of choice using pip:
pip install fcpgtools
For full functionality we strongly encourage the following installation workflow:
Install the Anaconda Python Distribution or Miniconda
Anaconda Individual Edition - includes
conda, a complete Python (and R) data science stack, and the helpful Anaconda Navigator GUI.A lighter-weight alternative is to install Miniconda.
Use the
condacommand line to clone our lightweightfcpgtools_basevirtual environment that contains non-Python dependencies from theenvironment.ymlfile available in our repo. Either clone the repo, or just download the .yml file locally, and run the following commands:conda env create -f {PATH}/environment.yml
Note: We also provide a more robust
environment_dev.ymlvirtual environment for developers containing all libraries relevant to making contributions as well as running our example notebooks.
Activate the
fcpgtools_baseenvironment, and pip installfcpgtools.pip install fcpgtools
(optional) pip install optional libraries required to run our demo notebook (
examples/v2_fcpgtools_demo.ipynb), and to leverage in-line function completion/type-hints.pip install jupyterlab pip install ipympl pip install python-lsp-server pip install jupyterlab-lsp pip install pydaymet
Caution: Unfortunately TauDEM installs old versions of GDAL and PROJ, which has the potential to cause conflict with libraries that require newer versions said dependencies.
Using FCPGtools
Getting started only takes a few lines of code:
# creating an flow accumulation raster from a Flow Direction Raster (FDR)
import fcpgtools
path_to_fdr = r'YOUR/PATH/HERE/fdr.tif'
flow_accumulation_grid = fcpgtools.accumulate_flow(
d8_fdr=path_to_fdr,
) -> xarray.DataArray
Version 2.0 of FCPGtools has a “flat” architecture, meaning all functions
can be accessed by importing the main fcpgtools module as shown in a simple example above.
For a more complete demonstration of fucntionality, we suggest walking-through our examples/fcpgtools_v2_demo.ipynb Jupyter Notebook and our Cookbook and Examples page.
Note that is you are accustomed to Version 1.0 of FCPGtools, we suggest looking over our
Migrating to FCPGtools Version 2.0
page.