Skip to content

Instantly share code, notes, and snippets.

@jqtrde
jqtrde / gdal_hdf.md
Last active August 29, 2015 14:17 — forked from drewbo/gdal_hdf.md

MODIS downloads are stored as .hdf files which makes them non-trivial to interact with.

I've previously mentioned using HEG but for a more streamlined approach we're going to want to use gdal.

Compiling GDAL with HDF4 support can actually be done fairly easily using brew although information on this was a bear to find. Thanks to Wood Sun we can do this via three commands

brew tap homebrew/versions
brew install hdf4
brew install https://raw.githubusercontent.com/geoalchimista/homebrew/master/formulae/gdal.rb --with-hdf4
@jqtrde
jqtrde / index.html
Last active August 29, 2015 14:17 — forked from wboykinm/index.html
<!DOCTYPE html>
<html>
<head>
<meta charset='utf-8' />
<title></title>
<meta name='viewport' content='initial-scale=1,maximum-scale=1,user-scalable=no' />
<script src='https://api.tiles.mapbox.com/mapbox-gl-js/v0.7.0/mapbox-gl.js'></script>
<script src='tx.js'></script>
<link href='https://api.tiles.mapbox.com/mapbox-gl-js/v0.7.0/mapbox-gl.css' rel='stylesheet' />
<style>

Storytelling from Space: Tools/Resources

This list of resources is all about acquring and processing aerial imagery. It's generally broken up in three ways: how to go about this in Photoshop/GIMP, using command-line tools, or in GIS software, depending what's most comfortable to you. Often these tools can be used in conjunction with each other.

Acquiring Landsat & MODIS

Web Interface

  • Landsat archive
psql DBNAME -c "\\copy (SELECT ST_AsGeoJson(ST_Union(the_geom)) FROM TABLENAME) to '/PATH/TO/YOUR/DESIRED/FILE.geojson'"
# https://www.mapbox.com/blog/processing-landsat-8/
task :landsat_2014 => :environment do
dirs = Dir["#{Rails.root.to_s}/db/initial/raster/*"].reject {|q| q =~ /tar\.gz/ }
dirs.each do |dir|
scene_id = dir.split("/")[-1]
[4,3,2].each do |band|
`gdalwarp -t_srs EPSG:3857 #{dir}/#{scene_id}_B#{band}.TIF #{dir}/#{scene_id}_B#{band}-projected.tif`
end
`convert -combine #{dir}/#{scene_id}_B{4,3,2}-projected.tif #{dir}/#{scene_id}_RGB-projected.tif && \
convert -channel B -gamma 0.925 -channel R -gamma 1.03 -channel RGB -sigmoidal-contrast 50x16% #{dir}/#{scene_id}_RGB-projected.tif #{dir}/#{scene_id}_RGB-projected-corrected.tif && \
@jqtrde
jqtrde / load_shp_to_AWS
Last active August 29, 2015 14:16 — forked from glw/load_shp_to_AWS
shp2pgsql -s 4326 -d -g the_geom shapefilename.shp shapefilename |psql -U username --password -p 5432 -h reallylonghostnametoamazonaws.com dbname
@jqtrde
jqtrde / index.html
Last active August 29, 2015 14:15 — forked from anonymous/index.html
<!DOCTYPE html>
<html>
<head>
<title>Foo</title>
<meta charset='utf-8' />
<meta name='viewport' content='width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=0' />
<style type='text/css'>
div {
cursor:pointer;
cursor:hand;
@jqtrde
jqtrde / README.md
Last active August 29, 2015 14:08 — forked from jasondavies/README.md

Based on Mike Bostock’s [World Map][0], modified to automatically colour countries such that no adjacent countries share the same colour.

This is done by extracting the topology via [TopoJSON][1] and greedily picking colours until the constraint is fulfilled.

See also: [Graph coloring][2] on Wikipedia.

Update: Greedily colouring is now performed in a single line, thanks to Mike Bostock!

@jqtrde
jqtrde / L8.sh
Last active August 29, 2015 14:06 — forked from YKCzoli/L8.sh
#!/bin/bash
echo "Enter bands (ie 4 3 2)"
read B1 B2 B3
echo "Enter the resulting filename"
read outputname