Skip to content

Instantly share code, notes, and snippets.

View creg-ny-baa's full-sized avatar

Tom Arnold creg-ny-baa

View GitHub Profile
@creg-ny-baa
creg-ny-baa / create_hex_tile_view.sql
Created September 8, 2015 13:43
Creates a PostGIS view of hexagonal tiles.
/*=============================================================================
Create a PostGIS view of hexagon tiles using the given user_variables.
***CAUTION! Uses floating point math, so polygons are not topological.***
2015; Tom Arnold; Walker Associates, Inc.
Free and unencumbered without warranty... like http://unlicense.org/UNLICENSE
The fun way to do this is to create a table with the user_variables and
select into the view from there. Then you can change your grid dynamically.
=============================================================================*/
@creg-ny-baa
creg-ny-baa / remove-firm-collars.sql
Last active August 26, 2015 17:36
A semi-automated sql script to remove map collars from FEMA FIRM Panel rasters.
/*
Removes map collars from FEMA FIRM Panel rasters.
=================================================
Output the query results to a batch file and run inside the directory
with the FIRM tiffs. Assumes that the table with panel footprints has
been projected to the same coordinate system as the rasters.
The MIT License (MIT)
2015-08-26 Tom Arnold - Walker Associates, Inc.
*/
<link rel="import" href="../core-scaffold/core-scaffold.html">
<link rel="import" href="../core-header-panel/core-header-panel.html">
<link rel="import" href="../core-menu/core-menu.html">
<link rel="import" href="../core-item/core-item.html">
<link rel="import" href="../core-icon-button/core-icon-button.html">
<link rel="import" href="../core-toolbar/core-toolbar.html">
<link rel="import" href="../core-menu/core-submenu.html">
<polymer-element name="my-element">
@creg-ny-baa
creg-ny-baa / mbtiles.py
Created November 15, 2013 15:04
Serve TMS tiles from an SQLite3, MBTiles spec database. Also provide a timestamp suitable for HTTP headers based on file timestamp.
import sqlite3
import os.path
from email import utils
class MBTilesTMS:
def __init__(self, filename):
if os.path.isfile(filename):
self.filename = filename
self.dbconn = sqlite3.connect(filename)
else:
@creg-ny-baa
creg-ny-baa / gist:7485522
Created November 15, 2013 14:52
A basic CherryPy setup running on WebFaction to serve map tiles.
import cherrypy
from mbtiles import MBTilesTMS
class Root(object):
@cherrypy.expose
def testmap(self):
return open('/home/webapps/mopcherry/htdocs/testmap.html')
@cherrypy.expose
def tiles(self, dataset, z, x, y):
filename = '/home/webapps/mopcherry/mbtiles/{}.mbtiles'.format(dataset)
@creg-ny-baa
creg-ny-baa / cartodb2qgis.py
Last active December 22, 2015 11:49
View CartoDB data (from a public table) in QGIS 1.8. Substitute your user name and SQL, and paste it in the python console.
# Run in QGIS python console for read-only view of CartoDB table
# Substitute your user name and query on first two lines
cartoName = "" # PUT YOUR USER NAME IN THE QUOTES
cartoQuery = "" # PUT YOUR QUERY IN THE QUOTES
import urllib
cartoUrl = 'http://{}.cartodb.com/api/v2/sql?format=GeoJSON&q={}'.format(cartoName, cartoQuery)
response = urllib.urlopen(cartoUrl)
content = response.read()
@creg-ny-baa
creg-ny-baa / osm_monochrome.qml
Last active December 21, 2015 07:48
QGIS 1.8 style descriptor for a high contrast display of OSM highway lines. To be used on data imported with SpatiaLite OSM tools.
<!DOCTYPE qgis PUBLIC 'http://mrcc.com/qgis.dtd' 'SYSTEM'>
<qgis version="1.8.0-Lisboa" minimumScale="0" maximumScale="1e+08" hasScaleBasedVisibilityFlag="0">
<transparencyLevelInt>255</transparencyLevelInt>
<renderer-v2 symbollevels="0" type="RuleRenderer">
<rules>
<rule filter=" &quot;sub_type&quot; = 'motorway' " symbol="0" label="Motorway"/>
<rule filter=" &quot;sub_type&quot; = 'primary'" symbol="1" label="Primary"/>
<rule filter=" &quot;sub_type&quot; = 'secondary'" symbol="2" label="Secondary"/>
<rule filter="&quot;sub_type&quot; = 'tertiary'" symbol="3" label="Tertiary"/>
<rule filter="&quot;sub_type&quot; = 'trunk'" symbol="4" label="Trunk"/>