The gssurgo
python package enables open source workflows with the gSSURGO
dataset. It provides:
-
A shell script
extract_gssurgo_tif
for generating stand-alonegSSURGO
grids. These raster grids are distributed within file geodatabase archives and can only be extracted using ArcGIS, the fileGDB driver, or (in the case ofextract_gssurgo_tif
) thearcpy
python package. -
Python functions for converting Geodatabase files to geopackage format.
-
Python functions for returning the results of specific
SQL
queries ofgSSURGO
data. -
Python functions for referencing query results to corresponding (raster) grid cells.
-
The intial
tif
(grid) extraction step requies thearcpy
python module. This step assumes that a python executable linked toarcpy
can be found atC:\Python27\ArcGIS10.3\python.exe
. Edit bin/extract_gssurgo_tif to enable alternate locations. -
Remaining operations require the dependencies listed in environment.yml and requirements.txt. If using Anaconda, make sure you have the 64bit version. You can install an Anaconda virtual environment with:
conda env create -n gssurgo -f environment.yml
source activate gssurgo
# local install
# pip install -e .
# development install
pip install git+git://github.com/jsta/gssurgo.git
# development upgrade
# pip install --upgrade git+git://github.com/jsta/gssurgo.git
A demonstration workflow using the gssurgo
python package can be found at: https://github.com/jsta/gssurgo_data
extract_gssurgo_tif 'path/to/gSSURGO_STATE.gdb/MapunitRaster_10m' 'path/to/STATE.tif'
import gssurgo
gssurgo.build_gpkg("path/to/gSSURGO_STATE.gdb", "path/to/gSSURGO_STATE.gpkg")
gssurgo.aoi(in_raster_path = "tifs", out_raster = "path/to/aoi.tif", xmax = -88.34945, xmin = -88.35470, ymin = 38.70095, ymax = 38.70498)
gssurgo.query_gpkg(src_tif = "tests/aoi.tif", gpkg_path = "path/to/gkpgs/", sql_query = 'SELECT mukey, nonirryield_r FROM mucropyld WHERE (cropname = "Corn")', out_raster = "tests/aoi_results.tif")
gssurgo.query_gpkg(src_tif = "tests/aoi.tif", gpkg_path = "path/to/gpkgs/", sql_query = 'SELECT mukey, nonirryield_r FROM mucropyld WHERE (cropname = "Corn")', out_raster = "tests/aoi_results.tif")
The
sql_query
parameter must give a two column result ofmukey
andsome_variable
where nomukey
entries are duplicated.
gssurgo.viz_numeric_output("path/to/aoi_results.tif", "path/to/aoi_results.png")