Introduction to eVis: the event visualization tool · Introduction to eVis: the event visualization...

15
Introduction to eVis: the event visualization tool Intro to eVis: the event visualization tool Background The Biodiversity Informatics Facility of the Center for Biodiversity and Conservation (CBC) at the American Museum of Natural History (AMNH) developed the Event Visualization Tool (eVis), as a conservation monitoring and decision support tool for guiding protected area and landscape planning. Since July 2009, eVis has been part of the official QGIS distribution. The eVis software tool is a “plugin” that extends the capability of Quantum GIS (QGIS - http://qgis.org/), a free, open-source desktop geographic information system. Users of eVis can link and visualize location-based data (e.g., wildlife observations, images documenting illegal logging, camera trap results, etc.) to a mapping environment. This exercise will serve as an introduction to the eVis plugin. eVis has the ability to connect directly to MYSQL and SQLITE databases and can connect to any ODBC data resource. eVis has an event browser that can display images and associated attribute data for vector features. For this exercise, we will be using a set of sample data from Central Vietnam (Thua Thien Hue and Quang Nam Provinces). This exercise was developed for QGIS version 1.0.2, on the Windows platform. The data for this exercise can be found in the zipped file called Workshop.zip. MS windows users, unzip this file to the C:\ drive, so that the directory reads C:\Workshop. This directory will be noted throughout the exercise as <workshop directory>. For users following this exercise in another operating system (OS X, Linux, etc.) note where the workshop directory has been unzipped on your system. Also, be aware that the MS Excel Connection section only includes instructions for windows XP users, as it shows the steps necessary to create an ODBC connection in this operating system. This type of connection is possible in other operating systems, but this exercise does not provide these specific instructions. If you are unfamiliar with this operation, skip this section, and continue with the Relational Database connection section. Biodiversity Informatics Facility Center for Biodiversity and Conservation American Museum of Natural History

Transcript of Introduction to eVis: the event visualization tool · Introduction to eVis: the event visualization...

Page 1: Introduction to eVis: the event visualization tool · Introduction to eVis: the event visualization tool 2. Click on the System DSN tab at the top of the window, and click the button.

Introduction to eVis: the event visualization tool

Intro to eVis: the event visualization tool

Background

The Biodiversity Informatics Facility of the Center for Biodiversity and Conservation (CBC) at the American Museum of Natural History (AMNH) developed the Event Visualization Tool (eVis), as a conservation monitoring and decision support tool for guiding protected area and landscape planning. Since July 2009, eVis has been part of the official QGIS distribution.

The eVis software tool is a “plugin” that extends the capability of Quantum GIS (QGIS - http://qgis.org/), a free, open-source desktop geographic information system. Users of eVis can link and visualize location-based data (e.g., wildlife observations, images documenting illegal logging, camera trap results, etc.) to a mapping environment.

This exercise will serve as an introduction to the eVis plugin. eVis has the ability to connect directly to MYSQL and SQLITE databases and can connect to any ODBC data resource. eVis has an event browser that can display images and associated attribute data for vector features. For this exercise, we will be using a set of sample data from Central Vietnam (Thua Thien Hue and Quang Nam Provinces). This exercise was developed for QGIS version 1.0.2, on the Windows platform.

The data for this exercise can be found in the zipped file called Workshop.zip. MS windows users, unzip this file to the C:\ drive, so that the directory reads C:\Workshop. This directory will be noted throughout the exercise as <workshop directory>. For users following this exercise in another operating system (OS X, Linux, etc.) note where the workshop directory has been unzipped on your system. Also, be aware that the MS Excel Connection section only includes instructions for windows XP users, as it shows the steps necessary to create an ODBC connection in this operating system. This type of connection is possible in other operating systems, but this exercise does not provide these specific instructions. If you are unfamiliar with this operation, skip this section, and continue with the Relational Database connection section.

Biodiversity Informatics Facility – Center for Biodiversity and Conservation – American Museum of Natural History

Page 2: Introduction to eVis: the event visualization tool · Introduction to eVis: the event visualization tool 2. Click on the System DSN tab at the top of the window, and click the button.

Introduction to eVis: the event visualization tool

License and citation information:

This exercise is licensed under a Creative Commons Attribution-Share Alike 3.0 License. You are free to alter the work, copy, distribute, and transmit the document under the following conditions (see http://creativecommons.org/licenses/by-sa/3.0/us/ for more details):

• You must attribute the work in the manner specified by the author or licensor (but not in any way that suggests that they endorse you or your use of the work).

• If you alter, transform, or build upon this work, you may distribute the resulting work only under the same, similar or a compatible license.

If you cite this document we ask that you include the following information:

Horning, N., K. Koy, P. Ersts. 2009. Intro to eVis: the event visualization tool. American Museum of Natural History, Center for Biodiversity and Conservation. Available from http://biodiversityinformatics.amnh.org/. (accessed on today’s date).

Biodiversity Informatics Facility – Center for Biodiversity and Conservation – American Museum of Natural History

Page 3: Introduction to eVis: the event visualization tool · Introduction to eVis: the event visualization tool 2. Click on the System DSN tab at the top of the window, and click the button.

Introduction to eVis: the event visualization tool

Getting Started

1. Start QGIS and add the 2003_Landsat_etm_subset.tif raster layer from <workshop directory>\GIS_Data\Raster directory, where <workshop directory> is the path to the directory where you installed the data for this workshop. This image will serve as the backdrop for this visualization exercise. * For example, on a computer running MS Windows, the directory would be: C:\Workshop\GIS_Data\Raster.

2. Select Plugins -> Plugin Manager… from the drop down menu to access the plugin manager menu.

3. In the menu, check the eVis Plugin, and click to activate eVis.

Biodiversity Informatics Facility – Center for Biodiversity and Conservation – American Museum of Natural History

Page 4: Introduction to eVis: the event visualization tool · Introduction to eVis: the event visualization tool 2. Click on the System DSN tab at the top of the window, and click the button.

Introduction to eVis: the event visualization tool

4. Activating the eVis plugin adds three new buttons to the QGIS toolbar. Any of the toolbars can be moved by clicking and holding left mouse button on the left side of the movable panel. The three eVis buttons are:

Database Connection Opens the Database connection menu window

Event ID Tool Activates the Event ID tool for interaction with the map

Event Browser Opens the Event Browser window.

Using the event browser

To begin using the event browser, we will use sample data stored in a shapefile vector layer. Once a vector data layer is loaded into QGIS, the event browser can be used to view the attribute data associated with the point features.

In order to view images in eVis, an attribute field containing the path and file name is also needed. The path can be absolute or relative, or can also be a web URL (http://). A bearing attribute may be used to indicate the direction the image was taken. Examples of the three formats are:

Absolute image path:

X Y FILE BEARING780596 1784017 C:\Workshop\eVis_Data\groundphotos\DSC_0168.JPG 275780596 1784017 C:\Workshop\eVis_Data\groundphotos\DSC_0169.JPG 80780819 1784015 C:\Workshop\eVis_Data\groundphotos\DSC_0170.JPG 10780819 1784015 C:\Workshop\eVis_Data\groundphotos\DSC_0171.JPG 350

In this example, the images must reside in the C:\Workshop\eVis_Data\groundphotos\ directory.

Relative image path:

X Y FILE BEARING780596 1784017 \groundphotos\DSC_0168.JPG 275780596 1784017 \groundphotos\DSC_0169.JPG 80780819 1784015 \groundphotos\DSC_0170.JPG 10780819 1784015 \groundphotos\DSC_0171.JPG 350

Biodiversity Informatics Facility – Center for Biodiversity and Conservation – American Museum of Natural History

Page 5: Introduction to eVis: the event visualization tool · Introduction to eVis: the event visualization tool 2. Click on the System DSN tab at the top of the window, and click the button.

Introduction to eVis: the event visualization tool

Using relative paths, the files can be located in any directory, as long as the images or the directory containing the images, “groundphotos” in this example, are in the same directory as the data layer.

URL image path:

X Y FILE BEARING780596 1784017 http://your.web.server/groundphotos/DSC_0168.JPG 275780596 1784017 http://your.web.server/groundphotos/DSC_0169.JPG 80780819 1784015 http://your.web.server/groundphotos/DSC_0170.JPG 10780819 1784015 http://your.web.server/groundphotos/DSC_0171.JPG 350

Using URL paths, eVis can connect to images that are available on a web server.

For this example, add the PhotoPoints.shp layer from the <workshop directory>\eVis_Data\ directory to QGIS using the Add Vector Layer dialog. *Note, Non-Windows users, choose Photo_Points_relative.shp since the absolute path is mapped for Windows users.

1. Make sure that your point layer is highlighted in the TOC, and click the Event Browser

button. If the default settings are set an image will appear in the display window. If an image is not displayed we will adjust the options so an image is displayed.

2. Click on the “Options” tab at the top of the Event Browser window is selected. Select “FILE” in the Attribute Containing Path to File drop down menu. If the Relative shapefile was input at the start of this exercise, check the Path is Relative option otherwise this checkbox should be empty. To see the image click on the “Display” tab. The first point feature image will be displayed in the viewer window. The buttons above the image can be used to change the zoom level of the image. The text box at the top displays all of the attribute info associated with the point location, and the

and buttons can be used to scroll through the points. The active point being

viewed is centered, and noted with a symbol. Also note that the total number of records and the number of the active record are displayed in the browser’s title bar.

Biodiversity Informatics Facility – Center for Biodiversity and Conservation – American Museum of Natural History

Page 6: Introduction to eVis: the event visualization tool · Introduction to eVis: the event visualization tool 2. Click on the System DSN tab at the top of the window, and click the button.

Introduction to eVis: the event visualization tool

3. If the vector layer contains a field (i.e., an attribute) for bearing, the direction the camera was pointing when the image was taken, click the “Options” tab and then click the Display Compass Bearing radio button, and set the field to Bearing. The red star is replaced by an arrow showing the direction the camera was pointing. The compass bearings in this file are relative to true north but if you wanted to adjust for bearings that are recorded relative to magnetic north you can enter the declination using the radio buttons under “Compass Offset”. East declinations should be entered using positive values and west declinations should use negative values.

4. Click on the “Display” tab again then browse through several images using the

and buttons to examine what can be seen in the image, and what

can be seen in the satellite image. You can then close the Event Browser window.

5. In order to view the image or images for a single point on the map use the Event ID tool. Activate the tool by clicking the Event ID button in the QGIS toolbar, and then click on any feature on the map. This will open an Event Browser displaying the image or images for the selected location. In areas where several images have been taken in different directions from a single location, using the Event ID tool will select all of the entries for that location, which can be seen in the “Displaying records” text in the browser’s title bar.

6. Scroll through the selected images in the browser to examine the records for that location, and then close the browser to select a different location.

Biodiversity Informatics Facility – Center for Biodiversity and Conservation – American Museum of Natural History

Page 7: Introduction to eVis: the event visualization tool · Introduction to eVis: the event visualization tool 2. Click on the System DSN tab at the top of the window, and click the button.

Introduction to eVis: the event visualization tool

Database Connectivity

In addition to vector data layers, eVis can be used to explore and visualize data, from one or more external databases. The minimum fields/attributes that are required to use eVis are an X and Y location. There are many different types of databases that eVis can be connected to. In this example, we will go through the steps to connect to and query from both a single table stored as a MS Excel file and a multiple table relational database stored in SQLite.

MS Excel connection

We will start by connecting to an MS Excel table. In order to establish this connection there are first a few steps that need to be taken in Windows to create an ODBC data source. If you are using a different operation system, please skip ahead to the Relational Database connection section.

For MS Windows XP only

1. To set up the ODBC data source for an Excel file, go to the Windows Administrative Tools. This menu can be accessed by clicking Start -> Control Panel -> Performance and Maintenance in the windows desktop, (also may be Start->Control Panel -> Administrative Tools depending on your settings). Within the Administrative Tools menu, double-click the Data Sources (ODBC) shortcut. This will open the ODBC Data Source Administrator.

Biodiversity Informatics Facility – Center for Biodiversity and Conservation – American Museum of Natural History

Page 8: Introduction to eVis: the event visualization tool · Introduction to eVis: the event visualization tool 2. Click on the System DSN tab at the top of the window, and click the button.

Introduction to eVis: the event visualization tool

2. Click on the System DSN tab at the top of the window, and click the button.

3. Then, in the Create New Data Source window that opens, choose Driver do Microsoft Excel(*.xls), and click . This will open the ODBC Microsoft Excel Setup

window.

4. In the ODBC Microsoft Excel Setup window, enter PhotoPoint_excel into the Data Source Name field, and click the button which opens the Select

Workbook dialogue.

Biodiversity Informatics Facility – Center for Biodiversity and Conservation – American Museum of Natural History

Page 9: Introduction to eVis: the event visualization tool · Introduction to eVis: the event visualization tool 2. Click on the System DSN tab at the top of the window, and click the button.

Introduction to eVis: the event visualization tool

5. In the Select Workbook dialogue, choose:

<workshop directory>\eVis_Data\PhotoPoints.xls

Then click the button in all three windows to complete the ODBC definition.

6. Once the Windows definition has been established, open QGIS, and click the Database Connection Icon button in eVis to open the database connection window. There are three tabs available in this window: Database Connection (opens by default), Predefined Queries, and SQL Query. An Output Console displays status and error messages.

7. In the Database Connection tab, define the database under the Database Type drop down menu. The available options are: Undefined, MSAccess, MYSQL, ODBC, and SQLITE. Choose ODBC to directly connect to the Excel database file that we have defined. Type localhost in the Database Host field, and PhotoPoint_excel in the Database Name field, as seen below.

Biodiversity Informatics Facility – Center for Biodiversity and Conservation – American Museum of Natural History

Page 10: Introduction to eVis: the event visualization tool · Introduction to eVis: the event visualization tool 2. Click on the System DSN tab at the top of the window, and click the button.

Introduction to eVis: the event visualization tool

8. Click the button. A message should appear displaying that the connection has been established.

SQL Query

Once a database connection has been established, data can be imported into QGIS through the use of SQL queries. SQL is a standard language for querying databases. For those interested in more information on SQL, there is a helpful tutorial at http://www.w3schools.com/sql/. To begin, we will run a simple SQL query statement that will access all of the data in the Excel file, and import it into QGIS as a point file.

1. Click on the SQL Query tab of the Database Connection module of eVis to access the query building window.

2. In the text box, type SELECT * FROM [PhotoPoints$]. The * symbol is used to choose all of the fields in the table, and [PhotoPoints$] is the name of the worksheet in the Excel table that we are querying.

3. Click the button to run the query.

Biodiversity Informatics Facility – Center for Biodiversity and Conservation – American Museum of Natural History

Page 11: Introduction to eVis: the event visualization tool · Introduction to eVis: the event visualization tool 2. Click on the System DSN tab at the top of the window, and click the button.

Introduction to eVis: the event visualization tool

4. A successful Select query opens the Database File Selection window. Enter a name for the new layer, such as PhotoPoints, and choose the correct fields for the X and Y coordinates. Click to import the data into a point layer in the QGIS map. You

will be asked to enter the map project for the new layer. You can enter WGS84 (EPSG number 4326).

Relational Database connection

In the next example, we will use the eVis Database Connection module to connect to a relational database with multiple tables using an SQLite database. Storing data in this format has the advantage of creating relationships between tables. In the example that we will use, there are two tables in our SQLite database, one containing ten point locations that were visited, and the second containing the details of 61 images taken at these locations. A graphical representation of these two tables and their relationship follows:

Biodiversity Informatics Facility – Center for Biodiversity and Conservation – American Museum of Natural History

Page 12: Introduction to eVis: the event visualization tool · Introduction to eVis: the event visualization tool 2. Click on the System DSN tab at the top of the window, and click the button.

Introduction to eVis: the event visualization tool

Note that there is a many-to-one relationship between the point_id field in the Attributes table, and the rec_id field in the Points table. In order to make these data useful in a GIS environment, we can use an SQL query to join the tables based on the key fields. After joining the tables, the result looks like:

To begin importing data from this database:

1. Open QGIS, and click the Database Connection button in eVis to open the Database Connection module.

Biodiversity Informatics Facility – Center for Biodiversity and Conservation – American Museum of Natural History

Page 13: Introduction to eVis: the event visualization tool · Introduction to eVis: the event visualization tool 2. Click on the System DSN tab at the top of the window, and click the button.

Introduction to eVis: the event visualization tool

2. In the Database Connection tab, define the database type by choosing SQLITE then click the Open File button and choose PhotoPoints.db from the <workshop directory>\eVis_Data\ directory, and click the button as seen below.

3. Open the SQL Query tab

4. In the text box, type:

SELECT Attributes.*, Points.x, Points.y FROM Attributes LEFT JOIN Points ON Points.rec_id=Attributes.point_ID

This query will import all of the points and images available in the database.

5. Click the button to run the query. After entering a name “PhotoPoints_db” for the new layer, and noting the x and y locations, then click “OK”. The new point file will be available in the map for use with the Event Browser.

6.

Biodiversity Informatics Facility – Center for Biodiversity and Conservation – American Museum of Natural History

Page 14: Introduction to eVis: the event visualization tool · Introduction to eVis: the event visualization tool 2. Click on the System DSN tab at the top of the window, and click the button.

Introduction to eVis: the event visualization tool

Running a predefined query

In addition to manually connecting to a database and entering an SQL statement, the eVis Database Connection tool has the ability to load predefined queries that are stored in an xml file. Use of these predefined files makes it easier to store and retrieve complex queries.

Open and examine the predefined_sqlite.xml file in a text editor by navigating to the <workshop directory>\eVis_Data\ directory. Right click on the file, and (in Windows) choose Open With… -> Notepad. There are three predefined queries in this file, all located between the <doc> and </doc> tags. And each query is between the <query> and </query> tags. Note that the information needed to set a database connection and query between each descriptor tag. These can be edited, or more <query> </query> examples can be added. * Note that the <databasename> tag is set to a Windows directory, to use this file in another operating system, be sure to adjust this path to the appropriate directory. This entry will also need to be updated if the files are residing in a different directory than the one noted.

1. To begin importing data using a predefined query, open the Database Connection module (if it is already open, close it and open again to reset) and click on the Predefined Queries tab.

2. Click the Open File button and load predefined_sqlite.xml in the <workshop directory>\eVis_Data directory as seen below.

Biodiversity Informatics Facility – Center for Biodiversity and Conservation – American Museum of Natural History

Page 15: Introduction to eVis: the event visualization tool · Introduction to eVis: the event visualization tool 2. Click on the System DSN tab at the top of the window, and click the button.

Introduction to eVis: the event visualization tool

3. In this sample file, three queries have been defined, that can be accessed from the drop down menu just under the Open File button. A description of each can be seen in the text box. The xml file can be manipulated in a text editor to create new queries, or edit the existing queries.

The three queries are:

a. Import all photo points: imports all data in a table to QGISb. Import photo points "looking across Valley": imports only points that have

images "looking across a valley"c. Import photo points that mention "limestone": imports only points that have

images that mention "limestone"

4. Choose Import photo points "looking across Valley", and then click the Database Connection tab. Notice that the fields are automatically filled out and the file selected. Click on the “Connect” button to connect to the database.

5. Click the SQL Query tab. Notice that the query statement has already been entered.

6. Click the button to run the selected query, 7. If the query is successful, and enter a name “ValleyPhotos” and select the x, y fields for

the new layer in the Database File Selection dialog. The resulting point layer will consist only of points that have “looking across a valley” in the comment field. This query method can be used to select points with any type of identifier, such as “species”, “township”, violation type”, etc.

Biodiversity Informatics Facility – Center for Biodiversity and Conservation – American Museum of Natural History