Skip to content

Instantly share code, notes, and snippets.

@DenisCarriere
Last active September 20, 2017 19:37
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save DenisCarriere/ed973fe14dc3c270e6aba43df4a917c7 to your computer and use it in GitHub Desktop.
Save DenisCarriere/ed973fe14dc3c270e6aba43df4a917c7 to your computer and use it in GitHub Desktop.
GIS Homework

GIS Homework

Prepared by: @DenisCarriere

A few libraries to know about for doing Geospatial analysis using primarily OpenStreetMap Data & Vector Tiles.

TurfJS is an advance GeoSpatial analysis/computing library for the web (written ES5 Javascript).

  • Simple: Modular, simple-to-understand JavaScript functions that speak GeoJSON
  • Fast: Takes advantage of the newest algorithms and doesn't require you to send data to a server
  • Modular: Turf is a collection of small modules. You can require just what you use with browserify

For example, a very powerful and utility module would be @turf/meta which allows you to iterate easily over your geospatial data:

Iterate over coordinates in any GeoJSON object, similar to Array.forEach()

Iterate over properties in any GeoJSON object, similar to Array.forEach()

Iterate over features in any GeoJSON object, similar to Array.forEach.

Iterate over each geometry in any GeoJSON object, similar to Array.forEach()

Iterate over flattened features in any GeoJSON object, similar to Array.forEach.

Iterate over 2-vertex line segment in any GeoJSON object, similar to Array.forEach() (Multi)Point geometries do not contain segments therefore they are ignored during this operation.

Iterate over line or ring coordinates in LineString, Polygon, MultiLineString, MultiPolygon Features or Geometries, similar to Array.forEach.

$ npm install @turf/meta
import {coordEach, propEach} from '@turf/meta' // Using Babel or Typescript
// const {coordEach, propEach} = require('@turf/meta')

const dataset = {
  type: 'FeatureCollection',
  features: [
    {
      type: 'Feature',
      properties: { foo: 'bar' },
      geometry: { type: 'Point', coordinates: [10, 10] }
    },
    {
      type: 'Feature',
      properties: { hello: 'world' },
      geometry: { type: 'Point', coordinates: [20, 50] }
    }
  ]
}

coordEach(dataset, coord => {
  //= [10, 10]
  //= [20, 50]
})

propEach(dataset, properties => {
  //= { foo: 'bar' }
  //= { hello: 'world' }
})

For all updates on releases, check out the release GitHub tag.

TileReduce is a geoprocessing library that implements MapReduce to let you run scalable distributed spatial analysis using JavaScript and Mapbox Vector Tiles. TileReduce coordinates tasks across all available processors on a machine, so your analysis runs lightning fast.

OpenStreetMap data as Mapbox Vector Tiles in an MBTiles file for data analysis.

Includes:

  • (almost) unsimplified geometries
  • all OpenStreetMap tags
  • additional properties like changeset, time, and user ids
  • zoom 12
  • no buffer around individual tiles

Build vector tilesets from large collections of GeoJSON features.

Examples using all platforms

Blazing fast tile based geocoder that matches cross street (road intersections) entirely sourced by OSM QA Tiles.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment