Skip to content

Instantly share code, notes, and snippets.

<!DOCTYPE html>
<meta charset="utf-8">
<style>
body {
font: 10px sans-serif;
}
.axis path,
@bmount
bmount / read_srtm_hgt.js
Last active December 10, 2015 23:28
Reading SRTM hgt files in JavaScript
f = require('fs')
h = f.readFileSync('sfoak_srtm_vox.buf')
// read the (1/4 over, 1/4th down) point, 2nd arg would be 3601* 500 + 100 for 50th x in 250th row (2 bytes per record):
g = new DataView(h, Math.pow(2, 3601)/2, 1000)
> g.getInt16(0, true)
97
<!DOCTYPE html>
<meta charset="utf-8">
<style>
html {
font-family: Helvetica;
}
path {
@bmount
bmount / hgt_png_snip
Last active December 11, 2015 07:59
piece of srtm San Francisco area in grayscale png
checked in raw

The now:

curl -o tweet.stream -u $TWUSER:$TWPASS -X POST https://stream.twitter.com/1.1/statuses/filter.json\?locations\=-123.0,37.0,-122.0,38.0

The future:

?? -? tweet.stream ?????:????? -? https://stream.twitter.com/1.1/statuses/filter.json... ?? ???????

@bmount
bmount / qgis_libs.sh
Created February 7, 2013 00:05
reminder about installing QGIS build from here: http://qgis.dakotacarto.com/ with a combination of libraries from source and homebrew. Leave a comment if you notice something barbaric (or just bad.)
sudo mkdir -p /Library/Frameworks/GDAL.framework/Versions/1.9/
sudo ln -s /usr/local/lib/libgdal.dylib /Library/Frameworks/GDAL.framework/Versions/1.9/GDAL
sudo mkdir -p /Library/Frameworks/PROJ.framework/Versions/4/
sudo ln -s /usr/local/Cellar/proj/4.8.0/lib/libproj.dylib /Library/Frameworks/PROJ.framework/Versions/4/PROJ
# did not work: sudo ln -s `pwd`/libgeos.dylib /Library/Frameworks/GEOS.framework/Versions/3/GEOS
# did work:
# $PWD is /usr/local/Cellar/geos/3.3.6/lib
sudo ln -s `pwd`/libgeos_c.1.dylib /Library/Frameworks/GEOS.framework/Versions/3/GEOS
sudo mkdir -p /Library/Frameworks/SQLite3.framework/Versions/3/
sudo ln -s /usr/local/Cellar/sqlite/3.7.15/lib/libsqlite3.0.8.6.dylib /Library/Frameworks/SQLite3.framework/Versions/3/SQLite3
@bmount
bmount / naip_break-up.py
Created February 9, 2013 01:05
reminder about breaking up huge National Agricultural Imagery Program (NAIP) tif files
# coding: utf-8
import os
# naip SF collection in geotiff from gdalinfo via mrsiddecode:
xmax = 72260
ymax = 21650
x = xmax
y = 21650
tmp = """gdal_translate -of PNG -srcwin {0} {1} 2000 2000 sf2012.tif bigslice/sf_partial-{2}.png"""
while x > 0:
@bmount
bmount / srtm_regions.js
Last active December 14, 2015 10:49
Region and url finder for SRTM1
function region (pt) {
var pt = pt, regions, r;
if (!Array.isArray(pt) || pt.length < 2) return false;
/*
* Boundaries of SRTM regions as lower left -> upper right:
* [[min lon,min lat], [max lon, max lat]]
* The records use lower left coordinates, so N37W123.hgt covers 37->38 lat, -123->-122 lon
* See: http://dds.cr.usgs.gov/srtm/version2_1/SRTM1/Region_definition.jpg
*/
regions = r = [
{"dp0150001": "Households with individuals 65 years and over", "dp0090004": "Total races tallied: Asian alone or in combination with one or more other races", "dp0090005": "Total races tallied: Native Hawaiian and Other Pacific Islander alone or in combination with one or more other races", "shape": "Unrepresentable_Domain: Coordinates defining the features.", "dp0090001": "Total races tallied: White alone or in combination with one or more other races", "dp0090002": "Total races tallied: Black or African American alone or in combination with one or more other races", "dp0090003": "Total races tallied: American Indian and Alaska Native alone or in combination with one or more other races", "dp0120006": "Total population: In Households: Child: Own child under 18 years", "dp0010040": "Total Population: Female: Under 5 years", "dp0010041": "Total Population: Female: 5 to 9 years", "dp0010042": "Total Population: Female: 10 to 14 years", "dp0010043": "Total Population: Female: 15 to 19 years", "dp0010044": "Total
@bmount
bmount / gist:5863926
Created June 26, 2013 01:10
opencv build with homebrew/some other python. reminder about setting cmake variables
cmake -DPYTHON_EXECUTABLE:PATH='/usr/local/bin/python' -DPYTHON_INCLUDE_DIR:PATH='/usr/local/Cellar/python/2.7.5/Frameworks/Python.framework/Versions/2.7/include/python2.7/' -DPYTHON_LIBRARY:PATH='/usr/local/Cellar/python/2.7.5/Frameworks/Python.framework/Versions/2.7/lib/libpython2.7.dylib' -G "Unix Makefiles"