Skip to content

Instantly share code, notes, and snippets.

View morganherlocker's full-sized avatar
☠️
computing

Morgan Herlocker morganherlocker

☠️
computing
View GitHub Profile
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 / bay_to_breakers.geojson
Last active August 2, 2021 07:51
turf buffer example
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
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

MatchResult

name type description
matched_points Array<Array<Number>> Coordinates the points snapped to the road network as latitude, longitude pairs.
indices Array<Number> Array that gives the indices of the matched coordinates in the original trace.
geometry String Geometry of the matched trace in the road network, compressed as a polyline with 6 decimals of precision.