Giter Site home page Giter Site logo

luoyec / gssurgo Goto Github PK

View Code? Open in Web Editor NEW

This project forked from jsta/gssurgo

0.0 0.0 0.0 3.68 MB

Python package enabling an open source gSSURGO workflow

Home Page: https://www.nrcs.usda.gov/wps/portal/nrcs/detail/soils/survey/geo/?cid=nrcs142p2_053628

License: MIT License

Python 87.69% Shell 1.80% R 10.51%

gssurgo's Introduction

gssurgo

PyPiVersionProject Status: Active - The project has reached a stable, usable state and is being actively developed.PYPI Downloads

The gssurgo python package enables open source workflows with the gSSURGO dataset. It provides:

  • A shell script extract_gssurgo_tif for generating stand-alone gSSURGO grids. These raster grids are distributed within file geodatabase archives and can only be extracted using ArcGIS, the fileGDB driver, or (in the case of extract_gssurgo_tif) the arcpy python package.

  • Python functions for converting Geodatabase files to geopackage format.

  • Python functions for returning the results of specific SQL queries of gSSURGO data.

  • Python functions for referencing query results to corresponding (raster) grid cells.

Prereqs

  • The intial tif (grid) extraction step requies the arcpy python module. This step assumes that a python executable linked to arcpy can be found at C:\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

Installation

# 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

Usage

1. Extract tif and build gpkgs

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")

2. Generate an Area of Interest (AOI)

gssurgo.aoi(in_raster_path = "tifs", out_raster = "path/to/aoi.tif", xmax = -88.34945, xmin = -88.35470, ymin = 38.70095, ymax = 38.70498)

3. Pull specific variable and merge with corresponding tif

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 of mukey and some_variable where no mukey entries are duplicated.

4. Visualize output

gssurgo.viz_numeric_output("path/to/aoi_results.tif", "path/to/aoi_results.png")

gssurgo's People

Contributors

jsta avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.