|
tuple | parser = argparse.ArgumentParser(description='Assemble regional NHDPLus V2 data into a national dataset') |
|
string | help = 'The configuration file' |
|
| required = True, |
|
| default = False, |
|
tuple | args = parser.parse_args() |
|
tuple | config = ConfigParser.RawConfigParser() |
|
tuple | pathOfOgr = config.get('GDAL/OGR', 'PATH_OF_OGR2OGR') |
|
tuple | pathOfFind = config.get('UTIL', 'PATH_OF_FIND') |
|
tuple | pathOfSevenZip = config.get('UTIL', 'PATH_OF_SEVEN_ZIP') |
|
tuple | pathOfSqlite = config.get('UTIL', 'PATH_OF_SQLITE') |
|
tuple | nhdPlusDB = os.path.join(args.outputDir, "NHDPlusDB.sqlite") |
|
tuple | zipFiles = subprocess.check_output("%s %s -type f -name *.7z -print" % (pathOfFind, args.archiveDir,), shell=True) |
|
string | sevenZCommand = "%s x -y -o%s %s" |
|
tuple | returnCode = os.system(sevenZCommand) |
|
tuple | gageLocDB = os.path.join(args.outputDir, "GageLoc.sqlite") |
|
tuple | gageLoc = subprocess.check_output("%s %s -type f -iname GageLoc.shp -print" % (pathOfFind, args.outputDir,), shell=True) |
|
list | gageLocShp = gageLoc[0] |
|
string | ogrCommand = '%s -gt 65536 -f "SQLite" -t_srs "EPSG:4326" %s %s' |
|
string | sqliteCommand = "%s %s 'CREATE INDEX IF NOT EXISTS reachcode_measure_idx on GageLoc (reachcode,measure)'" |
|
tuple | conusCatchment = os.path.join(args.outputDir, "Catchment.sqlite") |
|
tuple | shapefiles = subprocess.check_output("%s %s -type f -iname Catchment.shp -print" % (pathOfFind, args.outputDir,), shell=True) |
|
tuple | numFiles = len(shapefiles) |
|
int | currFile = 0 |
|
tuple | pctComplete = (float(currFile) / float(numFiles)) |
|
tuple | conn = sqlite3.connect(nhdPlusDB) |
|
tuple | cursor = conn.cursor() |
|
tuple | dbfs = subprocess.check_output("%s %s -type f -iname PlusFlowlineVAA.dbf -print" % (pathOfFind, args.outputDir,), shell=True) |
|
tuple | f = open(file, 'rb') |
|
tuple | db = list(dbfreader(f)) |
|
list | records = db[2:] |
|
list | GNIS_NBR = record[13] |
|
tuple | dbf = subprocess.check_output("%s %s -type f -iname GageLoc.dbf -print" % (pathOfFind, args.outputDir,), shell=True) |
|
Builds SQLite3 databases from NHDPlus V2 data archives downloaded from http://www.horizon-systems.com/NHDPlus/NHDPlusV2_home.php.
Assembles regional NHDPlus V2 data into national dataset suitable for gage- reach based region of interest extraction
- Note
- Requires GDAL/OGR that has been built with SQLite3 support
-
Requires 7z to extract data from archive files
This software is provided free of charge under the New BSD License. Please see the following license information:
Copyright (c) 2013, University of North Carolina at Chapel Hill All rights reserved.
Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:
- Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.
- Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.
- Neither the name of the University of North Carolina at Chapel Hill nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE UNIVERSITY OF NORTH CAROLINA AT CHAPEL HILL BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- Author
- Brian Miles brian.nosp@m._mil.nosp@m.es@un.nosp@m.c.ed.nosp@m.u
Usage:
1 NHDPlusSetup.py -i <config_file> -a <archive_dir> -o <output_dir>