Skip to content

Instantly share code, notes, and snippets.

View geobabbler's full-sized avatar
💭
Working

William Dollins geobabbler

💭
Working
View GitHub Profile
app.get('/leonardtown/buildings/:geom', function (req, res, next) {
var client = new pg.Client(app.conString);
var geom = req.params.geom.toLowerCase();
if ((geom != "features") && (geom != "geometry")) {
res.status(404).send("Resource '" + geom + "' not found");
return;
}
var tablename = "leonardtown_bldgs";
var schemaname = "public";
var fullname = schemaname + "." + tablename;
python tile_grab.py -b -158;21;-157;22 -d E:\tiles\oahu_img\a -i false -z 6 -u http://www.someserver.net/arcgis/rest/services/ImagerySvc/MapServer/tile/{z}/{y}/{x}.png
gdalbuildvrt 6.vrt 6/*.png
@geobabbler
geobabbler / stack2csv.py
Created November 26, 2014 21:20
Import JSON from StackExchange tags API to CSV
import requests
from pprint import pprint
r = requests.get('https://api.stackexchange.com/2.2/tags?page=1&pagesize=100&order=desc&sort=popular&site=gis')
data = r.json()
print "tag,count"
for tag in data["items"]:
print tag["name"] + "," + str(tag["count"])
@geobabbler
geobabbler / anno_snippet1.cs
Created January 16, 2015 20:47
First code snippet for annotation post
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
geobabbler / anno_snippet2.cs
Created January 16, 2015 20:49
Second code snippet for annotation post
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
win.Show();
}
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
geobabbler / node_geoserver_addfeature.js
Last active August 29, 2015 14:16
Posting a new PostGIS feature type to GeoServer using the REST config API
//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);
@geobabbler
geobabbler / metadata_writer.js
Created March 25, 2015 13:33
Generates metadata document containing elements required by data.gov
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);
xw.startDocument();
var root = xw.startElement('metadata');
root.writeAttribute('xmlns:xsi', 'http://www.w3.org/2001/XMLSchema-instance');
root.writeAttribute('xsi:noNamespaceSchemaLocation','http://www.fgdc.gov/metadata/fgdc-std-001-1998.xsd');
var idinfo = root.startElement('idinfo');
@geobabbler
geobabbler / simple_join.sql
Created May 8, 2015 14:05
Simple join example for blog post
SELECT
us_states_squares.shape,
us_states_squares.abbr,
us_states_squares.name,
vw_statistics_ytd.ytd
FROM
public.us_states_squares
INNER JOIN public.vw_statistics_ytd ON
us_states_squares.abbr = vw_statistics_ytd.state_abbr
WHERE