Skip to content

Instantly share code, notes, and snippets.

View morganherlocker's full-sized avatar
☠️
computing

Morgan Herlocker morganherlocker

☠️
computing
View GitHub Profile
var pts = // my point featurecollection
var polys = // my poly featurecollection
var tree = rbush()
polys.features.forEach(function(poly, i){
var bbox = turf.bbox(poly)
var idx = {
minX: bbox[0],
minY: bbox[1],
var pts = // my point featurecollection
var polys = // my poly featurecollection
pts.features = pts.features.filter(function(pt){
var isInside = false
polys.features.forEach(function(poly){
if(turf.inside(pt, poly)) isInside = true
})
return isInside
})
var geojson2svg = require('geojson2svg');
var turf = require('turf');
var fs = require('fs')
var polys = require('polygons.json') // a featurecollection of geojson polygons with a name property
polys.features.forEach(function(poly){
var extent = turf.bbox(poly)
var options = {
viewportSize: {width: 200, height: 100},
mapExtent: {left: extent[0], bottom: extent[1], right: extent[2], top: extent[3]},
@morganherlocker
morganherlocker / index.js
Last active May 3, 2016 20:21
tile-reduce + cheap-ruler example
var tileReduce = require('tile-reduce');
var path = require('path');
tileReduce({
zoom: 14,
map: path.join(__dirname, '/process.js'),
sources: [
{name: 'ways', mbtiles: 'ways.mbtiles')}
]
});
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@morganherlocker
morganherlocker / gist:7491657
Created November 15, 2013 21:08
ogr2ogr geojson to KML
ogr2ogr -f KML /full/path/a.kml /full/path/b.geojson
var turf = require('turf')
var tilebelt = require('tilebelt')
// put your own data here
var stargazers = [<list of lat lons>]
// this sets the size of your grid cells; each grid cell is a map tile at the given zoom
var zoom = 12
// tiles is a hash we can quickly add new tiles too and increment counts
var tiles = {}
var turf = require('turf')
var polys = //my polygon featurecollection
var edges = []
polys.features.forEach(function(poly){
for(var i = 0; i < poly.geometry.coordinates[0].length-1; i++){
edges.push({
start: turf.point(poly.geometry.coordinates[0][i]),
stop: turf.point(poly.geometry.coordinates[0][i+1])
})
../wgrib2 000 -s | grep "TMP:surface" | ../wgrib2 -i 000 -csv out.csv
var poly = {
"type": "Feature",
"properties": {},
"geometry": {
"type": "Polygon",
"coordinates": [
[
[
51.17431640625,
47.025206001585396