Skip to content

Instantly share code, notes, and snippets.

View davidheyman's full-sized avatar

David Heyman davidheyman

View GitHub Profile
INSERT INTO geo_header_sf1 (fileid, stusab, sumlev, geocomp, chariter, cifsn, logrecno, region, division, state, county, countycc, countysc, cousub, cousubcc, cousubsc, place, placecc, placesc, tract, blkgrp, block, iuc, concit, concitcc, concitsc, aianhh, aianhhfp, aianhhcc, aihhtli, aitsce, aits, aitscc, ttract, tblkgrp, anrc, anrccc, cbsa, cbsasc, metdiv, csa, necta, nectasc, nectadiv, cnecta, cbsapci, nectapci, ua, uasc, uatype, ur, cd, sldu, sldl, vtd, vtdi, reserve2, zcta5, submcd, submcdcc, sdelem, sdsec, sduni, arealand, areawatr, name, funcstat, gcuni, pop100, hu100, intptlat, intptlon, lsadc, partflag, reserve3, uga, statens, countyns, cousubns, placens, concitns, aianhhns, aitsns, anrcns, submcdns, cd113, cd114, cd115, sldu2, sldu3, sldu4, sldl2, sldl3, sldl4, aianhhsc, csasc, cnectasc, memi, nmemi, puma, reserved)
SELECT
trim(substring(data,1,6)) AS fileid,
trim(substring(data,7,2)) AS stusab,
trim(substring(data,9,3)) AS sumlev,
trim(substring(data,12,2)) AS geocomp,
trim(substring(data,14,3)) AS
# install epel repo
sudo yum -y install wget
wget https://dl.fedoraproject.org/pub/epel/epel-release-latest-7.noarch.rpm
sudo rpm -Uvh epel-release-latest-7.noarch.rpm
wget http://yum.postgresql.org/9.3/redhat/rhel-7-x86_64/pgdg-redhat93-9.3-1.noarch.rpm
sudo rpm -Uvh pgdg*.rpm
# update (again)
sudo yum -y update
Steps:
Set up EBS
21Created 1 TB EBS
Created 64 Bit Amazon Linux AMI 2012.09 M1 Medium 3.7 gb ram, 2 ECUs
Connect to ec2 instance via ssh
chmod 400 IFS-KeyPair.pem
ssh -v -i IFS-KeyPair.pem [email protected]
Note: Do not replace ec2-user with your user id. This is a AWS Amazon AMI requirement.
// Based on Glacier's example: http://docs.aws.amazon.com/AWSJavaScriptSDK/guide/examples.html#Amazon_Glacier__Multi-part_Upload
var fs = require('fs');
var AWS = require('aws-sdk');
AWS.config.loadFromPath('./aws-config.json');
var s3 = new AWS.S3();
// File
var fileName = '5.pdf';
var filePath = './' + fileName;
var fileKey = fileName;

Keybase proof

I hereby claim:

  • I am davidheyman on github.
  • I am davidheyman (https://keybase.io/davidheyman) on keybase.
  • I have a public key whose fingerprint is E39B FE40 D15B 962B 189E 8C5C F0F2 DE54 5DED 409D

To claim this, I am signing this object:

DROP VIEW IF EXISTS bivariate;
CREATE VIEW bivariate AS
SELECT gid, gdp, pop, aal_gdp, aal_pop, aal_gdp / gdp AS gdp_pct, aal_pop / pop AS pop_pct, geom
FROM admin1
INNER JOIN (
SELECT aal AS aal_gdp, wb_adm1_co
FROM flood
WHERE analysis_sector = 'GDP' AND year = 2010
) AS fl ON admin1.adm1_code = fl.wb_adm1_co
INNER JOIN (
sudo apt-get update
sudo apt-get upgrade
sudo apt-get install -y postgis postgresql-9.3-postgis-2.1 imagemagick
cd ~rails
git clone https://github.com/axismaps/cognita.git
cp ~rails/rails_project/config/database.yml ~rails/cognita/config/
# create transparency band
for f in *tif;
do
gdal_translate -b 1 -ot Byte $f red.tif;
gdal_translate -b 2 -ot Byte $f green.tif;
gdal_translate -b 3 -ot Byte $f blue.tif;
gdal_translate -a_nodata none $f no.tif;
gdal_calc.py -A no.tif --outfile=mask.tif --calc="(A<=255)*255";
gdal_merge.py -separate -o ../ToCompress/$f red.tif green.tif blue.tif mask.tif;
sudo rm red.tif;
@davidheyman
davidheyman / mapshaper.sh
Last active February 1, 2017 14:21
MapMaster Data Processing Commands
# Convert shp to topjson and simplify
mapshaper -i /Volumes/Storage/Box\ Sync/MapMaster\ data/World/Physical\ Environment/Vector/005_Water_Resources_Vulnerability/005_Water_Resources_Vulnerability.shp -simplify 5% -o data/world/005_water_resources.json format=topojson
# Load shapefiles in subdirectories into PostGIS
for f in *; do cd $f; for g in *.shp; do shp2pgsql -I -s 4326 $g `basename $g .shp` | psql -d mapmaster; cd ../; done; done
# Install Mapshaper
npm install -g mapshaper
# Install Tippecanoe
brew install tippecanoe
# Make a directory for your geojson files and convert all the shapefiles in a directory to geojson
mkdir ../geojson
for f in *.shp;
do