Skip to content

Instantly share code, notes, and snippets.

View esisa's full-sized avatar

Espen Oldeman Lund esisa

View GitHub Profile
# -*- coding: utf-8 -*-
from shapely.geometry import Polygon
polygon = Polygon([(0, 0), (1, 1), (1, 0)])
#print polygon.bounds
print "Areal før buffer: " , polygon.area
polygon2 = polygon.buffer(10)
print "Areal etter buffer: " , polygon2.area
# -*- coding: utf-8 -*-
import pyproj
# Point
lon = 10
lat = 60
# Projections
fromProj = pyproj.Proj(init='epsg:4258')
toProj = pyproj.Proj(init='epsg:25832')
# -*- coding: utf-8 -*-
from osgeo import gdal
# Read raster
source = gdal.Open('raster.tif')
nx, ny = source.RasterXSize, source.RasterYSize
band_array = source.GetRasterBand(1).ReadAsArray()
# Close raster
source = None
# -*- coding: utf-8 -*-
from fiona import collection
#c = collection("test.shp", "r")
#print "Projeksjon: " , c.crs
#print "Bounding box: " , c.bounds
#rec = c.next()
#print rec['properties']['AREAL']
@esisa
esisa / clear_cache
Created October 24, 2012 08:31
Clear a elevation profile cache
from django.conf import settings
# Cache location set to file
CACHES = {
'default': {
'BACKEND': 'django.core.cache.backends.filebased.FileBasedCache',
'LOCATION': '/tmp/waymarkedtrails-cache',
}
}
{
"units": "m",
"srs": "EPSG:32633",
"layout": "Normal(A4)",
"dpi": 60,
"layers": [{
"type": "Vector",
"styles": {
"1": {
"fillColor": "orange",
#
# Open a DEM, do a gaussian blur, then save it again
# Heavily based on:
# http://gis.stackexchange.com/questions/9431/what-raster-smoothing-generalization-tools-are-available
#
# Syntax for running snippet:
# python smoothDem.py input.tif output.tif 5
#
@esisa
esisa / Turapp example code
Last active January 2, 2016 13:58
Example code showing how to use Mapbox.js/Leaflet on Turapp.no
<!DOCTYPE html>
<html>
<head>
<title>Leaflet example code</title>
<meta name='viewport' content='width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no' />
<link href='http://api.tiles.mapbox.com/mapbox.js/v1.6.0/mapbox.css' rel='stylesheet' />
<script src='http://api.tiles.mapbox.com/mapbox.js/v1.6.0/mapbox.js'></script>
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="initial-scale=1,user-scalable=no,maximum-scale=1,width=device-width">
<meta name="mobile-web-app-capable" content="yes">
<meta name="apple-mobile-web-app-capable" content="yes">
<meta name="description" content="">
<meta name="author" content="">
@esisa
esisa / leaflet_image
Last active August 29, 2015 13:56
Error when running Leaflet Image
<!DOCTYPE html>
<html lang="en">
<head>
<script src='//api.tiles.mapbox.com/mapbox.js/v1.6.1/mapbox.js'></script>
<link href='//api.tiles.mapbox.com/mapbox.js/v1.6.1/mapbox.css' rel='stylesheet' />
<script src='//api.tiles.mapbox.com/mapbox.js/plugins/leaflet-image/v0.0.3/leaflet-image.js'></script>
<script src='//api.tiles.mapbox.com/mapbox.js/plugins/leaflet-image/v0.0.3/leaflet-image.js'></script>
<style type="text/css">
html,