Skip to content

Instantly share code, notes, and snippets.

Avatar

Andrew L. Johnson andrewljohnson

View GitHub Profile
@andrewljohnson
andrewljohnson / download_naips.py
Created Mar 24, 2016
download a naip from an s3 RquesterPayer bucket, using boto3
View download_naips.py
import boto3
def download_naips(self):
s3_client = boto3.client('s3')
filename = 'm_3807708_ne_18_1_20130924.tif'
s3_client.download_file('aws-naip', 'md/2013/1m/rgbir/38077/{}'.format(filename), filename, {'RequestPayer':'requester'})
@andrewljohnson
andrewljohnson / globalmaptiles.py
Last active Mar 21, 2016 — forked from tucotuco/globalmaptiles.py
Classes to calculate Tile coordinates
View globalmaptiles.py
#!/usr/bin/env python
###############################################################################
# $Id$
#
# Project: GDAL2Tiles, Google Summer of Code 2007 & 2008
# Global Map Tiles Classes
# Purpose: Convert a raster into TMS tiles, create KML SuperOverlay EPSG:4326,
# generate a simple HTML viewers based on Google Maps and OpenLayers
# Author: Klokan Petr Pridal, klokan at klokan dot cz
# Web: http://www.klokan.cz/projects/gdal2tiles/
@andrewljohnson
andrewljohnson / make_gaia_map_source.py
Created Sep 2, 2015
Make a URL that imports a TMS map source into Gaia GPS
View make_gaia_map_source.py
#!/usr/local/bin/python
import sys
import urllib
'''
make a URL that imports a TMS map source into Gaia GPS
example
View Jekyll Dev Refresher
on run {input, parameters}
tell application "Terminal"
set currentTab to do script ("ps ax | grep jekyll | grep -v grep | awk '{ print $1 }' | xargs kill") in front window
set currentTab to do script ("jekyll serve --detach;") in front window
end tell
tell application "Google Chrome"
activate
set theUrl to "http://0.0.0.0:4000/"
@andrewljohnson
andrewljohnson / ZoomScale
Created May 14, 2014
calculate scale from TMS/Google/OSM zoom level
View ZoomScale
double latitude = self.mapView.mapCenter.latitude;
metersPerPixel *= cos(latitude * (M_PI / 180));
double metersPerUnit = 1609.344;
int numberOfUnits = 1;
NSString *unitName = MILES_UNIT_STRING;
if (metersPerPixel < (1000/maxScaleSize)) {
unitName = METERS_UNIT_STRING;
metersPerUnit = 1;
} else {
unitName = KILOMETERS_UNIT_STRING;
View gist:7810218
def get_point_photos(request, lat, lon, name):
'''takes a lat lon pair via an ajax request, and returns a list of photos'''
#create a Flickr API object
f = flickrapi.FlickrAPI(api_key)
#resolve a (lat,long) to a "Flickr Place" which can be used to search for photos.
place = f.places_findByLatLon(api_key = api_key, lat=lat, lon = lon)
#get the id of the Flickr Place returned
place_id = place.find('places').findall('place')[0].attrib['place_id']
#returns an XML response that contains data to construct photo URLs
flickr_search = f.photos_search(api_key = api_key, place_id = place_id, content_type = '1', tags = 'nature, landscape, hiking, outdoors,
You can’t perform that action at this time.