This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from StreamCat_functions import dbf2DF | |
pre = 'D:/NHDPlusV21/NHDPlusGL/NHDPlus04' | |
fline = dbf2DF('D%s/NHDSnapshot/Hydrography/NHDFlowline.dbf' % pre) | |
flow = dbf2DF('%s/NHDPlusAttributes/PlusFlow.dbf' pre)[['TOCOMID','FROMCOMID']] | |
def recurs(val, ups): | |
print val | |
ups = ups + flow.ix[flow.TOCOMID == val].FROMCOMID.tolist() | |
if 0 in ups: |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# create raster from dbf of shapefile | |
# this works only if dbf is set up reading | |
# left to right across rows and top down | |
from osgeo import ogr, gdal | |
from collections import OrderedDict | |
from StreamCat_functions import dbf2DF | |
shp = 'shapes.shp' | |
att = 'TD_N' | |
tbl = dbf2DF(shp.split('.')[0] + '.dbf') |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(nusc) L:\...\WetlandConnectivity\NitrogenModeling\LandscapeRasters\scrap_RD>gdal_rasterize -te -2556000.0, -1728000.0, 2952000.0, 1860000 -tr 12000 12000 -a TD_N -where "TD_N >= 0" -a_nodata -999 -l shapes shapes.shp agree2.tif | |
-te : extent (get from >ogrinfo -so shapes.shp shapes) | |
-tr : cell resolution/size | |
-a : attribute in shapefile to put into raster cells | |
-where : SQL statment on attribute values (not necessarily needed in this case, covered w/ nodata) | |
-a_nodata : value to be turned to nodata | |
-l : layer name w/in shapefile, normally same as filename | |
in .shp filename | |
out .tif file |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import numpy as np | |
import georasters as gr | |
fll = 'D:/Projects/georaster_scrap/old/lakes_05b.tif' | |
a = gr.from_file(fll) | |
a.raster.data[:] = 1 | |
a.raster.unshare_mask() | |
a.nodata_value = 0 | |
a.datatype = 'Byte' |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import numpy as np | |
import georasters as gr | |
def trim_nodata(ras): | |
ras.raster.unshare_mask() | |
bbox = np.where(ras.raster.mask == False) | |
g = ras.geot | |
ymin = bbox[0].min() | |
ymax = bbox[0].max() | |
xmin = bbox[1].min() |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
python -m ipykernel install --user |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import os, sys | |
import itertools | |
import decimal | |
import struct | |
import numpy as np | |
import pandas as pd | |
import datetime | |
from collections import defaultdict | |
from datetime import datetime as dt |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
pd.read_csv('./COMID_HydroRegion.zip', compression='infer', sep=',',dtype={'COMID':int,'VPU':str}) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# -*- coding: utf-8 -*- | |
""" | |
Created on Mon Feb 06 16:02:50 2017 | |
@author: Rdebbout | |
""" | |
import os | |
import h5py | |
import struct |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!DOCTYPE html> | |
<meta charset="utf-8"> | |
<body> | |
<script src="//d3js.org/d3.v3.min.js"></script> | |
<script> | |
var width = 960, | |
height = 500; | |
var nodes = d3.range(200).map(function() { return {radius: Math.random() * 12 + 4}; }), |