Skip to content

Instantly share code, notes, and snippets.

@gimoya
gimoya / add-geojson-to-leaflet-map.markdown
Created December 27, 2018 23:19
Add GeoJSON to Leaflet Map

Add GeoJSON to Leaflet Map

A demonstration of how to add geoJSON data to a Leaflet map. The demo uses jQuery's getJSON method and a vanilla XMLHttpRequest.

This demo is for the 1.x release of Leaflet.js.

GeoJSON data is provided by the City of Pittsburgh, Pennsylvania.

A Pen by Captain Anonymous on CodePen.

/*
YUI 3.18.1 (build f7e7bcb)
Copyright 2014 Yahoo! Inc. All rights reserved.
Licensed under the BSD License.
http://yuilibrary.com/license/
*/
typeof YUI!="undefined"&&(YUI._YUI=YUI);var YUI=function(){var e=0,t=this,n=arguments,r=n.length,i=function(e,t){return e&&e.hasOwnProperty&&e instanceof t},s=typeof YUI_config!="undefined"&&YUI_config;i(t,YUI)?(t._init(),YUI.GlobalConfig&&t.applyConfig(YUI.GlobalConfig),s&&t.applyConfig(s),r||(t._afterConfig(),t._setup())):t=new YUI;if(r){for(;e<r;e++)t.applyConfig(n[e]);t._afterConfig(),t._setup()}return t.instanceOf=i,t};(function(){var e,t,n="3.18.1",r=".",i="http://yui.yahooapis.com/",s="yui3-js-enabled",o="yui3-css-stamp",u=function(){},a=Array.prototype.slice,f={"io.xdrReady":1,"io.xdrResponse":1,"SWF.eventHandler":1},l=typeof window!="undefined",c=l?window:null,h=l?c.document:null,p=h&&h.documentElement,d=p&&p.className,v={},m=(new Date).getTime(),g=function(e,t,n,r){e&&e.addEventListener?e.addEventListener(t,n,r):e&&e.attachEvent&&e.attachEvent("on"+t,n)},y=
@gimoya
gimoya / spocc-test
Created March 18, 2014 08:30
testing {spocc}
> library(spocc)
> spp <- c("Myricaria germanica")
> dat <- occ(query = spp, from = "gbif", gbifopts = list(georeferenced = TRUE))
> dat
Summary of results - occurrences found for:
gbif : 25 records across 1 species
bison : 0 records across 1 species
inat : 0 records across 1 species
ebird : 0 records across 1 species
ecoengine : 0 records across 1 species
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@gimoya
gimoya / QGIS with Bergfex Tile Source
Last active December 22, 2015 09:19
This script can be used with the QGIS OpenLayers Plugin to get tiles from Bergfex (= OEK 50, Austrian topographic map). See here: [http://gis.stackexchange.com/questions/70648/using-custom-source-for-qgis-openlayers-plugin] and here: [http://gis.stackexchange.com/questions/69907/easiest-way-to-create-historical-street-maps-using-qgis] for refere…
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>OpenLayers Bergfex Topo Layer</title>
<link rel="stylesheet" href="qgis.css" type="text/css">
<script src="OpenLayers.js"></script>
<script src="OlOverviewMarker.js"></script>
<script type="text/javascript">
var map;
var loadEnd;
var oloMarker; // OpenLayer Overview Marker
;~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~;
; -> Kommentar
; Erläuterung Syntax:
; ::vegl:: vor Abk. -> sobald 'vegl' UND ',' oder '.' oder ' ' getippt wird, wird Wort vervollständigt
; :*:UW:: -> sobald 'UW' oder 'uw' getippt wird, wird 'UNTERWUCHS' oder 'Unterwuchs' vervollständigt
;~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~;
::UW::Unterwuchs
::SS::Strauchschicht
@gimoya
gimoya / test.csv
Created March 15, 2012 08:31
CSV-Data for testing read.table() with github:gist data
id age tolerance male exposure time
9 11 2.23 0 1.54 0
9 12 1.79 0 1.54 1
9 13 1.9000000000000001 0 1.54 2
9 14 2.12 0 1.54 3
9 15 2.66 0 1.54 4
45 11 1.12 1 1.16 0
45 12 1.45 1 1.16 1
45 13 1.45 1 1.16 2
45 14 1.45 1 1.16 3
@gimoya
gimoya / google_ss.R
Created March 13, 2012 13:30
Read spreadsheet data from Google Docs to R workspace
google_ss <- function(gid = NA, key = NA)
{
if (is.na(gid)) {stop("\nWorksheetnumber (gid) is missing\n")}
if (is.na(key)) {stop("\nDocumentkey (key) is missing\n")}
require(RCurl)
url <- getURL(paste("https://docs.google.com/spreadsheet/pub?key=", key,
"&single=true&gid=", gid, "&output=csv", sep = ""),
cainfo = system.file("CurlSSL", "cacert.pem", package = "RCurl"))
read.csv(textConnection(url), header = T, sep = ",")
}
@gimoya
gimoya / shBrushR.js
Created February 11, 2012 19:25
SyntaxHighlighter Brush for the R Language
/**
* Author: Yihui Xie
* URL: http://yihui.name/en/2010/09/syntaxhighlighter-brush-for-the-r-language
* License: GPL-2 | GPL-3
*/
SyntaxHighlighter.brushes.R = function()
{
var keywords = 'if else repeat while function for in next break TRUE FALSE NULL Inf NaN NA NA_integer_ NA_real_ NA_complex_ NA_character_';
var constants = 'LETTERS letters month.abb month.name pi';
this.regexList = [
@gimoya
gimoya / fun_install_github.R
Created January 1, 2012 13:31
Function to source all functions from a R github-repository
fun_install_github <- function (repo = "theBioBucket-Archives",
username = "gimoya",
branch = "master")
{require(RCurl)
message("\nInstalling ", repo, " R-functions from user ", username)
name <- paste(username, "-", repo, sep = "")
url <- paste("https://github.com/", username, "/", repo,
sep = "")
zip_url <- paste("https://nodeload.github.com/", username,
"/", repo, "/zipball/", branch, sep = "")