Skip to content

Instantly share code, notes, and snippets.

@gabrieldance
gabrieldance / cut_out_states.rb
Last active August 29, 2015 14:07
cut out states from country shapefile
require 'csv'
states = CSV.read('states_w_regions.csv',headers:true)
states.each do |state|
puts(state["id"], state["abbreviation"])
`ogr2ogr -f "ESRI Shapefile" -sql "select * from cb_2013_us_county_500k where cast(STATEFP as integer(2)) = #{state["fips_state"]}" cb_2013_#{state["abbreviation"]}_county_500k.shp ../cb_2013_us_county_500k.shp`
end
# These are shell functions to quickly create pansharpened RGB images ready for color correction
# from a set of raw Landsat 8 TIF files in a given directory.
# For example:
# l8_pansharp LC81690352014169LGN00
# Creates:
# LC81690352014169LGN00_rgb_pansharp.tif
# l8_rush_pansharp downloads a L8 tile from Google Storage (if they have it), extracts the relevant bands, then creates the pansharpened output.
We can't make this file beautiful and searchable because it's too large.
ST_FIPS,SFIPS,COUNTY_FIP,CFIPS,PL_FIPS,ID,NAME,ELEVATION,POP_1990,POPULATION,ST,STATE,WARNGENLEV,WARNGENTYP,WATCH_WARN,ZWATCH_WAR,PROG_DISC,ZPROG_DISC,COMBOFLAG,LAND_WATER,RECNUM,LON,LAT
50,50,023,023,NULL,1457265,East Calais,850,0.0,NULL,VT,VERMONT,3,NULL,3,0.0,50,50.0,0.0,NULL,0.0,-72.4303,44.3664
50,50,023,023,NULL,15000150000,Exit 9 I89,NULL,0.0,NULL,VT,VERMONT,3,NULL,3,0.0,125,125.0,0.0,NULL,0.0,-72.6851,44.2982
50,50,023,023,NULL,1919082,Exit 10 I89,459,0.0,NULL,VT,VERMONT,3,NULL,3,0.0,125,125.0,0.0,NULL,0.0,-72.7513,44.3427
50,50,023,023,NULL,1457229,Duxbury,420,0.0,NULL,VT,VERMONT,2,NULL,2,0.0,100,100.0,0.0,NULL,0.0,-72.7531,44.3269
50,50,023,023,NULL,1460076,Waterbury Center,725,0.0,NULL,VT,VERMONT,2,NULL,2,0.0,125,125.0,0.0,NULL,0.0,-72.7164,44.3781
50,50,023,023,NULL,1460309,Woodbury,1197,0.0,NULL,VT,VERMONT,3,NULL,3,0.0,100,100.0,0.0,NULL,0.0,-72.42,44.43
50,50,023,023,NULL,1461796,Exit 8 I89,550,0.0,NULL,VT,VERMONT,3,NULL,3,0.0,125,125.0,0.0,NULL,0.0,-72.5963,44.2507
50,50,023,023,NULL,1457248,Ea
We can't make this file beautiful and searchable because it's too large.
NAME,NAMEASCII,SOV0NAME,SOV_A3,ADM0NAME,ADM0_A3,ADM1NAME,ISO_A2,LATITUDE,LONGITUDE,POP_MAX,POP_MIN,POP_OTHER,LS_NAME
Colonia del Sacramento,Colonia del Sacramento,Uruguay,URY,Uruguay,URY,Colonia,UY,-34.4799990054,-57.8400024734,21714,21714,0,NULL
Trinidad,Trinidad,Uruguay,URY,Uruguay,URY,Flores,UY,-33.5439989374,-56.9009965602,21093,21093,0,NULL
Fray Bentos,Fray Bentos,Uruguay,URY,Uruguay,URY,Ro Negro,UY,-33.1389990288,-58.3039974719,23279,23279,0,NULL
Canelones,Canelones,Uruguay,URY,Uruguay,URY,Canelones,UY,-34.5380040067,-56.2840014932,19698,19698,0,NULL
Florida,Florida,Uruguay,URY,Uruguay,URY,Florida,UY,-34.0990020052,-56.214998448,32234,32234,0,NULL
Bassar,Bassar,Togo,TGO,Togo,TGO,Kara,TG,9.26100006832,0.78900357378,61845,61845,0,NULL
Sotouboua,Sotouboua,Togo,TGO,Togo,TGO,Centre,TG,8.55700213306,0.98499646233,21054,21054,0,NULL
Medenine,Medemine,Tunisia,TUN,Tunisia,TUN,Mdenine,TN,33.3999990025,10.4166995576,61705,61705,0,NULL
Kebili,Kebili,Tunisia,TUN,Tunisia,TUN,Kebili,TN,33.6899970349,8.9710025379,19875