Skip to content

Instantly share code, notes, and snippets.

@oeon
oeon / bulk-shp2pgsql
Created February 17, 2011 00:22
batch upload folder of shapefiles which are all in same .prj to PostGIS database
#!/bin/bash
FILES=$(ls *.shp | sed 's/\..\{3\}$//');
for FILE in $FILES
do
shp2pgsql -s 4326 -I -k ${FILE} gis.${FILE} | psql -d HSIP
done
@oeon
oeon / gist:982234
Created May 20, 2011 02:22
translate 1+GB MrSID image
gdalwarp -of VRT -multi -t_srs EPSG:3785 in.sid out.vrt #in.sid=EPSG:2229, out.vrt=EPSG:3785
gdal_translate -co tiled=yes -co compress=jpeg -co photometric=ycbcr -co JPEG_QUALITY=50 3785.vrt 3785.tif
gdalbuildvrt slo3785.vrt *.tif
gdal_translate -co tiled=yes -co compress=jpeg -co photometric=ycbcr -co JPEG_QUALITY=50 slo3785.vrt slo3785.tif
@oeon
oeon / gist:1254501
Created September 30, 2011 17:56
imposm error
bin/imposm --overwrite-cache --read --write -d osm ~/osm_data/slo.california.osm
Enabling Shapely speedups.
[10:53:11] ## reading /Users/sloale/osm_data/slo.california.osm
[10:53:11] coords: 1427k nodes: 28k ways: 203k relations: 1k (estimated)
[10:53:25] coords: 1437k nodes: 0k ways: 66k relations: 0k
[10:53:25] reading took 14s
[10:53:25] ## dropping/creating tables
[10:53:25] ## writing data
Traceback (most recent call last):
File "bin/imposm", line 8, in <module>
@oeon
oeon / gist:1263089
Created October 4, 2011 22:52 — forked from frewsxcv/gist:1262862
San Luis Obispo translation file (ogr2osm)
def translateAttributes(attrs):
if not attrs:
return
tags = {}
if int(attrs['SPD_PST']) > 0:
tags.update({'maxspeed':attrs['SPD_PST'] + ' mph'})
if attrs['FULLNAME']:
tags.update({'name:fullname':attrs['FULLNAME'],'source:maxspeed':'sign' })
@oeon
oeon / oam.sh
Last active September 29, 2015 11:57
OAM batch script
#!/bin/sh
for f in $(ls /media/LAR_HD/6Inch/*.tif)
do
export GDAL_TIFF_INTERNAL_MASK=YES
nearblack -co TILED=YES -setmask -nb 0 -of GTiff -o ./prewarp.tif $f
gdalwarp -co TILED=YES -dstalpha -s_srs EPSG: 2229 -t_srs EPSG:4326 prewarp.tif warped.tif
rm prewarp.tif
gdal_translate -co TILED=YES -co JPEG_QUALITY=80 -co COMPRESS=JPEG -co PHOTOMETRIC=YCBCR -b 1 -b 2 -b 3 -mask 4 warped.tif final.tif
rm warped.tif
@oeon
oeon / gist:1648880
Created January 20, 2012 18:33
send email when new user registers [GeoNode], add to last line of `/var/lib/geonode/lib/python2.6/site-packages/registration/models.py`
#don't forget to add!
#from django.core.mail import send_mail
send_mail("New user: " + self.user.email + " has registered on GeoNode", "New user: " + self.user.email + " has registered on GeoNode as " + self.user.username, settings.DEFAULT_FROM_EMAIL, ['your_email@example.com', 'other_admin@example.com'])
@oeon
oeon / gist:1833724
Created February 15, 2012 06:10
GISUG picture reference
#4 http://www.flickr.com/photos/zamburak/5655223905/lightbox/
#5 http://www.flickr.com/photos/dizfunk/3066153143/
#6 'no linux' google image search
#7 http://www.flickr.com/photos/thermo-police/6258762505/
#8 http://www.flickr.com/photos/esparta/187132368/
#9 screenie, invert
#13 my basement
#33 http://www.flickr.com/photos/xxsnuffxx/139070284/sizes/l/in/photostream/
#36 http://tiles.mapbox.com/geoslo/map/gisug
#78 my dog Bruce
@oeon
oeon / gist:2339950
Created April 8, 2012 21:41
bash, sed - change extension from markdown to md
for file in *; do mv $file $(echo $file | sed 's/markdown/md/g'); done
@oeon
oeon / slo_bldgs_oct2012
Last active October 5, 2015 18:27
buildings in SLO County, Overpass query, cURL Windows
curl -o slo_bldgs_oct2012.osm -g http://www.overpass-api.de/api/xapi?*[building=*][bbox=-121.34792,34.89752,-119.47262,35.79522][@meta]
@oeon
oeon / gist:2855793
Created June 1, 2012 23:41
georeference png from .geo coords
gdal_translate -of png -a_ullr -122.3113 36.71011 -119.0009 34.01044 -a_srs EPSG:4326 "ADELAIDA CELL SITE.png" adgeo.png