This document provides an overview of a mapping tutorial that will cover building maps and mapping data. The tutorial is divided into two parts - the first half covers building and displaying maps, while the second half focuses on mapping data. Various mapping APIs and libraries are introduced, including Google Maps, Yahoo Maps, OpenStreetMap, Mapstraction, and OpenLayers. Terminology related to maps and geodata is also defined.
The Ultimate Guide to Choosing WordPress Pros and Cons
Mapping Hacks Tutorial 1
1. Where 2.0
Mapping Hacks Tutorial 1
Andrew Turner FortiusOne ajturner@gmail.com
Rabble ENTP evan@protest.net
Welcome to Mapping the Mapping Hacks with Google, Yahoo, Open Street Map, and fellow
travelers.
I’m Rabble, i like to cause trouble, and think maps are fun. I don’t do this for a living.
I’m Andrew, i like to build maps and i do do this for a living.
2. Mapping Hacks Tutorial
What’s Covered?
Building Maps Part I
Building Data Part II
This tutorial is divided up in to two parts. First half is the building and display of maps. Then
we’ll have a break, and the second half will be about the data of maps.
3. Feel free
to ask questions
at any time.
http://flickr.com/photos/seandreilinger/2326448445
4. Building Maps
How to build maps, and put them on the web. The scope of this tutorial is limited to web
mapping.
5. Building Data
The second half of the workshop is how to get and manipulate mapping data. There’s a huge
amount of geodata out there, the trick is getting it in to useful formats.
6. Building Data == Later == Part II
But that’s for the second half, after the break. Before we can get there, we need to be able to
see it.
7. Building Maps On Other
People’s API’s
It’s possible to use pure open source data and software to do mapping. For the more
advanced examples we will use these tools. But the vast majority of mapping hacks today are
built upon google maps, so we will start by walking through how to build on top of and
extend google maps.
8. Terminology
•Vector •XML
•Raster •REST
•Feature •Proprietary - Open
•Attributes
First, some terminology to help
9. Terminology
•Vector •XML
•Raster •REST
•Feature •Proprietary - Open
•Attributes
First, some terminology to help
10. Terminology
•Vector •XML
•Raster •REST
•Feature •Proprietary - Open
•Attributes
First, some terminology to help
11. Terminology
•Vector •XML
•Raster •REST
•Feature •Proprietary - Open
•Attributes
First, some terminology to help
12. Terminology
•Vector •XML
•Raster •REST
•Feature •Proprietary - Open
•Attributes
First, some terminology to help
13. Terminology
<element attribute=quot;valuequot;>
•Vector •XML content
</element>
•Raster •REST
•Feature •Proprietary - Open
•Attributes
First, some terminology to help
14. Terminology
<element attribute=quot;valuequot;>
•Vector •XML content
</element>
•Raster •REST http://host/resource.format
•Feature •Proprietary - Open
•Attributes
First, some terminology to help
15. Terminology: Geometries
• Point
• LineString
• Box
• Polygon
• MultiGeometry
• Coordinate Reference System (aka Projection)
Even with “location” there are several important types of geometries that are common.
Almost all the formats we’ll talk about support all these geometry types. So we’ll show some
examples, but assume you’ll need to know what’s appropriate, but that it’s probably
supported.
16. Terminology: Geometries
• Point
• LineString
• Box
• Polygon
• MultiGeometry
• Coordinate Reference System (aka Projection)
Even with “location” there are several important types of geometries that are common.
Almost all the formats we’ll talk about support all these geometry types. So we’ll show some
examples, but assume you’ll need to know what’s appropriate, but that it’s probably
supported.
17. Terminology: Geometries
• Point
• LineString
• Box
• Polygon
• MultiGeometry
• Coordinate Reference System (aka Projection)
Even with “location” there are several important types of geometries that are common.
Almost all the formats we’ll talk about support all these geometry types. So we’ll show some
examples, but assume you’ll need to know what’s appropriate, but that it’s probably
supported.
18. Terminology: Geometries
• Point
• LineString
• Box
• Polygon
• MultiGeometry
• Coordinate Reference System (aka Projection)
Even with “location” there are several important types of geometries that are common.
Almost all the formats we’ll talk about support all these geometry types. So we’ll show some
examples, but assume you’ll need to know what’s appropriate, but that it’s probably
supported.
19. Terminology: Geometries
• Point
• LineString
• Box
• Polygon
• MultiGeometry
• Coordinate Reference System (aka Projection)
Even with “location” there are several important types of geometries that are common.
Almost all the formats we’ll talk about support all these geometry types. So we’ll show some
examples, but assume you’ll need to know what’s appropriate, but that it’s probably
supported.
20. Terminology: Geometries
• Point
• LineString
• Box
• Polygon
• MultiGeometry
• Coordinate Reference System (aka Projection)
Even with “location” there are several important types of geometries that are common.
Almost all the formats we’ll talk about support all these geometry types. So we’ll show some
examples, but assume you’ll need to know what’s appropriate, but that it’s probably
supported.
21. Terminology: Geometries
• Point
• LineString
• Box
• Polygon
• MultiGeometry
• Coordinate Reference System (aka Projection)
Even with “location” there are several important types of geometries that are common.
Almost all the formats we’ll talk about support all these geometry types. So we’ll show some
examples, but assume you’ll need to know what’s appropriate, but that it’s probably
supported.
24. Google Maps
Web mapping has been around for a long time, but it was really the advent of google maps
which got the masses hacking on web maps.
25. Mapstraction
Beyond our first demos we’ll get in to how to use the mapstraction library. It lets you easily
move between mapping apis, it’s open source, and works with many data sources.
29. Mapstraction Recipe
1.Include Javascripts
2.Create an HTML Map Div
3.Create a JavaScript Mapstraction object
4.Center the Map
5.Add Controls
6.Add Features - Markers, Polylines, Overlays, etc.
7.Events
51. Why does open, interoperable data matter?
We just went over how you can create markers with javascript, from a database. Why would
you bother spending time and resources working with formats that man mean other people
can use your data?
52. http://www.flickr.com/photos/blah_oh_well/352203022
It’s not enough for a
Web App to be Sticky...
Common design principles want to make a website “sticky”. To encourage users to stay at the
site and return often.
But this is no longer sufficient - users want more.
53. http://www.flickr.com/photos/orinrobertjohn/139788703
...it also needs to be
stringy.
Web applications need to be “Stringy” - they need to provide ways for users to move their
data into, and out of the system. It needs to connect into the rest of their personal and
corporate suite of tools, workflows, and expectations.
58. photo credits
Recovery.gov
Recovery.gov is a very new, and quickly conceived and implemented initiative to track all the
stimulus dollars: from tax payer, to gov’t, to agency, to project, to tax payer.
59. photo credits
A Chance for Change http://isd.ischool.berkeley.edu/stimulus/2009-029/
Given the new administration support for new initiatives and Transparency, it’s a chance for
agencies, and citizens, to engage in rethinking how it’s all done.
They’re talking about GeoRSS AtomPub, KML, Linked Open Data, RDFa. All the hot topics on
data sharing - the point of this workshop.
60. photo credits
TimeMap Mockup
The UC Berkeley iSchool has published papers, example websites, and example feeds about
how it *could* be done.
61. photo credits
Data.gov
And it’s just the beginning. Data.gov will incorporate these ideas across the federal, and
subsequently local, governments. This will be they ways in which information is spread in the
US Government.
62. International Open Data
And it’s not just the US government, it also applies internationally to directives such as
INSPIRE which is working in the EU to open data.
63. THEREFORE BE IT RESOLVED THAT the City of
Vancouver endorses the principles of:
• Open and Accessible Data - the City of
Vancouver will freely share with citizens,
businesses and other jurisdictions the greatest
amount of data possible while respecting
privacy and security concerns;
• Open Standards - the City of Vancouver will
move as quickly as possible to adopt
prevailing open standards for data,
documents, maps, and other formats of
media;
motion, May 15, 2009
Governments are enforcing data standards.
This is a big win from getting data for your system, as well as providing them technology that
works within their ecosystem.
65. photo credits
lots of this Sheets of CSV files
Currently data is shared either by large spreadsheets of unstructured (or at best semi-
structured) tabular data
66. photo credits
http://www.flickr.com/photos/johncharlton/360919818
Each Format is Unique
Even when there is structure, people use arbitrary markups, formats, schemas.
67. photo credits
http://www.flickr.com/photos/bookgrl/3111647593
...and unlinked
And there has been no way to know if one location was the same as another - or a person or
project had a link to more about them.
71. http://www.flickr.com/photos/tomhe/311381947
What do you want to do?
The first, overarching thing you can do when choosing the formats to support is consider
what you are trying to accomplish.
Interchange
Visualization
Analysis
86. GeoRSS Future
• Supports point, line, box, polygon
• Not an ‘official’ standard. OGC best practice
• Used by most mapping tools
• Next generation:
• External, by reference, geometries (e.g. link to “US”)
• Multiple geometries per entry
http://georss.org
89. GeoJSON
{ quot;keyquot;: quot;valuequot;,
quot;dictionaryquot; : {
quot;index1quot;:quot;another valuequot;,
quot;index2quot;:quot;more valuesquot;
}}
very compact - only requires an eval() to turn into JavaScript objects.
90. GeoJSON: Point
{ quot;typequot;: quot;Pointquot;,
quot;coordinatesquot;: [100.0, 0.0] }
Supports all the standard geometry types.
98. GPX
• Common Format for GPS (XML)
• Stores
• Waypoints (wpt)
• Tracks (trk)
• Routes (rte)
• Useful for importing from GPS (for geotagging photos) or exporting to (tracks,
waypoints, points of interest)
GPS Exchange format
Used for exporting/importing to GPS Devices
102. CSV - Comma Separated Value
quot;namequot;,quot;holeparquot;,quot;holeyardagequot;,quot;holenumberquot;,quot;latitudequot;,quot;longitudequot;
quot;Simple placemarkquot;,quot;4.0quot;,quot;234.0quot;,quot;1.0quot;,quot;-121.082203542568quot;,quot;37.4222899014025quot;
quot;Simple placemark 2quot;,quot;3.0quot;,quot;100.0quot;,quot;2.0quot;,quot;-121.082203542568quot;,quot;37.4222899014025quot;
quot;namequot;,quot;holeparquot;,quot;holeyardagequot;,quot;holenumberquot;,quot;addressquot;
quot;Simple placemarkquot;,quot;4.0quot;,quot;234.0quot;,quot;1.0quot;,quot;1517 N. Main St., Royal Oak, MIquot;
quot;Simple placemark 2quot;,quot;3.0quot;,quot;100.0quot;,quot;2.0quot;,quot;2200 Wilson Blvd., Arlington, VAquot;
can embed Lat,lon as columns - or WKB (well known binary) string
105. KML
http://code.google.com/apis/kml/
documentation/kmlreference.html
photourl
KML emerged as a commonly used format for sharing data. It meets the 80% case for
geographic information, human-readable information, metadata, attributes, temporal, 3D,
navigation and more. Surprisingly capable for a simple format.
106. KML
<?xml version=quot;1.0quot; encoding=quot;UTF-8quot;?>
<kml xmlns=quot;http://earth.google.com/kml/2.2quot;>
<Placemark>
<name>Simple placemark</name>
<description>Attached to the ground. Intelligently places itself
at the height of the underlying terrain.</description>
<Point>
<coordinates>-122.0822035425683,37.42228990140251,0</coordinates>
</Point>
</Placemark>
</kml>
110. KML 3D
KML can be styled with icons, colors, labels, and even 3D.
111. KML: Extended Data
<ExtendedData id=quot;roomsquot;>
<name>Rooms</name>
<value>3</value>
</ExtendedData>
A way to embed attribute data with any placemark
113. KML: Styles
<Style id='class_0'>
<PolyStyle>
Polygon
<color>bfa5f7fe</color>
<fill>1</fill>
<outline>1</outline>
</PolyStyle>
<LineStyle>
<color>ffa5f7fe</color>
<width>2</width> Line
</LineStyle>
<IconStyle>
<color>bfa5f7fe</color>
<scale>1</scale>
<Icon>
Icon
<href>http://maker.geocommons.com/images/icons/propCircle.png</href>
</Icon>
<hotSpot x=quot;0.5quot; y=quot;0.5quot; xunits=quot;fractionquot; yunits=quot;fractionquot;/>
</IconStyle>
<BalloonStyle>
<text>
Info Window
<![CDATA[<p><b>Number of Installations:</b> $[selected_attribute]</p>
<p><b>cost per 0:</b> $[cost]<br/><b>Description:</b> $[description]<br/>
<b>Incentives:</b> $[incentives]<br/><b>Name:</b> $[name]<br/>
<b>Size of installs (kW):</b> $[size]<br/><b>Zipcode:</b> $[zipcode]<br/></p>
<p><a href=quot;http://maker.geocommons.com/maps/5015quot;>View the map in Maker<i>!</i></p>]]></text>
</BalloonStyle>
</Style>
114. KML: Network Links
index.kml
layer1.kml layer2.kml layer3.kml
<NetworkLink>
<name><![CDATA[Pubs in London]]></name>
<Link>
<href>http://maker.geocommons.com/maps/839/overlays/1</href>
</Link>
</NetworkLink>
Link to other KML files within a KML file. Useful for directory listings of KML.
116. KML Spotlight:
Flickr Export
Flickr photos can be exported using the GeoRSS (geoFeed) or KML links at the bottom of
Flickr pages. This is useful for viewing in GoogleEarth.
118. KMZ - Zipped KML
All the verbosity, 10% the size.
Cunning in the simplicity of assigning a Zip compression as an actual type. Makes it very easy
to expose via RESTful services and mime-types.
Very useful when bundling multiple KML files and 3D models together.
119. Other Visualization Formats
•SLD - Styled Layer Descriptor
•Mapnik
•Cascadenik
SLD - an OGC specification. Uses bits of CSS and a lot of XML
Mapnik - the mapnik map rendering library has it’s own styling XML
Cascadenik - a CSS3-like map styling, with preprocesses for exporting to Mapnik styling
122. Shapefile
A misnomer - not a single “File”, but multiple files: SHP geometry, DBF database, SHX data-
geometry join, PRJ projection file, XML metadata.
ESRI Proprietary format - though now widely used.
Limited to 10 character attribute titles.
All geometries must be the same ‘type’ (all points, or all polygons, but not both)
131. File Sizes
File Type Size
CSV (points) 3.7k
KML 460k
Shapefile 208k
Proposed Stimulus Spending
http://finder.geocommons.com/overlays/9313
The first is strictly technical - what is the file size of these formats? How doest that affect the
user (mobile, costs, server)
132. User Compatibility
• Feed Readers
• GoogleEarth
• Mapping API’s
• Browsers
What tools will the user be using to consume or produce this information?
133. http://www.flickr.com/photos/samiksha/406928440
What does the user
understand?
What terms do they understand?
KML has done very well because people know what “GoogleEarth” is and means. They may
have an “RSS Reader”, but they probably don’t have “ArcGIS Desktop” or QGIS. They almost all
have Excel to read CSV.
134. http://www.flickr.com/photos/umpqua/191909440
What does the data
Form follows Function
suggest?
The purpose of the data informs how it should be exposed and utilized.
Is it just for an API? Is it for users to subscribe to? Visualize? Analyze?
136. Resources
•/places
•/places/89
•/places/89.atom
•/places/89.kml
•/places/89.sqlite
Don’t have to choose a single format - provide many. Appropriate for basic or advanced
users and developers
137. Web Aligned http://highearthorbit.com/a-proposal-georss-kml
Link to the other formats. Tools are getting better at following these links.
138. http://www.flickr.com/photos/alfr3do/7436142
What does the user
understand?
What terms do they understand?
KML has done very well because people know what “GoogleEarth” is and means. They may
have an “RSS Reader”, but they probably don’t have “ArcGIS Desktop” or QGIS. They almost all
have Excel to read CSV.
142. OpenSearch Template
http://geocommons.com/search
?keyword={searchTerms}
&limit={count?}
&page={startPage?}
required
optional?
OpenSearch is essentially a way to template out search parameters from a URL.
143. OpenSearch - HTML
<html xmlns=quot;http://www.w3.org/1999/xhtmlquot; xml:lang=quot;enquot; lang=quot;enquot;>
<head>
<title>Starting a Business in San Francisco map</title>
<link type=quot;application/opensearchdescription+xmlquot; title=quot;Mapufacturequot;
rel=quot;searchquot; href=quot;http://geocommons.com/search.xmlquot; />
<link type=quot;application/atom+xmlquot;
title=quot;Mapufacture GeoRSS Feed for Starting a Business in San
Franciscoquot;
rel=quot;alternatequot; href=quot;http://geocommons.com/maps/1621.atomquot; />
<link type=quot;application/vnd.google-earth.kml+xmlquot;
title=quot;Mapufacture KML for Starting a Business in San Franciscoquot;
rel=quot;alternatequot; href=quot;http://geocommons.com/maps/1621.kmlquot; />
</head>
<body>
...
</body>
</html>
If you provide a link in your HTML page to the OpenSearch - browsers like Firefox, Safari, and
Internet Explorer can embed these into browser search bars.
Even MS Windows 7 can connect OpenSearch providers into your *desktop search* to the
web.
144. OpenSearch - HTML
<html xmlns=quot;http://www.w3.org/1999/xhtmlquot; xml:lang=quot;enquot; lang=quot;enquot;>
<head>
<title>Starting a Business in San Francisco map</title>
<link type=quot;application/opensearchdescription+xmlquot; title=quot;Mapufacturequot;
rel=quot;searchquot; href=quot;http://geocommons.com/search.xmlquot; />
<link type=quot;application/atom+xmlquot;
title=quot;Mapufacture GeoRSS Feed for Starting a Business in San
Franciscoquot;
rel=quot;alternatequot; href=quot;http://geocommons.com/maps/1621.atomquot; />
<link type=quot;application/vnd.google-earth.kml+xmlquot;
title=quot;Mapufacture KML for Starting a Business in San Franciscoquot;
rel=quot;alternatequot; href=quot;http://geocommons.com/maps/1621.kmlquot; />
</head>
<body>
...
</body>
</html>
If you provide a link in your HTML page to the OpenSearch - browsers like Firefox, Safari, and
Internet Explorer can embed these into browser search bars.
Even MS Windows 7 can connect OpenSearch providers into your *desktop search* to the
web.
145. OpenSearch - HTML
<html xmlns=quot;http://www.w3.org/1999/xhtmlquot; xml:lang=quot;enquot; lang=quot;enquot;>
<head>
<title>Starting a Business in San Francisco map</title>
<link type=quot;application/opensearchdescription+xmlquot; title=quot;Mapufacturequot;
rel=quot;searchquot; href=quot;http://geocommons.com/search.xmlquot; />
<link type=quot;application/atom+xmlquot;
title=quot;Mapufacture GeoRSS Feed for Starting a Business in San
Franciscoquot;
rel=quot;alternatequot; href=quot;http://geocommons.com/maps/1621.atomquot; />
<link type=quot;application/vnd.google-earth.kml+xmlquot;
title=quot;Mapufacture KML for Starting a Business in San Franciscoquot;
rel=quot;alternatequot; href=quot;http://geocommons.com/maps/1621.kmlquot; />
</head>
<body>
...
</body>
</html>
If you provide a link in your HTML page to the OpenSearch - browsers like Firefox, Safari, and
Internet Explorer can embed these into browser search bars.
Even MS Windows 7 can connect OpenSearch providers into your *desktop search* to the
web.
146. Description Document
<?xml version=quot;1.0quot; encoding=quot;UTF-8quot;?>
<OpenSearchDescription xmlns=quot;http://a9.com/-/spec/opensearch/1.1/quot;
xmlns:geo=quot;http://a9.com/-/opensearch/extensions/geo/1.0/quot;>
<ShortName>GeoCommons</ShortName>
<Description>Search for maps and data in GeoCommons</Description>
<Tags>geo georss location kml aggregation geosearch</Tags>
<Contact>robot@geocommons.com</Contact>
<Image width=quot;16quot; height=quot;16quot; type=quot;image/x-iconquot;>http://geocommons.com/
favicon.ico</Image>
<Url type=quot;text/htmlquot; template=quot;http://maker.geocommons.com/searches?
query={searchTerms}&limit={count?}&page={startPage?}quot;/>
<Url type=quot;application/atom+xmlquot; template=quot;http://maker.geocommons.com/
searches.atom?query={searchTerms?}&limit={count?}&page={startPage?}quot;/>
</OpenSearchDescription>
http://maker.geocommons.com/search.xml
There is a description document that is hosted on your site.
177. GPSBabel http://gpsbabel.org
your swiss army knife
convert from one to another
178. GDAL/OGR http://gdal.org
when you need a powersaw instead of a swiss army knife
GDAL translates Raster data (97 formats)
OGR translates Vector data (35 formats)
179. GeoNames GeoRSS http://www.geonames.org/rss-to-georss-converter.html
Converts RSS to GeoRSS
there are many more.