Skip to content

Instantly share code, notes, and snippets.

import rasterio, fiona
from rasterio import features
uidfield = #whatever field contains unique values for extraction
infile = #input shapefile
inraster = #input raster
with rasterio.open(inraster, 'r') as src:
rasArr = src.read_band(band_no)
oshape = src.shape
process.stdin.pipe(require('split')()).on('data', processLine)
var holder = {}
process.stdin.on('end', function() {
console.log(holder);
});
function processLine (line) {
try {
import os, rasterio
import matplotlib.pyplot as plot
basedir = '/Users/dnomadb/Documents/pwat_hrrr/'
savedir = '/Users/dnomadb/Documents/pwat_hrrr_pngs/'
with rasterio.drivers():
for i in os.listdir(basedir):
if i.split('.')[-1] == 'grib':
print i
2048
{"n0n0n0n0n3n0n0n0n0n0n0n": {"band_1": -30.505917828233898}}
{"s0s0s0s0s3s0s0s0s0s0s0s": {"band_1": -30.517954733905256}}
{"n0n0n0n0n3n0n0n0n0n0n1n": {"band_1": -30.487437598328142}}
{"n0n0n0n0n3n0n0n0n0n0n1s": {"band_1": -30.480835189256492}}
{"n0n0n0n0n3n0n0n0n0n1n0n": {"band_1": -30.451393362010137}}
{"n0n0n0n0n3n0n0n0n0n1n0s": {"band_1": -30.462482709218932}}
{"n0n0n0n0n3n0n0n0n0n1n1n": {"band_1": -30.43480969748125}}
{"n0n0n0n0n3n0n0n0n0n1s1s": {"band_1": -30.429818161815525}}
{"n0n0n0n0n3n0n0n0n1n0n0n": {"band_1": -30.405773830183655}}
2048
{"n0n0n0n0n3n0n0n0n0n0n0n": {"band_1": -30.505917828233898}}
{"s0s0s0s0s3s0s0s0s0s0s0s": {"band_1": -30.517954733905256}}
{"n0n0n0n0n3n0n0n0n0n0n1n": {"band_1": -30.487437598328142}}
{"n0n0n0n0n3n0n0n0n0n0n1s": {"band_1": -30.480835189256492}}
{"n0n0n0n0n3n0n0n0n0n1n0n": {"band_1": -30.451393362010137}}
{"n0n0n0n0n3n0n0n0n0n1n0s": {"band_1": -30.462482709218932}}
{"n0n0n0n0n3n0n0n0n0n1n1n": {"band_1": -30.43480969748125}}
{"n0n0n0n0n3n0n0n0n0n1s1s": {"band_1": -30.429818161815525}}
{"n0n0n0n0n3n0n0n0n1n0n0n": {"band_1": -30.405773830183655}}
556141 function calls (553630 primitive calls) in 0.752 seconds
Ordered by: standard name
ncalls tottime percall cumtime percall filename:lineno(function)
1 0.000 0.000 0.000 0.000 <string>:1(<module>)
1 0.000 0.000 0.000 0.000 <string>:1(Affine)
1 0.000 0.000 0.000 0.000 <string>:1(ArgInfo)
1 0.000 0.000 0.000 0.000 <string>:1(ArgSpec)
1 0.000 0.000 0.000 0.000 <string>:1(Arguments)
556141 function calls (553630 primitive calls) in 0.763 seconds
Ordered by: standard name
ncalls tottime percall cumtime percall filename:lineno(function)
1 0.000 0.000 0.000 0.000 <string>:1(<module>)
1 0.000 0.000 0.000 0.000 <string>:1(Affine)
1 0.000 0.000 0.000 0.000 <string>:1(ArgInfo)
1 0.000 0.000 0.000 0.000 <string>:1(ArgSpec)
1 0.000 0.000 0.000 0.000 <string>:1(Arguments)
z = 3
for t in range(2 ** z):
tbbox = mercantile.bounds(t, t, 3)
childSt = mercantile.tile(tbbox.west, tbbox.north, 11)
childEnd = mercantile.tile(tbbox.east, tbbox.north, 11)
print childSt
Tile(x=0, y=-1, z=11)
Tile(x=256, y=256, z=11)
Tile(x=512, y=511, z=11)
@class1: #245568;
@class2: #215668;
@class3: #1F5768;
@class4: #1D5969;
@class5: #1B5A69;
@class6: #195B69;
@class7: #165C69;
@class8: #145E69;
@class9: #115F69;
@class10: #0E6069;
(
select
st_union(wkb_geometry) as wkb_geometry,
avg(value) as tempval,
left(quadtree, (z(!scale_denominator!)+5)*2+1) as tqt
from latticegrid
where wkb_geometry && !bbox!
group by tqt
) as data