1 of 14

GIS

HIPAA

2 of 14

The Grass is Greener with Turf.js

luminfire.com/gis

Andrew Walz

GIS Systems Engineer

@andywalz

github.com/andywalz/maptime-turf

3 of 14

Why Turf? Because it’s JavaScript

“Any application that can be written in JavaScript, will eventually be written in JavaScript”

--Jeff Atwood, co-founder of Stack Exchange

“Love it or hate it, the one thing a modern developer cannot do is ignore JavaScript. It is slowly but surely eating your world.”

--Sandeep Bhanot, Salesforce.com/Trailhead Vice President

4 of 14

JavaScript: Today

  • Millions of Developers
  • The largest repository of free libraries
  • Aka ECMAScript after org that standardizes it
  • Smart phones, Raspberry Pi, browsers, servers, the cloud (native apps too)
  • Controlled by non-profit foundations (with massive corporate support)
  • The de facto language of the Internet

5 of 14

JavaScript: Today

  • Runs on all browsers

  • Runs at any scale

  • Runs without a browser

  • Runs as/on servers too!

6 of 14

GIS & JavaScript

GEOJSON

APIs:

  • Google Maps
  • ArcGIS for JS
  • Carto
  • Mapbox
  • Bing
  • Mapquest
  • Here
  • OpenStreetMaps
  • & more

7 of 14

GEOJSON

  • Human readable geospatial data format 👍👍
  • De facto standard for geo data on the web
  • Easy to download, create, or export from Desktop GIS
  • Portable across other languages like Python, PHP, etc
  • Turf is built from the ground up around GeoJson

Essential Resources:

8 of 14

Advanced geospatial analysis for browsers and node

turf.tin(points);

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

9 of 14

Turf Functions List

AGGREGATION

  • collect

MEASUREMENT

CLASSIFICATION

  • nearest

TRANSFORMATION

MISC

DATA

  • random
  • sample

HELPER

INTERPOLATION

  • isolines
  • planepoint
  • tin

GRIDS

JOINS

  • inside
  • Tag

META

ASSERTIONS

10 of 14

Map Demos

http://conference-map.dev/

file:///Users/andywalz/Repos/FM/fmspatial/ancillary/index.html

https://www.mapbox.com/bites/00087/

http://geospatialem.github.io/conference-map/

11 of 14

Let’s write some code!

github.com/andywalz/maptime-turf

12 of 14

Node + Turf Demo

Terminal commands:

  • mkdir turf-demo
  • cd turf-demo/
  • git init
  • hub create
  • npm init
  • npm install open --save
  • npm install @turf/turf --save
  • ls node_modules
  • cat package.json
  • touch index.js
  • sublime .
  • node index.js

// Load GeoJson data: statewide libraries and hennepin county polygon

const points = JSON.parse(fs.readFileSync('./data/mn_libraries.geojson'));

const aoi = JSON.parse(fs.readFileSync('./data/hennepin.geojson'));

// Extract only points within aoi

var results = turf.within(points, aoi);

// Write results to a new geojson file

fs.writeFile('./hennepin_libraries.geojson',JSON.stringify(results));

console.log('saved output to hennepin_libraries.geojson, now opening map...');

// Map the Hennipen Co libaries in geojson.io

mapit(results);

// Buffer the libraries to see how much of county is within 2 miles of a libary

polygons = turf.buffer(results,2,'miles');

mapit(polygons);

function mapit(geojson) {

// open package allows open a file or url in the user's preferred application

const open = require('open');

// pass data to geojson.io via url segment

var geojsonUrl = 'http://geojson.io/#data=data:application/json,' + encodeURIComponent(JSON.stringify(geojson));

// open map in default web browser

open(geojsonUrl);

}

https://github.com/andywalz/turf-gislis

13 of 14

LuminFire GIS Plugins and Code

WordPress Plugins

  • WP-GeoMeta — Provides low-level spatial support for WordPress and a dashboard to check on your spatial data.
  • WP Spatial Capabilities Check — Check which spatial functions your WordPress site’s MySQL database supports.
  • Brilliant Geocoder for Gravity Forms — Geocode user’s input values in the popular Gravity Forms plugin for WordPress.

Libraries

  • WP-GeoMeta-Lib — A library to add spatial support to your own WordPress plugins or themes.

FileMaker Demo File

  • fmFiddle — A sample FileMaker file with Geocoding and other spatial functionality. Requires FileMaker (afree 30 day trial of FileMaker is available).

https://brilliantplugins.com/

14 of 14

Questions?

luminfire.com/gis

Andrew Walz

GIS Systems Engineer

@andywalz