Skip to content

Instantly share code, notes, and snippets.

@glw
glw / bash commands
Last active July 18, 2017 20:11
Useful Bash commands
# recusively copy files from sub-directories into the parent
$ find ./recursive_search/ -name '*.txt' -exec cp --backup=numbered -t ./ {} +
==========================================================================================================
#how to create a install script http://askubuntu.com/questions/47404/how-do-i-make-post-install-scripts
===========================================================================================================
#how to find install name
@glw
glw / pgrouting isocrone attempt
Last active January 2, 2016 11:18
What I did.
#upload python script here https://github.com/glw/chicagodivvybikes.git to download divvy bike station data. output it geojson file. I choose geojson so that I could re-use this script for other projects that will require geojson.
#geojson to shpfile
ogr2ogr -f "ESRI Shapefile" divvy_stations.shp divvybikestations.geojson
#shpfile to sql
shp2pgsql -s 4326 -I divvy_stations.shp divvy_stations > divvy_stations.sql
#Download Chicago OSM streets: XML format
wget http://osm-extracted-metros.s3.amazonaws.com/chicago.osm.bz2
@glw
glw / soution_failed_guestaddition
Last active February 27, 2018 19:31
common solution to vituralbox guest addition failed install
#from ubuntu installation
sudo apt-get install dkms build-essential linux-headers-generic gcc make
#for ubuntu 14.04 it may be necessary to install the following...when prompted choose yes for new install.
sudo apt-get install virtualbox-guest-dkms virtualbox-guest-utils virtualbox-guest-x11
@glw
glw / load_shp_to_AWS
Last active June 21, 2024 18:52
load shapefile into Amazon RDS PostGIS
shp2pgsql -s 4326 -d -g the_geom shapefilename.shp shapefilename |psql -U username --password -p 5432 -h reallylonghostnametoamazonaws.com dbname
@glw
glw / RMySQL_Install
Last active August 29, 2015 14:02
RMySQL Install
#Ubuntu 12.04
#R 3.1.0
terminal:
sudo apt-get install libdbd-mysql libmysqlclient-dev
wget http://cran.r-project.org/src/contrib/RMySQL_0.9-3.tar.gz
sudo R CMD INSTALL --configure-args='--with-mysql-inc=/usr/include/mysql' --configure-args='--with-mysql-lib=/usr/lib64/mysql' /home/user/Downloads/RMySQL_0.9-3.tar.gz
@glw
glw / gdal_mosaic
Last active August 29, 2015 14:02
Simple GDAL mosaic of all tifs in folder
#Compress tif with gdal
gdal_translate -of GTiff -co COMPRESS=DEFLATE -co TILED=NO image1.tif image1_compressed.tif
#copy all tifs to new location
for %I in (image1.tif image2.tif image3.tif image4.tif) do copy %I test\folder\
#mosaic with gdal
gdalwarp --config GDAL_CACHEMAX 3000 -wm 3000 *.tif final_mosaic.tif
@glw
glw / batch_arcpy_fieldcalculation
Last active August 29, 2015 14:02
Arcpy batch field calculation
import arcpy
mxd = arcpy.mapping.MapDocument("Current") # finds metadata on your current MXD
layerlist = arcpy.mapping.ListLayers(mxd) # grabs a list of layers with in your MXD
del layerlist[3] #If you need to delete an item in the layerlist list
expr = "'Northwest'" # Variables to run the calculatefield function. **notice the extra '' within ""...
field = "Zone" #
# Goes through list and assigns expr to the field you specified
@glw
glw / pykml_install
Created July 3, 2014 21:09
installing pykml on Ubuntu 12.04
sudo apt-get install libxml2-dev libxslt1-dev python-dev
sudo pip install lxml
sudo pip install pykml
sudo apt-get update
@glw
glw / ubuntu14-gis-install
Last active July 18, 2016 00:49
postgis, pgrouting, qgis install on ubuntu 14
#The following will install Postgres, pgAdmin3, PostGIS, PGRouting, QGIS, and numix (for cooler icons)
#The ubuntugis launchpad repo provides all but pgrouting, pgAdmin and of course the numix icons, it provides similar versions of software - https://launchpad.net/~ubuntugis/+archive/ubuntu/ubuntugis-unstable
#Currently on Ubuntu 14.x the universal package sources offer Posgresql 9.3, and Postgis 2.1.2 so there is no need to add repositories for these alone, unless looking for the most up-to-date version. In which case going straight to the source will be your best bet.
#! /bin/bash (include if you want to turn this into a script)
#install postgis postgresql pgadmin3 from PGDG Repo **See alternative installation below if interested in a more up-to-date QGIS.
#source: http://trac.osgeo.org/postgis/wiki/UsersWikiPostGIS21UbuntuPGSQL93Apt
@glw
glw / arcsde-to-shp
Created December 24, 2014 18:05
Batch export from ArcSDE to shapefile
# Name: arcsde-to-shp.py
# Description: Copies data from ArcSDE, converts it to shp file format and puts into destination folder
# Author: Garret Wais
import arcpy, os
from arcpy import env
arcpy.env.overwriteOutput=True
#set OS working directory
os.chdir("T:\\")