Esempio n. 1
0
# shapefile in the data directory

sfile = 'data/boundary'

# output shapefile name

damfile = '02060006dams'

# path to place the NID shapefile

NID = 'NID'

# make an instance of the extractor to work with; the base US NID shapefile
# will be downloaded and extracted automatically if it doesn't exist

nidextractor = NIDExtractor(NID)

# extract the data to a new shapefile

nidextractor.extract_shapefile(sfile, damfile)

# the extractor can also extract data to a new shapefile using a bounding box

bbox = -78, 38, -75, 40

# output file name

bboxfile = 'bbox'

nidextractor.extract_bbox(bbox, bboxfile)
Esempio n. 2
0
def main():

    # make sure the metadata are set before starting the download

    print('')
    print(('preparing to delineate the subbasins for HUC {}\n'.format(HUC8)))
    print(
        ('if you have already downloaded the NHDPlus, NWIS, and NID source ' +
         'data make sure you set the directory paths, or all the data will ' +
         'be downloaded again.\n'))
    print('press "y" to continue or "n" to abort...\n')

    s = 'n'
    while s != 'y':
        s = eval(input())
        if s == 'n': exit()

    # source data directory structure (ideally a data drive or server)

    NHDPlus = '{}/NHDPlus'.format(source)
    NWIS = '{}/NWIS'.format(source)
    NID = '{}/NID'.format(source)

    # download and extract the data using the PyHSPF data extractors (if needed)
    # these steps can/will be skipped if they are not needed

    nhdplusextractor = NHDPlusExtractor(HUC8[:2], NHDPlus)
    nwisextractor = NWISExtractor(NWIS)
    nidextractor = NIDExtractor(NID)

    # extract or set the path to the source NHDPlus data

    nhdplusextractor.download_data()

    # extract the hydrography data for the HUC8 to the output directory

    nhdplusextractor.extract_HUC8(HUC8, output)

    # paths to the NHDPlus data files created above by the nhdplusextractor

    bfile = '{}/boundary'.format(output)  # watershed boundary
    cfile = '{}/catchments'.format(output)  # individual catchments
    ffile = '{}/flowlines'.format(output)  # individual flowlines
    VAAs = '{}/flowlineVAAs'.format(output)  # value-added attributes
    efile = '{}/elevations'.format(output)  # elevation geotiff

    # extract the NWIS gages to a shapefile in the HUC8 directory

    nwisextractor.extract_HUC8(HUC8, output)

    # path to the gage shapefile created above

    gfile = '{}/gagestations'.format(output, HUC8)

    # extract the NID dams to a shapefile in the new HUC8 directory

    dfile = '{}/dams'.format(output, HUC8)

    nidextractor.extract_shapefile(bfile, dfile)

    # use the locations of the gages and dams, the NHDPlus data files, and
    # PyHSPF's HUC8Delineator to delineate subbasins subject to the criteria
    # into a new file in the HUC8 output directory

    delineator = HUC8Delineator(HUC8, VAAs, ffile, cfile, efile, gfile, dfile)

    # delineate the watershed using the NHDPlus data and delineator

    delineator.delineate(output, drainmax=drainmax, parallel=parallel)
Esempio n. 3
0
# shapefile in the data directory

sfile = 'data/boundary'

# output shapefile name

damfile = '02060006dams'

# path to place the NID shapefile

NID = 'NID'

# make an instance of the extractor to work with; the base US NID shapefile
# will be downloaded and extracted automatically if it doesn't exist

nidextractor = NIDExtractor(NID)

# extract the data to a new shapefile

nidextractor.extract_shapefile(sfile, damfile)

# the extractor can also extract data to a new shapefile using a bounding box 

bbox = -78, 38, -75, 40

# output file name

bboxfile = 'bbox'

nidextractor.extract_bbox(bbox, bboxfile)