Skip to content

Instantly share code, notes, and snippets.

View tucotuco's full-sized avatar

John Wieczorek tucotuco

View GitHub Profile
@tucotuco
tucotuco / gist:4645547
Created January 27, 2013 00:41
Code to create PLSS geocodes
def plss_creator():
i = 0
f = open('/Users/tuco/plss_geocodes.csv', 'w')
for line in open('/Users/tuco/plss_for_geomancer.csv').read().split('\n'):
values = line.split(',')
if values[0] != 'feature_id' and len(values)>1:
# feature_id,name,lat,lon,uncertainty,w,s,e,n
geocode = {
"results" : [
{
@tucotuco
tucotuco / utf8er.awk
Created July 23, 2012 22:30
UTF8 BOM prepender
#!/usr/bin/awk -f
# Prepends a three-byte (three bytes \xEF\xBB\xBF)
# Byte Order Marker (BOM) to a file to explicitly
# show UTF8 encoding.
# Assumptions:
# Original file is actually UTF8-encoded.
# Example:
# gawk -f utf8er.awk source.csv dest_with_bom.csv
BEGIN {
@tucotuco
tucotuco / mixstermshistory.rdf
Created February 29, 2012 11:38
MIxS version 2012-02-19 RDF including DwC terms
<?xml version="1.0" encoding="UTF-8"?>
<?xml-stylesheet type="text/xsl" href="human.xsl"?>
<!DOCTYPE rdf:RDF [
<!ENTITY rdfns 'http://www.w3.org/1999/02/22-rdf-syntax-ns#'>
<!ENTITY rdfsns 'http://www.w3.org/2000/01/rdf-schema#'>
<!ENTITY dctermsns 'http://purl.org/dc/terms/'>
<!ENTITY dctypens 'http://purl.org/dc/dcmitype/'>
<!ENTITY dwcattributesns 'http://rs.tdwg.org/dwc/terms/attributes/'>
<!--
<!ENTITY skosns 'http://www.w3.org/2004/02/skos/core#'>
@tucotuco
tucotuco / mixstermhistory.rdf
Created February 27, 2012 10:59
MiXS version 2011-01-26 RDF
<?xml version="1.0" encoding="UTF-8"?>
<?xml-stylesheet type="text/xsl" href="human.xsl"?>
<!DOCTYPE rdf:RDF [
<!ENTITY rdfns 'http://www.w3.org/1999/02/22-rdf-syntax-ns#'>
<!ENTITY rdfsns 'http://www.w3.org/2000/01/rdf-schema#'>
<!ENTITY dctermsns 'http://purl.org/dc/terms/'>
<!ENTITY dctypens 'http://purl.org/dc/dcmitype/'>
<!ENTITY dwcattributesns 'http://rs.tdwg.org/dwc/terms/attributes/'>
<!--
<!ENTITY skosns 'http://www.w3.org/2004/02/skos/core#'>
cellkey,doc
1871-3602,'{"_id": "1871-3602", "b": [["-148.9403826", "59.9833333"], ["-148.923782", "59.975"]], "t": "11", "v": {"p9": 205, "p7": 63, "m6": 68, "t12": -26, "m11": -27, "b5": 166, "b6": -58, "m12": -51, "b1": 42, "b2": 63, "b3": 28, "b8": 44, "b9": 101, "b16": 604, "b17": 211, "b12": 1571, "m7": 94, "m5": 32, "m4": -4, "b14": 58, "b15": 40, "t10": 42, "b13": 235, "b10": 120, "b11": -28, "m1": -58, "t2": -24, "m9": 62, "m8": 92, "b18": 235, "t11": -2, "p2": 124, "p5": 90, "m3": -35, "p3": 97, "m2": -52, "p10": 235, "p11": 164, "x8": 161, "x9": 127, "x2": 4, "x3": 28, "x1": -6, "x6": 142, "x7": 166, "x4": 66, "x5": 105, "a": 12, "b4": 5829, "p1": 153, "p6": 58, "t8": 126, "p4": 98, "t9": 94, "t6": 105, "t7": 130, "p8": 114, "t5": 68, "m10": 14, "t3": -4, "t1": -32, "b7": 224, "p12": 170, "x10": 70, "x11": 24, "x12": 0, "b19": 447, "t4": 31}}'
1871-3603,'{"_id": "1871-3603", "b": [["-148.9481455", "59.975"], ["-148.9315491", "59.9666667"]], "t": "11", "v": {"p9": 206, "p7": 63, "m6": 68, "t12": -25,
cellkey,doc
1871-3602,'{"_id": "1871-3602", "b": [["-148.9403826", "59.9833333"], ["-148.923782", "59.975"]], "t": "11", "v": {"t5": 68, "t1": -32, "m11": -27, "b5": 166, "b6": -58, "m12": -51, "b1": 42, "b2": 63, "b3": 28, "b4": 5829, "t9": 94, "b8": 44, "b9": 101, "m5": 32, "p4": 98, "m4": -4, "b14": 58, "b16": 604, "b17": 211, "m7": 94, "m6": 68, "b12": 1571, "b13": 235, "t12": -26, "b11": -28, "t10": 42, "m9": 62, "b15": 40, "b18": 235, "t11": -2, "a": 12, "b10": 120, "m2": -52, "p1": 153, "p10": 235, "p11": 164, "x8": 161, "x9": 127, "m10": 14, "x2": 4, "x3": 28, "x1": -6, "x6": 142, "x7": 166, "x4": 66, "x5": 105, "p2": 124, "p3": 97, "m3": -35, "p6": 58, "p7": 63, "t8": 126, "p5": 90, "t6": 105, "t7": 130, "p8": 114, "p9": 205, "t2": -24, "t3": -4, "m8": 92, "b7": 224, "p12": 170, "x10": 70, "x11": 24, "x12": 0, "b19": 447, "m1": -58, "t4": 31}}'
1871-3603,'{"_id": "1871-3603", "b": [["-148.9481455", "59.975"], ["-148.9315491", "59.9666667"]], "t": "11", "v": {"t5": 68, "t1": -32, "m11": -27, "b5": 166
vlsb-3102-004:sdl tuco$ ./sdl.py -c tilecsvs2appengine -k 11 -w /Users/tuco/Data/SDL/workspace -l none --config_file /Users/tuco/Projects/Spatial-Data-Library/bulkloader/bulkloader.yaml --url http://localhost:8080/_ah/remote_api
Tile11-1
Tile11-1/forcouch/11_1806-3600_2075-3676-jsonfix.csv
Tile11-1/forcouch/11_1806-3600_2075-3676.csv
appcfg.py upload_data --batch_size=1 --num_threads=5 --config_file=/Users/tuco/Projects/Spatial-Data-Library/bulkloader/bulkloader.yaml --filename=/Users/tuco/Data/SDL/workspace/Tile11-1/forcouch/11_1806-3600_2075-3676-jsonfix.csv --kind CellIndex --url=http://localhost:8080/_ah/remote_api
Uploading data records.
[INFO ] Logging to bulkloader-log-20110925.173807
[INFO ] Throttling transfers:
[INFO ] Bandwidth: 250000 bytes/second
[INFO ] HTTP connections: 8/second
@tucotuco
tucotuco / globalmaptiles.py
Created September 4, 2011 21:56
Classes to calculate Tile coordinates
#!/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/
<!DOCTYPE html>
<html>
<head>
<title>Google Maps JavaScript API v3 Example: Map Coordinates</title>
<meta name="viewport"
content="width=device-width, initial-scale=1.0, user-scalable=no">
<meta charset="UTF-8">
<link href="/apis/maps/documentation/javascript/examples/default.css"
rel="stylesheet" type="text/css">
def get_tile_origin(self, tile_x, tile_y, zoom):
'''Return the lat, lng of the northwest corner of the tile.'''
tile_width = 360.0/pow(2,zoom) # degrees
tile_height = tile_width/2 # degrees
n = 90 - tile_y * tile_height
w = -180 + tile_x * tile_width
return (n,w)
def get_bb(self, tile_x, tile_y, zoom):
"""Return bounding coordinates (n, e, s, w) of the tile."""