Injecting spatial into your everyday data munging is an easy way to
punch up the impact of your applications:
don't just show
what , show where.
(Plus, maps just look cool.)
If you're here today, I'm going to assume a couple things: that
you're interested in learning about, if not already experienced in,
programming; that you're interested in open data, and you're
interested in building - or helping build - applications using open
data. And that's great! But why should you be interested in web
maps specifically?
FUN FACT: you don't have to be a GIS "expert" to make a web map.
Wait... What even is "GIS"?
Technically, Geographic Information Systems
means computer systems, infrastructure, software, an
entire industry dedicated to "spatial data"... blah, blah, blah,
blah
Really, GIS is mostly about
"using spatial data to make maps"
*Note:
For this talk today, "(geo)spatial" data and
"GIS" data are interchangable
Because you're probably going to be google for data, you'll want to
be familiar with both terms. Depending on where you look, you might
see something like "City of Austin GIS Data" or "USGS Geospatial
Data Downloads". Just know that this is all talking about the same
kind of data.
What's so special
about spatial data?
Not very much!
Spatial data is just regular data, with location info
attached.
Regular data:
Table of firestations in Austin - via
data.austintexas.gov
...Spatialized:
Table of firestations in Austin with lat/lon coordinates - via
data.austintexas.gov
Take a second to define lat/lon
Which can make:
Map of firestations in Austin - via
data.austintexas.gov
Vector vs. Raster
Spatial data comes in two flavors: vector
and raster
Most likely, most of the data you'll work with (or create)
will be vector data
Vector GIS data
Points, lines, and polygons.
Inherently spatial
Just like geometric points are defined by an (x,y) pair:
geospatial points can be defined by (lat/lon) coordinates.
What's it good for?
Points of interest (e.g., firestations)
Roads, rivers, boundary lines
Lakes, building footprints, census areas
etc.
Working With GIS Data
So even though I gave you a whirlwind explanation of "what the heck
is 'raster' GIS data?" -- for the most part you're going to focus
on vector data. The mast majority of the data you will want to go
looking for -- and will find -- on open data repositories will be
point, line, or polygon data.
Data formats
SPOILER ALERT:
Most of the (vector) data you'll find will be "a shapefile"
This is "a shapefile."
Yes, really.
Spatial data for the web
To use spatial data in a web app, you've got options:
Database
Map Server
or...
Binary File: XML, JSON, CSV, etc
So shapefiles are great as long as your constraining your data
analysis or processing to "on my own computer" use cases. For the web,
shapefiles are less convenient. Luckily, if you're building a webmap,
you've got options as far as "where to stick your data".
GeoJSON : Regular JSON, but with coordinates. e.g.,
{
"type": "Feature",
"geometry": {
"type": "Point",
"coordinates": [-97.740323, 30.274656]
},
"properties":
{
"name": "Texas Capitol Building",
"address": "1100 Congress Ave, Austin, TX 78701"
}
}
GeoJSON will probably look very comfortably-familiar to you, if
you've worked with any JSON datasets before. It's essentially the
same JSON you know & love... plus spatial.
For now, we're going to focus on building web maps with
GeoJSON-formatted spatial data -- because it's easy to convert
into, widely supported, and easy to work with.
Local Data Resources
We're lucky: Texas has a ton of great, open GIS data!
Some places to
start looking:
Finding Data
Beyond Texas, GIS data is everywhere - but finding it can be tricky.
On larger scales, Government-sponsored data portals (like data.gov for the
US) can be a great resource.
A lot of freely-available spatial data is virtually impossible to find
by casual searching -- and in many cases, knowing "who" to ask can be
just as important (if not MORE important!) than knowing "what". When in
doubt, start asking around.
Remember: People are a great resource
I was curious about popular datasets outside of Texas...
...so I asked the internet.
Lots of wonderful people responded! See:
https://twitter.com/sarasomewhere/status/781236823305564160
In just an hour or two, I got over 2 dozen links from around
the world -- some datasets I was familiar with (like NOAA's
weather data) but most I'd never even thought about thinking
about! You can see a lot of the responses in the thread at that
link, if you're interested.
Useful Online Tools
ogre.adc4gis.com: Convert from one format to another
mapshaper.org: Make giant datasets tiny, fast
geojson.io: Quickly validate & visualize your GeoJSON
Each of these are fully opensource, and all 3 of these are actually
apps you can run locally if you prefer. However, each of these
tools do things that other, more complete toolsets already do. As a
non-GIS person, you probably aren't going to want to care about
setting up & learning those other things. These tools are free,
fast, and simple to use - and they get the job done without getting
in your way.
Building web maps
for fun & profit
In a nutshell
TL;DR: a web map* is a map in the browser which lets
you click, zoom, and pan
*(sometimes called a "slippy map")
Web maps are usually made with HTML and JavaScript:
lots of options here,
LeafletJS is one of the most popular.
A word about basemaps
An important component of a web map is the basemap : the
underlying map tiles that give your data context.
Many free-to-use basemaps have been created using OpenStreetMap's open data
Examples: some OSM-based basemaps
Let's Make a Map!
I'm going to show you 2 different ways to map your newly-aquired
open spatial data -- we'll blow through the example pretty
quickly, so don't bother following along right now. In a minute
I'll give you the slide links and you can work at your own pace
(and I'll try to answer any questions you have).
Option 1: GitHub + GeoJSON
Simple maps in 2 minutes or less: no customization
options, but great for quickly displaying data on a map
Push a GeoJSON file to GitHub.
View your GeoJSON file on GitHub.
There is no step three.
GitHub's built-in GeoJSON rendering is a great option if you just need
to show some data on a map, with no programming effort. GitHub is
actually using LeafletJS and an OSM-based basemap behind the scenes,
to make this happen.
Option 2: Leaflet
An open source JavaScript library, Leaflet is the "glue" between your data,
a basemap, and a beautiful, mobile-friendly "slippy map" interface.
Sample code
DON'T worry! I don't expect you to copy this down, or even read it
completely. I'm just including it as an example of how simple it is to
make a webmap with Leaflet. This code makes a map, using Open Street
Map as the background ("basemap"), and displays "myawesomedata.json"
(a GeoJSON file) on the map. It also makes the features in
myawesomedata clickable, and generates popup windows showing each
feature's name.
Building your own map
I won't bother re-inventing the wheel: here are a couple resources to
get you started. Leaflet's own documentation is FANTASTIC, and the
tutorials (linked here) are really all you need to get started. If you
want to build the same exact sample map from the previous slide, I've
got a blog post that walks you through it.
What now?
Choose your own adventure!
Find data*
Convert data to web-friendly GeoJSON (if needed)
Use a mapping library like Leaflet to display your data on an
interactive "slippy map"
???
*Ready-made sample data: sarasafavi.com/maps/libraries.json
The links in these slides should help you get started down this path. I'll
be around through the end of today to help if you decide to use the free space to
work on a web map. Good luck, and have fun!