Skip to content

Instantly share code, notes, and snippets.

@mojodna
mojodna / bbox.sql
Created Feb 1, 2017
Find all nodes, ways, and relations in a bounding box (AWS Athena + OSM ORC).
View bbox.sql
with params as (
select
27.61649608612061 as minlon,
53.85379229563698 as minlat,
27.671985626220707 as maxlon,
53.886459293813054 as maxlat
), direct_nodes as (
select n.id, n.version, n.changeset, n.timestamp, n.lat, n.lon
from
planet n,
View gist:dac599b2c69a1958ececf3de42ceb358
IFS="\n"; for line in $(grep JPG 2016_06_08_fluff4_geoinfo.txt); do echo $line | awk '{print "exiftool " $1 " -exif:gpslatitude=" $2 " -exif:gpslatituderef=S -exif:gpslongitude=" $3 " -exif:gpslongituderef=W -exif:gpsaltitude=" $4}'; done > fluff4.sh; IFS=
@mojodna
mojodna / get_zoom.py
Created Aug 30, 2016
Get the closest web mercator zoom for a raster input
View get_zoom.py
import math
import sys
import rasterio
from rasterio.warp import (calculate_default_transform, transform)
CHUNK_SIZE = 256
@mojodna
mojodna / polygonize_landcover.py
Created Jun 30, 2016
Polygonize landcover block-by-block.
View polygonize_landcover.py
from __future__ import print_function
import json
import sys
import fiona
from fiona.crs import from_epsg
import rasterio
from rasterio import features
@mojodna
mojodna / README.md
Last active Sep 7, 2016
TileMill in bash + AppleScript
View README.md

TileMill in bash + AppleScript

Installation (OS X)

In the project directory:

npm install tessera tilelive-mapnik tilelive-carto
brew install fswatch
@mojodna
mojodna / README.md
Last active May 14, 2017
Chunk out NED ⅓arc second data using pyspark
View README.md

To run this on EMR, do something akin to the following (with buckets changed as appropriate):

aws emr create-cluster \
  --name "NED Conversion" \
  --log-uri s3://ned-13arcsec.openterrain.org/logs/ \
  --release-label emr-4.0.0 \
  --use-default-roles \
  --auto-terminate \
  --ec2-attributes KeyName=stamen-keypair \
@mojodna
mojodna / README.md
Last active Apr 15, 2020
GDAL 2.0 on Amazon Linux
View README.md
sudo yum -y update
sudo yum-config-manager --enable epel
sudo yum -y install make automake gcc gcc-c++ libcurl-devel proj-devel geos-devel
cd /tmp
curl -L http://download.osgeo.org/gdal/2.0.0/gdal-2.0.0.tar.gz | tar zxf -
cd gdal-2.0.0/
./configure --prefix=/usr/local --without-python
make -j4
sudo make install
View osm.xml
<GDAL_WMS>
<Service name="TMS">
<ServerUrl>http://tile.openstreetmap.org/${z}/${x}/${y}.png</ServerUrl>
</Service>
<DataWindow>
<UpperLeftX>-20037508.34</UpperLeftX>
<UpperLeftY>20037508.34</UpperLeftY>
<LowerRightX>20037508.34</LowerRightX>
<LowerRightY>-20037508.34</LowerRightY>
<TileLevel>18</TileLevel>
View dynamodb-batch-get.js
"use strict";
var AWS = require("aws-sdk");
AWS.config.update({
region: process.env.AWS_DEFAULT_REGION || AWS.config.region || "us-east-1"
});
var dynamodb = new AWS.DynamoDB();
@mojodna
mojodna / queue_srtm.js
Created Apr 25, 2015
Vapor clock feeder
View queue_srtm.js
#!/usr/bin/env node
/* eslint-disable no-sync */
"use strict";
var assert = require("assert"),
fs = require("fs"),
path = require("path"),
util = require("util");
var env = require("require-env"),
You can’t perform that action at this time.