Skip to content

Instantly share code, notes, and snippets.

View johnniehard's full-sized avatar
🚀
Making it happen!

Johnnie Hård johnniehard

🚀
Making it happen!
View GitHub Profile
@johnniehard
johnniehard / orientation.md
Last active July 28, 2018 20:48
Getting the orientation of the longest straight line distance across a polygon.

Some quick and dirty PostGIS:

Get the longest line for your polygons

create table test.tatortlongestline as
select st_longestline(t.geom, t.geom) as geom, t.tatort
from indata.tatort as t
where lanskod = '01';

{
"location": { "lat": 0, "lng": 0 },
"data": [
{ "date": "2018-08-31", "cloudy_pct": 23, "B1": 3645, "B2 (etc...)": 4324, "NDVI": 0.4 },
{ "date": "2018-08-25", "cloudy_pct": 21, "B1": 3445, "B2 (etc...)": 4384, "NDVI": 0.3 },
"etc..."
]
}

Keybase proof

I hereby claim:

  • I am iamlukesky on github.
  • I am iamlukesky (https://keybase.io/iamlukesky) on keybase.
  • I have a public key ASDzxKz0aNaCqsYzm34G3T7cShlOI8nRaDGTvaLyK_3p9Qo

To claim this, I am signing this object:

@johnniehard
johnniehard / Depth DEM
Last active November 27, 2017 14:19
Caclulating depth DEM in QGIS raster calculator.
(( "DEM" - zerolevel) * -1 ) * ((( "DEM" - zerolevel) * -1) > 0)
@johnniehard
johnniehard / shpfolder2geojson.sh
Created September 1, 2017 05:14
Converts all shapefiles in input directory to EPSG:4326 GeoJSON files inside of target directory
#!/bin/bash
# Johnnie Hård
# https://synvinkel.org
geojson=".geojson"
# These are set by calling the script with arguments e.g:
# ./shpfolder2geojson.sh MyShapefileDirectory MyGeojsonDirectory
inputdirectory=$1
<h1>Hello World!</h1>
lkjdfkjfd
@johnniehard
johnniehard / README.md
Last active August 13, 2017 20:14
Skapa, hosta och ta in mbtiles

Stegen jag tog, hade inget vidare syfta än att få upp ett fungerande exempel.

  1. Ladda ner vägkartan stockholm från lantmäteriets öppna data ftp (vem fan har en ftp 2017?)

  2. Konvertera samtliga *.shp till *.geojson. Använd convertall.sh. Kom ihåg att lägga till -s_srs EPSG:3006 -t_srs EPSG:4326 för att reprojicera till wgs84 i samma veva.

  3. Slå ihop alla *.geojson som ska vara med som lager i *.mbtiles filen med cat *.geojson > vagk_01_wgs84.geojson

  4. Använd Tippecanoe för att konvertera vagk_01_wgs84.geojson till mbtiles.

@johnniehard
johnniehard / sketch.js
Created May 25, 2017 08:21
Converts a p5js graphics object to an Image object. This way you can use an off screen buffer to create image masks.
function graphicsToImage(graphics){
var img = createImage(graphics.width, graphics.height);
img.loadPixels();
graphics.loadPixels();
for(var x = 0; x < img.width; x++){
for(var y = 0; y < img.height; y++){
idx = 4 * (y * img.width + x);
img.pixels[idx] = graphics.pixels[idx];
img.pixels[idx+1] = graphics.pixels[idx+1];
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8" name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no" />
<title>tourMap</title>
<link rel="stylesheet" href="https://unpkg.com/leaflet@1.0.3/dist/leaflet.css" />
<script src="https://unpkg.com/leaflet@1.0.3/dist/leaflet.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/leaflet-providers/1.1.15/leaflet-providers.min.js"></script>
@johnniehard
johnniehard / gospatial_batchprocess.py
Last active June 8, 2017 15:14
Batch process an input directory with GoSpatial
'''
Author: Johnnie Hård, johnnie.hard@gmail.com
Purpose: Batch process all files in a directory with gospatial
'''
import os, subprocess
# Set input/output directories
# cwd = the directory where the script gets called.
cwd = os.getcwd()