This file contains 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
# VIM regex commands | |
# Get ride of anything not from 2010 - 2015 | |
g!/\(.*\)\(201[0-5]\) /d | |
# Get ride of all areas not relevant to our study area | |
g!/^0601\|^0602\|^1901\|^1902\|^2701\|^2702\|^4301\|^4302\|^4303/d | |
# Split region code from year, get ride of variable code | |
%s/\(.*\)05\(201[0-5]\) /\1 \2/g |
This file contains 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
+proj=aea +lat_1=29.5 +lat_2=45.5 +lat_0=23 +lon_0=-96 +x_0=0 +y_0=0 +ellps=GRS80 +datum=NAD83 +units=m +no_defs |
This file contains 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
gdal_rasterize --config GDAL_CACHEMAX 4000 -burn 1 -tr 1.0 1.0 -te 562 -952 602 -853 -co COMPRESS=LZW CT_Watershed_Above_Haddam_HRAP_Projected.shp CT_Watershed_Above_Haddam_HRAP_Projected.tiff |
This file contains 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
+proj=stere +lat_0=90 +lat_ts=60 +lon_0=-105 +k=1 +x_0=0 +y_0=0 | |
+a=6371200 +b=6371200 +to_meter=4762.5 +no_defs | |
["Degree",0.0174532925199433]],PROJECTION["Stereographic_North_Pole"], | |
PARAMETER["False_Easting",0.0],PARAMETER["False_Northing",0.0], | |
PARAMETER["Central_Meridian",-105.0],PARAMETER["Standard_Parallel_1", | |
60.0],UNIT["HRAP_Grid",4762.5]] |
This file contains 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
#!/home/deepwinter/env/bin/python | |
# using virtual env | |
# http://wiki.dreamhost.com/Python | |
import datetime | |
import time | |
import wget | |
import datetime | |
import tarfile | |
import os.path | |
import urlgrabber |
This file contains 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
# tried with gdalwarp, but ends up slow with a huge file | |
gdalwarp -q -cutline /Users/matthewxi/Documents/Projects/NASQAN/clip_columbia_extent_conus.shp -crop_to_cutline -co COMPRESS=LZW -of GTiff /Users/matthewxi/Documents/Projects/NASQAN/nasqan_raster_conus_compressed/b14246900_polygon.shp30.tiff /Users/matthewxi/Documents/Projects/NASQAN/b14246900_nlcd_clipped_3.tif | |
# gdal_translate seems to be the better option | |
# using extents to crop | |
gdal_translate -projwin -2191346 3275471 -1068667 2168385 -co "COMPRESS=LZW" /Users/matthewxi/Documents/Projects/NASQAN/nasqan_raster_conus_compressed/b14246900_polygon.shp30.tiff /Users/matthewxi/Documents/Projects/NASQAN/b14246900_nlcd_clipped_7.tif |
This file contains 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
require(ncdf) | |
require(raster) | |
file.nc <- 'air.sfc.2009.nc' | |
## Output: a GeoTIFF file | |
file.tiff <- paste('air/air.', sprintf('%.4d',day), '.tiff', sep ='') | |
r.temperature <- raster(file.nc, day) |
This file contains 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
find *.shp -exec gdal_rasterize -burn 1 -tr 200 200 {} ../nasqan_raster_lambert/{}.tif \; | |
# improve performance by loading more data into memory at once | |
find *.shp -exec gdal_rasterize --config GDAL_CACHEMAX 2400 -burn 1 -tr 30 30 -a_srs EPSG:5070 -of HFA {} ../nasqan_raster_conus/{}30.img \; | |
# compress tiffs using LZW to vasty improve disk performance | |
find *.shp -exec gdal_rasterize --config GDAL_CACHEMAX 4000 -burn 1 -tr 30 30 -a_srs EPSG:5070 -co COMPRESS=LZW {} ../nasqan_raster_conus/{}30.tiff \; |
This file contains 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
find *_polygon.shp -exec ogr2ogr -s_srs EPSG:5070 -t_srs EPSG:102009 ../nasqan_polygons_lambert/{} {} \; |
This file contains 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
# need to rescale the values | |
gdal_translate -scale 200 350 0 1 air.59.tif air-rescaled.tif | |
# or batch it | |
find *.tif -exec gdal_translate -scale 200 350 0 1 {} {}.rescaled.tif \; | |
# make into png files | |
mogrify -format jpg *.rescaled.tif |