Maps

If you have never used the Maps module

Plotting data on maps is a specialised area that is quite different from normal graphing. The article here tells you about the sorts of data that we can present using maps and ways in which we can use maps in constructing data visualisations.

The Maps module is not part of the initial installation of iNZight. It downloads and installs automatically the first time you try to launch it by going to the Advanced > Maps

Selecting data type

The iNZight Maps module can handle two types of data, Coordinate data and Regional data. The first step is to tell the program whether you have Coordinate data or Regional data.

Selecting the latitude and longitude

The program behaves differently depending on this choice. The documentation deals first with Coordinate data and then with Regional data.

The nzquakes data obtained available from File > Example data and selecting the Maps module is an example of coordinate data. The NSSATS data also available there, is an example of regional data (data about US states).

Geographical Co-ordinate Data

iNZight will try to guess the Latitude and Longitude variables automatically, but you will have to select them manually if they have nonstandard names.

Once you've selected those, click OK and iNZight will now plot your data on a map (it may take a little while for the underlying map to download)

Selecting the latitude and longitude

[This only works if you are connected to the internet because iNZight Maps downloads appropriate Stamen map tiles (via ggmap) to form the background of the plot]

Plot appearance can be changed and information about other variables added to the plot using the following controls.

  • Click on the + buttons to expand the option panels

Extra Plot Options:

iNZight Maps downloads appropriate Stamen map tiles (via ggmap) to make the background of the plot

Map-type: options are terrain (default - coloured terrain map with some features named), terrain-background (no added names), toner-lite (white map on grey background) and toner (white map on black background).

Overall point size (Slider): scale everything drawn on top of the plot/map to a chosen multiple of their current sizes (default =1)

Colour:

Either choose a ...
  Point colour: select a single colour to apply to all of the points
Or select the names of a ...
  Colour by variable to differentially colour points according the values of the chosen variable.

Additional options which appear once a Colour-by variable has been selected:

  • Palette for selecting a colour palette
  • Reverse palette (check-box): Reverse the way the values of the colour-by variable are mapped to colours (smallest-to-biggest/biggest-to-smallest)
  • Use percentiles (check-box): Apply the colour range according to the percentiles of the colour-by variable instead of its raw values.
  • Cycle levels (categorical colour-by variable): Clicking the arrow icons results in just the points from one category at a time being highlighted, with the others dimmed
  • Cycle quantiles (numeric colour-by variable): Behaves in the same way with just the points in a quantile being highlighted. By default just 4 quantiles are used (useful if the colour-by variable is highly skewed), but …
    • #quantiles allows you to change 4 to some other number of quantiles
  • Back cycle icon results in all of the points being highlighted again

Size:

Overall (slider): Multiply the current size of each point by value chosen (default value 1)

Size by: Select a variable to differentially size the points by (i.e., size according to the values of the chosen variable)

Additional option which appears once a Size-by variable has been selected:

  • Resize method: make the area of the point either proportional to the value of the size-by variable, or emphasize (map the smallest values to a hard-coded small point-size and the largest to a large size – sometimes useful when the ratio largest/smallest is not very big)

Transparency/Opacity:

Overall (slider): Adjust the transparency levels of all of the points uniformly (default value 0 = no change; maximum makes all points completely transparent)

Opacify by: (Opacity is the opposite of transparency) Select a variable to differentially set the opacity the points by (high values map to most visible, low to most transparent)

Additional option which appears once a Opacify-by variable has been selected:

  • Reverse opacification (check-box): Reverse the way the values of the opacify-by variable are mapped to opacity/transparency levels

Point Symbol:

Symbol: Select from circle, square, diamond, triangle and inverted triangle

Filled in symbols (check-box): Click to fill in all symbols

Symbol by: Can be done according to a categorical variable which has 5 or fewer categories

  • Symbol line width: Line-width multiplier

Connect Points:

Connect points with lines (check-box): Check the box to draw lines between points. Connected in the order they appear in the data file.
Additional options which then appear:
    ● Line colour (selection box);   ● Line width: (slider)

Sub-setting:

Works the same way as in the main part of iNZight, you can generate subsets by selecting a variable from either one or both of the subset menus.

Subset selection sliders and play buttons appear once a subset-by variable has been selected.

Interactive Coordinate Maps

Interactive plot icon When you click on the Interactive plot icon (immediately above), iNZight makes a temporary interactive html file and opens it using your default browser.

  • Interactive versions of the maps are not available when there is more than one map in the plotting window

To save a permanent file, click on the Save Plot icon, or go Plot > Save Plot.
Choose the interactive HTML as your file type.

These files work independently of iNZight



Data on Geographical Regions

US Map

In many cases, you might have data with regional information (where "region" can be countries, states, provinces, electorates, etc.).

iNZight allows you to display this information on a map of outlines, with each region coloured according to the value of a chosen variable. (Some alternative representations are also catered for.)

.... Selecting a Map

JUNK

Select Map

Choose either Use Inbuilt Map (default) to use one of the maps already in iNZight
  (choose from a selection of maps of Continents, several Countries, and World maps)
or Import Shapefile to start up a dialog for reading a shape file stored on your computer

Double clicking on a map name in the Use Inbuilt Map section will plot a preview of the map in the plotting area and display a brief description of the map.

Then click … Import Map

Select Variables

