Thursday, August 28, 2014

An Introduction to Leaflet, Part I: CSVs and Pop-ups

Leaflet is an open source JavaScript library for publishing interactive web-based and mobile maps. Most tutorials on Leaflet's website are geared towards creating basic maps with a small number of features.

Despite this, the code libraries are capable of doing much more!  Today's post will focus on importing and using point data in spreadsheet form, specifically comma separated value files or *.csv.  (In the next post, we will look at other data types and formats.)  l will use the Leaflet Simple CSV Plugin that contains many different features, which I will describe later.

The data
The data set contains locations of homicides (417) in Chicago during 2013.  It also contains attribute data for incident, type, circumstances, arrests, date, and, location.  It is available through Chicago's large open data portal.

End product:
If you want to skip to see the end result, click this link:  The screenshot below shows the map on an iPad Mini (Gen 1). Click for a closer vew.

On iPad Mini: A Leaflet Map of Homicides in Chicago, 2013
How I got there...
There are several Leaflet plugins to import *.csv files.  On the web, I found the Leaflet Simple CSV Plugin by Matthew Perry that incorporates several different plugins, including a bonus one for clustering/collecting markers, into one set of code. Furthermore, it contains code for allowing attribute data from the *.csv file to be displayed when a marker is clicked.  

Pop-up displaying attribute data from the *.csv about the homicide
The code package put together many different capabilities. It was easy-to-use, modify, has documentation, and a working example.  I accessed the maps on several devices: two different computers, the iPad mini, an iPhone 4S, and a Nexus 7 tablet.  The only device that had an issue was the iPhone 4S.  When clicking a point market, pop-up attribute data was not always displayed and simply flickered.  I am still looking into this and will post anything I found out.

Resources for Learning Leaflet
Leaflet.js Essentials (Published August 2014)

Where to learn JavaScript and more coding skills for free

Tuesday, August 19, 2014

Free Online Mapping Classes From PSU and Coursera

Course dates: Last updated on 12/16/2014

Penn State has an online Open Web Mapping Class for free using open source software.  The course materials are available at: through a creative commons license. You can also take the paid version of the online course for credit.  Coursework includes QGIS, GDAL, OGR, GeoServer, TileMill, Openlayers, and OpenStreetMap.  Penn State also has several map-related classes on Coursera.

Coursera has at least six relevant classes to GIS, GPS, and more during this upcoming fall 2014 and winter 2015 sessions.  Please note some of the courses do offer different tracts that range from basic to technical in difficulty.  This fall and winter there are exciting course offerings!

One course is on Geodesign
Another is on GPS, mapping, and spatial computing
Also don't forget, ESRI does have some free and low cost tutorials for ArcGIS on their training page as well:  Be sure to checkout Directions Magazine's articles and webinars for other opportunities.

If anyone else has any that they would like to share, feel free to write them in the comments section below!

Update #1:  Noteworthy addition:  ESRI is offering a free MOOC or massive open online course entitled "Going Places with Spatial Analysis".  Head over to the link below to signup for notification when registration begins, which is shortly: Going Places Signup / Start Page

Thursday, August 14, 2014

Image Processing Using Orfeo Toolbox in QGIS

Satellite and aerial images are more than pretty pictures.  Each image contains a wealth of data that can be queried, modified, extracted, and visualized through simple and advanced techniques.  This blog entry will cover a few basic tools in the Orfeo Toolbox in QGIS.  Instructions for installing Orfeo Toolbox in the QGIS processing toolbox can be found be clicking here.  There is also a standalone Monteverdi 2 program.

Quick Background on Orfeo Toolbox
The toolbox, often abbreviated OTB, was created to promote the use of several French satellites.  Like many programs, the algorithms are geared towards popular satellites.  For more on its creation, visit:

After following the instructions above, go under "Processing" and make sure the "Toolbox" is selected. You will see Orfeo's tools grouped into what types of functions they perform.

Screenshot of Orfeo Toolbox in QGIS's Processing Toolbox
Feature Extraction, Identification, and Classification
Extracting features from imagery is an extremely powerful tool.  For example, roads can be extracted from imagery.  Edges of images and line segments can be detected.  They can a provide a quick unique source of data for areas large and small.  Click on any of the images below to get a closer look.

Extracted edges of buildings at a college campus.

Line segment detection: In this case the lines of a tennis court (and fencing).
The tan lines are generated by the software.
Line segments differentiating a road, sidewalk, and  nearby grass.
Images can also be searched for specific objects. to automate their discovery. Image classification, groupings based on spectral characteristics, whether supervised or unsupervised, is another post in itself.

Change Detection
Another important aspect of imagery is detecting changes over time, whether something is new, absent, modified, or (re)moved.

Left: Unpainted roof, Center: Roof painted red, Right: Change Detection of Roof
Remote sensing and image processing are technical fields.  There is a significant amount of documentation (hundreds of pages) on the Orfeo Toolbox website. A shortened manual and a series of short practical exercises could help to expand its user base.  If you work in remote sensing and image processing, be sure to check out this fantastic resource!

Tuesday, August 5, 2014

OpenJUMP for Editing Geometry and Attribute Data

OpenJUMP is a neat little program for editing geometry and attribute data in GIS-related files.  It is free and open source, its project source code can be downloaded.  A full list of its features can be found here. Anyone that has gotten deep into a GIS project knows that inevitably attribute or geometry data will need be edited.  

OpenJUMP can be installed on Windows, Mac OSX, or Linux.  Instructions for installation are found on the project's wiki:

After installing and opening the program, you will find a neat and organized interface.  Setting up workspaces/a project space is easy and smooth, unlike other programs that I have used.  There is a very nice and functional menu bar at the top.  Buttons below provide for basic functions that are common in GIS-related programs.

You will find a lot of functionality in the "Tools", "Rasters"," and Plugins on the top navigation bar.  For example, in Tools you will be able to:
  • Do spatial and attribute queries
  • Proximity/buffer analysis
  • Create statistics about the layer and featurs
  • Generate grids,etc.
  • Perform quality assurance (QA)
  • Edit geometry data
  • Edit attribute data
Also, right-clicking on a loaded layer, will also bring up a wide variety of actions to be performed.

First, our map.  Below is a map of shapefiles loaded in OpenJUMP for Cornell University's campus buildings and a shapefile of trees from an inventory in 2012. Click any of the images below to see them in a larger version.

Cornell University Campus and Tree Inventory.
Editing Attribute Data

Below is a screenshot of the attribute table in OpenJUMP.  Right-click in the table, and selecting "Editable" allows users to edit attribute data and also brings up an additional Editing Toolbar for editing geometry.

An attribute table for our tree inventory file.
Editing Geometry Data

At right: the Editing Geometry toolbar.
Editing geometry toolbar includes the ability to:

  •  Select features, parts, and linestrings
  • Draw rectangle, polygon, linestring, and points
  • Invert, delete, or move a vertex
  • Scale selected items 
  • Snap vertices, snap vertices to selected vertex, split lines, node lines
  • ...and about 12 other actions

So, let's say I wanted to edit a building.  I would right-click on the shapefile and click "Editable" and then make the change, say using the delete vertex tool.  Your cursor becomes a small red x and pulsates/sends a ping to let you know that the action has been completed.

Lastly, a quick word about using the Feature Info Tool / identify tool.  With it, you have several different ways to display information about select features.  The screens below show information for a tree shapefile.

The Feature Info Tool allows you to view attribute and/or geometry data
with a few clicks of a button, it can be viewed in different formats.
OpenJUMP has a lot of interesting features, including exporting images as scaleable vector graphs or *.svg. Be sure to check out OpenJUMP at: