Skip to content

Instantly share code, notes, and snippets.

💭
Working

William Dollins geobabbler

💭
Working
Block or report user

Report or block geobabbler

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
View ImageType.cs
if (ImageFormat.Jpeg.Equals(image.RawFormat))
{
// JPEG
}
else if (ImageFormat.Png.Equals(image.RawFormat))
{
// PNG
}
else if (ImageFormat.Gif.Equals(image.RawFormat))
{
@geobabbler
geobabbler / globamaptiles.py
Created Apr 21, 2014
Update of globalmaptiles.py from http://www.maptiler.org to include functions to generate ArcGIS tile addresses (using hex notation) and to generate world file (affine transformation) parameters for a given TMS tile.
View globamaptiles.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/
@geobabbler
geobabbler / worlddfile.py
Last active Aug 29, 2015
Function to generate world file parameters for any TMS tile. Useful for building virtual rasters. Add to globalmaptiles.py
View worlddfile.py
def WorldFileParameters(self, tx, ty, zoom):
"Returns world file (affine transofrmation) parameters of the given tile."
bounds = self.TileBounds( tx, ty, zoom)
moriginx = bounds[3] + (self.Resolution(zoom) / 2)
moriginy = bounds[0] - (self.Resolution(zoom) / 2)
return (self.Resolution(zoom), 0.0, 0.0, self.Resolution(zoom) * -1, moriginy, moriginx)
View server.js
var express = require('express'),
geo = require('./routes/geo');
var app = express();
app.get('/countries/:id/bbox', geo.bbox);
app.get('/countries/:id/bbox/:srid', geo.bboxSrid);
app.get('/countries/:id/polygon', geo.polygon);
app.get('/countries/:id/polygon/:srid', geo.polygonSrid);
View geo.js
var pg = require('pg');
var conString = "postgres://username:password@hostname.rds.amazonaws.com:5432/database"; //TODO: point to RDS instance
exports.bbox = function(req, res) {
var client = new pg.Client(conString);
client.connect();
var crsobj = {"type": "name","properties": {"name": "urn:ogc:def:crs:EPSG:6.3:4326"}};
var idformat = "'" + req.params.id + "'";
idformat = idformat.toUpperCase();
var query = client.query("select st_asgeojson(st_envelope(shape)) as geojson from ne_countries where iso_a3 = " + idformat + ";");
View irl_bbox.json
{
"type": "feature",
"crs": {
"type": "name",
"properties": {
"name": "urn:ogc:def:crs:EPSG:6.3:4326"
}
},
"geometry": {
"type": "Polygon",
@geobabbler
geobabbler / snippet6.bat
Created Nov 23, 2014
Code snippet 6 for blog post
View snippet6.bat
curl -X POST -d "{ \"type\": \"Point\", \"coordinates\": [-98.35, 39.7] }" -H "Content-Type: application/json" http://localhost:3000/vector/public/states_gen/features/intersect
View snippet7.js
/**
* retrieve all features that intersect the input GeoJSON geometry
*/
app.post('/vector/:schema/:table/:geom/intersect', function (req, res, next) {
//console.log(JSON.stringify(req.body));
var queryshape = JSON.stringify(req.body);
//continue with the rest of app.post
View snippet1.bat
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
You can’t perform that action at this time.