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 / movers over image
Created October 19, 2014 09:55
Moving points that slow down on darker areas of an image.
PImage src;
Mover[] movers = new Mover[10000];
void setup(){
src = loadImage("YOUR_IMAGE.JPG");
src.resize(src.width/4, src.height/4);
size(src.width, src.height);
for(int i = 0; i < movers.length; i++){
movers[i] = new Mover(src, new PVector(random(width), random(height)));
@johnniehard
johnniehard / image shuffler
Created November 6, 2014 13:43
Take parts of an image and shuffle them around
//ta delar ur en bild och shuffla runt dem
int col = 4; //even numbers
int row = 2;
int w;
int h;
PImage img;
PImage[] delar = new PImage[col*row];
@johnniehard
johnniehard / datestamp.pde
Created October 19, 2015 10:56
For date stamping saved frames
void startRecording()
{
String folder = year() +""+ month() +""+ day() +""+ hour() +""+ minute();
record = true;
}
void record()
{
if(record) saveFrame(folder +"/"+ year() +""+ month() +""+ day() +""+ hour() +""+ minute() +""+ second() +""+ millis() +".png");
}
# -*- coding: utf-8 -*-
## python 2.7
from math import *
while True:
try:
#n = '6103213499'
n = raw_input(u"Ange ett personnumer: ")
@johnniehard
johnniehard / ellipsoid.py
Created January 21, 2017 08:49
Transforming geodesic latitude, longitude coordinates to geocentric X, Y, Z coordinates and back again.
'''
Define an ellipsoid by its semi major axis (a) and flattening (f).
The definition of the ellipsoid is then saved in the instance object and the functions can be called with just the coordinates to be transformed.
'''
from math import *
class Ellipsoid:
def __init__(self, a, f):
self.a = a
@johnniehard
johnniehard / gospatial_batchprocess.py
Last active June 8, 2017 15:14
Batch process an input directory with GoSpatial
'''
Author: Johnnie Hård, [email protected]
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()
<!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/[email protected]/dist/leaflet.css" />
<script src="https://unpkg.com/[email protected]/dist/leaflet.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/leaflet-providers/1.1.15/leaflet-providers.min.js"></script>
@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];
@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.

<h1>Hello World!</h1>
lkjdfkjfd