Material for AWRA2022 Geospatial R and Python Workshop.
Loosly based on Introduction of Geoinformatics
For working with R, you can use RStudio and you will need the following libraries installed:
library(sf)
library(ggplot2)
library(dplyr)
library(readr)
library(knitr)
library(rnaturalearth)
library(stringr)
library(osmdata)
library(mapview)
library(dataRetrieval)
library(terra)
library(stars)
library(remotes)
library(elevatr)
install_github("mhweber/awra2020spatial")
library(awra2020spatial)
install_github("mhweber/Rspatialworkshop")
library(Rspatialworkshop)
For running Python notebooks you can use a combination of Mambaforge and your favorite IDE such as VS Code or Jupyter Lab. For example, you can install it on OSX as follows:
APP_DIR="~/.local/apps" && \
wget https://github.com/conda-forge/miniforge/releases/latest/download/Mambaforge-MacOSX-x86_64.sh && \
chmod +x Mambaforge-MacOSX-x86_64.sh && \
bash ./Mambaforge-MacOSX-x86_64.sh -b -p ${APP_DIR}/mambaforge && \
rm -f Mambaforge-MacOSX-x86_64.sh
where APP_DIR
can be set to any location of interest.
After installing mambaforge
you can create a Python environment as follows:
git clone https://github.com/mhweber/AWRA2022GeoWorkshop && \
cd AWRA2022GeoWorkshop && \
mamba env create -f environment.yml
Now a new environment called awra2022
is created that can be loaded from your IDE.
You can also use the Binder service by clicking on the Binder badge to launch a Jupyter Lab
instance with all the required Python libraries installed.
Here is a list of some useful geospatial tools and resources:
- General:
- Awesome Geospatial: A Long list of geospatial analysis tools.
- R:
- EPA R User Group R Spatial Workshop: Workshop material from 2021 EPA R User Group meeting on spatial analysis in R
- AWRA 2020 R Spatial Workshop: Material from 2020 AWRA R Spatial Workshop
- Geocomputation With R: One of the best overall resources for working with spatial data in R
- nhdplusTools: R package for manipulation of hydrographic data using the NHDPlus data model
- Hydroinformatics in R: Extensive Notes and exercises for a course on data analysis techniques in hydrology using the programming language R
- r-spatial: Suite of fundamental packages for working with spatial data in R
- Python:
- PyNHD: Navigate and subset NHDPlus (MR and HR) dataset using web services.
- Py3DEP: Access topographic data through National Map's 3DEP web service.
- PyGeoHydro: Access NWIS, NID, WQP, HCDN 2009, NLCD, CAMELS, and SSEBop databases.
- PyDaymet: Access Daymet for daily climate data both single pixel and gridded.
- Python Geospatial: A collection of Python packages for geospatial analysis with binder-ready notebook examples.
- xarray: An open-source project and Python package that makes working with labeled multi-dimensional arrays simple, efficient, and fun!
- rioxarray: Rasterio xarray extension.
- GeoPandas: An open-source project to make working with geospatial data in python easier.
- Proplot:
A succinct
matplotlib
wrapper for making beautiful, publication-quality graphics. - OSMnx: A Python package that lets you download and analyze geospatial data from OpenStreetMap.
- Xarray Spatial:
Implements common raster analysis functions using
numba
and provides an easy-to-install, easy-to-extend codebase for raster analysis. - Datashader: Accurately render even the largest data