Skip to content

Instantly share code, notes, and snippets.

View almccon's full-sized avatar
🔣

Alan McConchie almccon

🔣
View GitHub Profile

Overview

In general, it seems there are roughly five (5) ways to get "file data" (e.g. a GeoTIFF) out of a PostGIS geoprocessing workflow:

  • Export just the raster field as an ASCII grid
  • Connect to the database using a desktop client (e.g. QGIS) [1]
  • Use a procedural language (like PLPGSQL or PLPYthon) [2]
  • Use the COPY declaration to get a hex dump out and convert it to a binary file
  • Fill a 2D NumPy array with a byte array and serialize it to a binary file using GDAL or psycopg2 [3, 4]
  • Use ST_AsTiff() or the more general ST_AsGDALRaster() to get a byte array, which can be written to a binary file
@skorasaurus
skorasaurus / Osm_Terms.md
Last active March 20, 2016 19:58
OpenStreetMap cheat sheet for Common terms and lexicon used in OSM. [assuming node, line, and polygon is covered in the presentation itself)

Changeset: A group of changes that you made to OSM data. Once uploaded to OSM, your edits are instantly available to others if they download OSM data. They may take a few minutes or several hours to appear on the map.

Extract: A large chunk of OSM data for a specific area (like a state, country, or geographic area).

Layer: A data source that's displayed on a slippy map (often is thought of as a group of tiles stitched together). (It also has another meaning in OSM, but don't worry about it right now).

Render: to convert from the OSM data into an image. Rendered data is a map.

Stylesheet: it means a text file of rules that define what features (like roads, buildings) are displayed, and how (what color should the road be ? How wide should be? What icon should be used for a restaurant?) on a map.

@tmcw
tmcw / archive_tweets.py
Created July 31, 2012 21:31
Archive Tweets
import requests, os, glob, json
you = 'tmcw'
data = 'tweets'
try: os.mkdir(data)
except Exception: pass
def run(max_id = False):
already = glob.glob("%s/*.json" % data)
@gka
gka / cartogram.py
Created December 5, 2011 12:09
Generator for Dorling cartograms
"""
Generator for packed circle cartograms
"""
import proj, gisutils
class Cartogram:
def loadCSV(self, url, key='id', value='val', lon='lon', lat='lat'):
import csv
doc = csv.reader(open(url))
@juniorz
juniorz / install_postgis_osx.sh
Created July 14, 2011 03:49
Installing PostGIS on Mac OS X and Ubuntu
# Some good references are:
# http://russbrooks.com/2010/11/25/install-postgresql-9-on-os-x
# http://www.paolocorti.net/2008/01/30/installing-postgis-on-ubuntu/
# http://postgis.refractions.net/documentation/manual-1.5/ch02.html#id2630392
#1. Install PostgreSQL postgis and postgres
brew install postgis
initdb /usr/local/var/postgres
pg_ctl -D /usr/local/var/postgres -l /usr/local/var/postgres/server.log start