Skip to content

Instantly share code, notes, and snippets.


William Dollins geobabbler

View GitHub Profile
geobabbler /
Last active Feb 12, 2016
Simple extension to PostGIS dialect for Hibernate
package com.geomusings.dialect;
//import org.hibernate.dialect.PostgreSQLDialect;
import org.hibernate.dialect.function.StandardSQLFunction;
import org.hibernate.type.CustomType;
import org.hibernate.type.StandardBasicTypes;
import org.hibernate.type.Type;
import org.hibernate.spatial.dialect.postgis.PostgisDialect;
import org.hibernate.usertype.UserType;
import org.hibernate.spatial.SpatialAggregate;
geobabbler / d3_squares_example.js
Last active May 25, 2016
D3 squares example for blog post
View d3_squares_example.js
function (json) {
var w = 980;
var h = 480;
//get the center of the data
var center = d3.geo.centroid(json);
var svg ="body").append("svg")
.attr("width", w)
geobabbler / ogr_example.bat
Created May 8, 2015
OGR export example for blog post
View ogr_example.bat
ogr2ogr -f "GeoJSON" statistics_%2_%1.geojson PG:"host=localhost user=wombat dbname=geo2 password=sufficiently_complex_password" -sql "SELECT * FROM vw_geojson_statistics_ytd WHERE year = 2015"
geobabbler / simple_join.sql
Created May 8, 2015
Simple join example for blog post
View simple_join.sql
INNER JOIN public.vw_statistics_ytd ON
us_states_squares.abbr = vw_statistics_ytd.state_abbr
geobabbler / metadata_writer.js
Created Mar 25, 2015
Generates metadata document containing elements required by
View metadata_writer.js
var fs = require('fs');
function writeMetadata(Origin, Pubdate, Title, Abstract, Westbc, Eastbc, Northbc, Southbc, Addrtype, State){
var XMLWriter = require('xml-writer');
xw = new XMLWriter(true);
var root = xw.startElement('metadata');
root.writeAttribute('xmlns:xsi', '');
var idinfo = root.startElement('idinfo');
geobabbler / node_geoserver_addfeature.js
Last active Aug 29, 2015
Posting a new PostGIS feature type to GeoServer using the REST config API
View node_geoserver_addfeature.js
//callback should be like function(err){//do stuff}
function registervector(datasetName, callback){
//dataset name is the name of the PostGIS table
process.env.NODE_TLS_REJECT_UNAUTHORIZED = "0"; //my dev SSL is self-signed. don't do this in production.
var https = require('https'); //using SSL because of basic auth in this example
var auth = 'Basic ' + new Buffer('username' + ':' + 'p@s$w0rd').toString('base64'); //strong passwords please
//build the object to post
var post_data = {'featureType': {'name': datasetName}};
//be sure to turn it into a string
var s = JSON.stringify(post_data);
View anno_snippet3.cs
void win_Closed(object sender, EventArgs e)
TextSymbolPropsWindow win = sender as TextSymbolPropsWindow;
if ((bool)win.DialogResult)
GraphicsLayer graphicsLayer = BoundMap.Layers["AnnoLayer"] as GraphicsLayer; //the layer on which the anno will be drawn
string input = win.Annotation;
if (!String.IsNullOrEmpty(input))
geobabbler / anno_snippet2.cs
Created Jan 16, 2015
Second code snippet for annotation post
View anno_snippet2.cs
private void DrawCompleteHandler(object sender, DrawEventArgs args)
_currentPoint = args.Geometry as MapPoint; //capture the point that where the mouse was clicked
TextSymbolPropsWindow win = new TextSymbolPropsWindow(); //My child window. This can be any you define.
win.EditMode = false; //this tells the window that this is a new annotation
win.Closed += new EventHandler(win_Closed); //subscribe to the window's Closed event
geobabbler / anno_snippet1.cs
Created Jan 16, 2015
First code snippet for annotation post
View anno_snippet1.cs
if (_draw == null)
_draw = new Draw(BoundMap); //private class-level variable of type ESRI.ArcGIS.Client.Draw
_draw.DrawComplete += DrawCompleteHandler; //subscribe to the DrawComplete event
_activated = true;
_draw.IsEnabled = true; //enable the Draw object
_draw.DrawMode = DrawMode.Point; //set it to Point mode
geobabbler /
Created Nov 26, 2014
Import JSON from StackExchange tags API to CSV
import requests
from pprint import pprint
r = requests.get('')
data = r.json()
print "tag,count"
for tag in data["items"]:
print tag["name"] + "," + str(tag["count"])
You can’t perform that action at this time.