When a map has been imported, iNZight will also try to find a variable in your data file which best matches one of the region-naming variables on the map. It will display the names it has found beside Data variable and Map variable. Selection boxes allow you to select replacement variables for these two roles.

  • Selection boxes allow you to change the variables used for each of these two roles.

It will also draw the map. Regions for which data is present in the data set are shaded green.
Any Regions which have no data are shaded orange.

Variable matching and Unmatched data

Unmatched Data:
The names of any Regions in the data that are not represented in the map will be listed here once the map has been imported. You can decide to use the map anyway or exit maps and go back to your data to do something about the non-matching names.

Multiple observations for each region were found: (only appears when this is true)
This often happens when, for example, we have observations for a region for several different years with different years corresponding to different rows in the data set.
The module will then try to find a variable that "explains" the multiple observations. We call this a "sequence variable".

  • Select sequence variable: If an “explaining variable” is found its name will be displayed in the selection box. You have the freedom to change it

Use Map (Button): Click to tell the program "I want to use this map"

  • The program will then replace the map-selection command panel with a new command panel for plotting. An unshaded map with the appropriate boundaries will appear (as follows)

Initial appearance of Variables view

.... Plotting data on the Map

If you are using this module for the first time it is best to ignore the Map Options and Extra Plot Options paragraphs initially and see how the plotting of variables works. So that is what we are going to discuss next.

Select Variable/s to display

Click on the name of the desired variable and it will display on the map

PlotVariable

If you select several variables you will get a map plot for each of those variables …

Plot 2 Variables

Regions radio button gives shaded maps

Plotting shaded maps

Centroids radio button gives …

Plotting centroids

Additional options that become available when Centroids is turned on:
  Size by: (typically use a relevant population-size variable)
  Overall size (slider): makes the disks bigger or smaller uniformly
  Transparency of map (slider): transparency of map outlines

Map Options

Map Options

Current Map: Opportunity to change your mind and select a different map
Regional selection boxes: use to remove regions from the plotted map
Projection (dropdown list): Opportunity to change the map projection (default is the projection suggested by the shapefile)

Extra Plot Options:

Plot Title: change plot title
Palette: change colour palette
Check boxes: Dark (makes sea go dark), Grid Lines (use to add), Axis labels (use to add)
Map Scales: Choices for independent scales/same scale to be used across a set of plots
Font Size (slider): Region Labels (check box): add labels
Additional options that become available when Region Labels are turned on :
  Selection box for selecting variable to use for labelling
  Region label font size: (slider)

Dataset has multiple observations per region

(only appears when this is true)

Multple observations choices

  • Single value: display just the last value
    Additional options that become available when Single Value is chosen:
      Value of ... variable (slider) : choose value of the explaining variable (e.g. year)
      Play button and playback timer button: controls playing through the values/images
  • Aggregate: display an aggregate of the values (e.g. mean, median)
  • All Values: display mini time-series glyph ("sparklines") for each region
    Additional options that become available when All Values is chosen:
      Sparklines can be plotted for Absolute (the raw numbers), Relative (ratio to the first value), Percent Change (between successive observations)
      Overall size (slider) : controls size of the sparkline glyphs
      Transparency of map (slider): transparency of map outlines

All values and sparklines


Interactive Maps

Interactive plot icon When you click on the Interactive plot icon (immediately above), iNZight makes a temporary interactive html file and opens it using your default browser.

  • Interactive versions of the maps are not available when there is more than one map in the plotting window

To save a permanent file, click on the Save Plot icon, or go Plot > Save Plot.
Choose the interactive HTML as your file type.

These files work independently of iNZight


Shape files and importing shape files

Shapefiles are a method of storing geographical data for use in GIS (geographical information systems) or similar software. Despite the singular name, shapefiles are actually a collection of files that each correspond to a particular aspect of the data. Three files are mandatory:

  • The geometry of the data (polygons in our case) in a .shp file
  • An index of the geometries contained in the .shp file to allow software to know where each geometry is located within the file. This is contained in a .shx file.
  • Attributes for each geometry contained in the .shp file. These attributes can be any data and function similarly to a data frame where each row corresponds to a single geometry. These are stored in a .dbf file and can be inspected with Microsoft Excel.

Most shapefiles will have additional files containing other information such as map projections or indexes of the spatial distance between geometries. Shapefiles are typically stored in separate directories for each map, with all the files that make up the shapefile contained within a single directory. Shapefiles are generally distributed on the internet as archive files, e.g. ZIP files. Currently these have to be decompressed to use in iNZight.

  • In the Import Shape file dialog, open the .shp file in the relevant shapefile folder

Other shapefile-information file formats that can be used in iNZight are GeoJSON and TopoJSON files. These are a single file that stores much the same information as a shapefile by storing a geometry and set of properties for each feature in the dataset. GeoJSON can be used in most GIS software and is a standard format for web-based mapping technologies such as Leaflet. TopoJSON is a closely related format that includes topology and typically has file size that is smaller than GeoJSON as TopoJSON only stores one copy of any borders that are shared by two countries.

  • In the Import Shape file dialog, just open the relevant .GeoJSON or .TopoJSON file

***Coming (Daniels's notes):

  • Add ability to import zipped shape files as is
  • A newer, faster method of map simplification
  • A more integrated map selection interface where we download less common shapefiles on-demand, but still list them in a tree diagram
  • As an additional note, my current method of simplifying our “built-in” maps is to use a webpage that uses this method. Once I put it into a script, I can send it to you and we won’t need to jump between different software to add a map to your server (or perhaps more importantly, not rely on other services)