Skip to content

Instantly share code, notes, and snippets.

View alexanno's full-sized avatar

Alexander Salveson Nossum alexanno

View GitHub Profile
s = document.createElement("script");
s.src = "https://code.jquery.com/jquery-2.1.4.min.js";
s.type = "application/javascript";
document.head.appendChild(s);
$("tr a").each(function(key,elem){
elem.target="_blank";
elem.click();
})
@alexanno
alexanno / .sh
Created June 29, 2015 20:32
Import N50 postgis dump
#pgadmin works pretty well
#schema only
pg_restore --host localhost --port 5432 --username "alexanno" --dbname "test" --role "alexanno" --no-password --no-owner --no-privileges --no-tablespaces --schema-only --schema n50 --verbose "/Users/alexanno/Downloads/Kartdata_Norge_UTM33_N50_PostGIS/n50_custom.backup
#data only
pg_restore --host localhost --port 5432 --username "alexanno" --dbname "alexanno" --role "alexanno" --no-password --data-only --schema n50 --verbose "/Users/alexanno/Downloads/Kartdata_Norge_UTM33_N50_PostGIS/n50_custom.backup
@alexanno
alexanno / island_contours_postgis_n50.sql
Last active August 29, 2015 14:23
island contours in postgis + n50
select ogc_fid, geometri from n50.n50_begrensningskurve a
where st_touches(a.geometri, (select geometri from n50.n50_begrensningskurve where ogc_fid=2680783))
------------ http://boundlessgeo.com/2010/07/network-walking-in-postgis/
WITH RECURSIVE walk_network(ogc_fid, geom) AS (
SELECT ogc_fid, geom FROM sandbox.justoya WHERE ogc_fid=2625722
UNION ALL
SELECT n.ogc_fid, n.geom
FROM sandbox.justoya n, walk_network w
WHERE ST_DWithin(ST_EndPoint(w.geom),ST_StartPoint(n.geom),0.1)
)
@alexanno
alexanno / greatcircle_postgis
Created June 27, 2015 22:41
Create great circles in postgis / cartodb.
http://gis.stackexchange.com/questions/84443/what-is-this-postgis-query-doing-to-show-great-circle-connections/84444#84444
The examples given, and the previous answer all depend on taking the line into a planar projection and then segmentizing. As of PostGIS 2.1 (which I think CartoDB is on) you can do a general-purpose job of it using ST_Segmentize(geography), so like this:
SELECT
ST_Segmentize(
ST_MakeLine(
ST_SetSRID(ST_MakePoint(-71.060316, 48.432044),4326),
pt
)::geography
@alexanno
alexanno / gist:789fedb9e4378d4dd0c6
Created June 3, 2015 12:20
git https:// instead of git://
git config --global url."https://".insteadOf git://
@alexanno
alexanno / unzip+load.sos.sh
Last active August 29, 2015 14:21
Unzip and load multiple SOSI files to one Postgis-table with ogr2ogr
#unzip all zip files
unzip '*.zip'
find ./ -name \*Stedsnavn*.sos -execdir ogr2ogr --config PG_USE_COPY YES --config PG_USE_BASE64 YES -update -append -f PostgreSQL PG:'host=localhost port=5432 dbname=alexanno user=alexanno active_schema=sandbox' -progress -nlt PROMOTE_TO_MULTI -nln stedsnavn_norge {} \;
@alexanno
alexanno / color_ubuntu.sh
Created May 8, 2015 09:46
Color in Ubuntu shell
LS_COLORS=$LS_COLORS:'di=1;32:' ; export LS_COLORS
#http://askubuntu.com/questions/466198/how-do-i-change-the-color-for-directories-with-ls-in-the-console
Blue = 34
Green = 32
Light Green = 1;32
Cyan = 36
Red = 31
Purple = 35
#ubuntu 14.04 64x
#https://github.com/developmentseed/landsat-util
#https://github.com/landsat-pds/landsat_ingestor/wiki/Accessing-Landsat-on-AWS
#https://developmentseed.org/blog/2015/03/19/aws-landsat-archive/
#https://developmentseed.org/blog/2015/03/28/twice-as-fast/
#http://landsat.usgs.gov/landsat8.php
sudo apt-get update
sudo apt-get install python-pip python-numpy python-scipy libgdal-dev libatlas-base-dev gfortran
sudo pip install landsat-util
@alexanno
alexanno / printing_python_qgis.py
Created March 8, 2015 07:32
Printing with Python and QGIS
#http://kartoza.com/how-to-create-a-qgis-pdf-report-with-a-few-lines-of-python/
# coding=utf-8
# A simple demonstration of to generate a PDF using a QGIS project
# and a QGIS layout template.
#
# This code is public domain, use if for any purpose you see fit.
# Tim Sutton 2015