Intro eVis

download Intro eVis

of 13

Transcript of Intro eVis

  • 8/6/2019 Intro eVis

    1/13

    Intro to eVis: the event visualization tool

    Background

    The Remote Sensing/Geographic Information Systems (RS/GIS) Facility of the Center forBiodiversity and Conservation (CBC) at the American Museum of Natural History (AMNH) hasdeveloped a software tool, eVis, to add to the suite of conservation monitoring and decisionsupport tools for guiding protected area and landscape planning.

    The eVis software tool is a plugin that extends the capability of Quantum GIS (QGIS -http://qgis.org/), a free, open-source geospatial software program. This extension will allowprotected-area managers and other conservation practitioners to easily link and visualizelocation-based data (such as wildlife observations, illegal logging events, camera trap results,

    photographs, and similar data) to a mapping environment.eVis provides a common system to visualize and interpret location-based (i.e., referenced withlatitude and longitude coordinates) data. Using the user-friendly QGIS and eVis map interface,managers will be able to quickly visualize the distribution of their data on a map and developmanagement strategies to address changing conditions on the ground. For example, with eVis,Village Protection Teams (established at Song Thanh Nature Reserve with the aid of WWFMOSAIC) will be able to visualize the distribution of illegal activities, such as logging, hunting,and gold mining, and compare these records with existing GIS layers and satellite imagery. Byupdating and analyzing these records systematically, managers can use the enforcement data tocreate strategies for effective and efficient patrolling. With eVis, managers can also readily

    examine and combine wildlife observations from monitoring transects and camera traps tounderstand wildlife distribution and assess changes to their distribution over time.

    This exercise will serve as an introduction to the eVis software tool. For further information onusing QGIS, see the accompanying Intro to Quantum GIS exercise. eVis has the ability toconnect directly to MYSQL and SQLITE databases and can connect to any ODBC data resource.eVis also has an event browser that can display images and associated attribute data for features.For this exercise, we will be using a set of sample data from Central Vietnam (Thua Thien Hueand Quang Nam Provinces).

    The data for this exercise can be found in the zipped file called Workshop.zip. For MS windows

    users, unzip this file to the C:\ drive, so that the directory reads C:\Workshop. This directory willbe noted throughout the exercise as . For users following this exercise inanother operating system (OS X, Linux, etc.) note where the workshop directory is has beenunzipped, and follow from there. Also, be aware that the MS Excel Connection section onlyincludes instructions for windows XP users, as it shows the steps necessary to create an ODBCconnection in this operating system. This type of connection is possible in other operatingsystems, but this exercise does not yet provide these instructions. If you are unfamiliar with thisoperation, skip this section, and continue with the Relational Database connection section.

  • 8/6/2019 Intro eVis

    2/13

    Getting Started

    1. Start QGIS and add the 2003_Landsat_etm_subset.tifraster layer from \GIS_Data\Raster directory, where is the path to thedirectory 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 MSWindows, the directory would be: C:\Workshop\GIS_Data\Raster.

    2. Select Plugins -> Plugin Manager from the drop down menu to access the pluginmanager menu.

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

    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 themovable 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

  • 8/6/2019 Intro eVis

    3/13

    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 attributedata associated with the point features.

    In order to view photos in eVis, an attribute field containing the path and file name is alsoneeded. The path can be absolute or relative, or can also be a web URL (http://). A bearingattribute may be used to indicate the direction the photo was taken. Examples of the threeformats are:

    Absolute photo path:

    X Y FILE BEARING

    780596 1784017 C:\Workshop\eVis_Data\groundphotos\DSC_0168.JPG 275

    780596 1784017 C:\Workshop\eVis_Data\groundphotos\DSC_0169.JPG 80

    780819 1784015 C:\Workshop\eVis_Data\groundphotos\DSC_0170.JPG 10

    780819 1784015 C:\Workshop\eVis_Data\groundphotos\DSC_0171.JPG 350

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

    Relative photo path:

    X Y FILE BEARING

    780596 1784017 \groundphotos\DSC_0168.JPG 275

    780596 1784017 \groundphotos\DSC_0169.JPG 80

    780819 1784015 \groundphotos\DSC_0170.JPG 10

    780819 1784015 \groundphotos\DSC_0171.JPG 350Using relative paths, the files can be located in any directory, as long as the photographs or thedirectory containing the photographs, groundphotos in this example, are in the same

    directory as the data layer.

    URL photo path:

    X Y FILE BEARING

    780596 1784017 http://geospatial.amnh.org/groundphotos/DSC_0168.JPG 275

    780596 1784017 http://geospatial.amnh.org/groundphotos/DSC_0169.JPG 80

    780819 1784015 http://geospatial.amnh.org/groundphotos/DSC_0170.JPG 10

    780819 1784015 http://geospatial.amnh.org/groundphotos/DSC_0171.JPG 350

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

    For this example, add the PhotoPoints.shp layer from the \eVis_Data\directory to QGIS using the Add Vector Layer dialog. *Note, NonWindows users, choosePhoto_Points_relative.shp as the absolute path is mapped for Windows users.

  • 8/6/2019 Intro eVis

    4/13

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

    button to open the tool.

    2. Select FILE in theField Containing Path to Image drop down menu. If using theRelative shapefile, check thePath is Relative option. The first point feature photo willautomatically be displayed in the viewer window. The buttons above the photo can be

    used to change the zoom level of the photo. The text box at the top displays all of theattribute info associated with the point location, and the andbuttons can be used to scroll through the points. The point the active point being viewedis 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 browsers title bar.

    3. If the database contains a field for bearing, the direction the camera was pointing whenthe photo was taken, click theDisplay compass bearingradio button, and set the field to

    Bearing. The red star is replaced by an arrow showing the direction the camera waspointing.

    4. Browse through several photos to examine what can be seen in the photo, and what canbe seen in the satellite image.

    5. In order to view the photo or photos for a point on the map use the Event ID tool.Activate the tool by clicking the Event ID button, and then click on any of the photo

    points on the map. This will open an Event Browser displaying the photo or photos forthe selected location. In areas where several photos have been taken in different

  • 8/6/2019 Intro eVis

    5/13

    directions from a single location, using the Event ID tool will select all of the entries forthat location, which can be seen in the Displaying records text in the browsers titlebar.

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

    Database Connectivity

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

    MS Excel connection

  • 8/6/2019 Intro eVis

    6/13

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

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

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

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

    window.

  • 8/6/2019 Intro eVis

    7/13

    4. In the ODBC Microsoft Excel Setup window, enterPhotoPoint_excel into theDataSource Name field, and click the button which opens the Select

    Workbookdialogue.

    5. In the Select Workbookdialogue, choose \eVis_Data\PhotoPoints.xls and click the button in all three

    windows to complete the ODBC definition.

  • 8/6/2019 Intro eVis

    8/13

    6. Once the Windows definition has been established, open QGIS, and click the DatabaseConnection Icon buttonin eVis to open the database connection window. There are

    three tabs available in this window:Database Connection (opens by default),PredefinedQueries, 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 downmenu. The available options are: Undefined, MSAccess, MYSQL, ODBC, and SQLITE.Choose ODBCto directly connect to the excel database file that we have defined. Typelocalhostin the Database Host field, andPhotoPoint_excel in the Database Name field,as seen below.

  • 8/6/2019 Intro eVis

    9/13

    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 theuse of SQL queries. SQL is a standard language for querying databases. For those interested in

    more information on SQL, there is a helpful tutorial athttp://www.w3schools.com/sql/. Tobegin, we will run a simple SQL query statement that will access all of the data in the Accessdatabase, 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 thequery building window.

    http://www.w3schools.com/sql/http://www.w3schools.com/sql/http://www.w3schools.com/sql/http://www.w3schools.com/sql/
  • 8/6/2019 Intro eVis

    10/13

    2. In the text box, typeSELECT * FROM [PhotoPoints$]. The * symbol is used to chooseall of the fields in the table, and [PhotoPoints$] is the name of the worksheet in the exceltable that we are querying.

    3. Click the button to run the query.

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

    Relational Database connection

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

  • 8/6/2019 Intro eVis

    11/13

    Note that there is a many-to-one relationship between thepoint_idfield in the Attributes table,

    and the rec_idfield 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, theresult 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.2. In theDatabase Connection tab, define the database type by choosing SQLITE then

    click the Open File button and choose PhotoPoints.db from the \eVis_Data\ directory, and click the button as seen below.

  • 8/6/2019 Intro eVis

    12/13

    3. Open the SQL Query tab4. 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 photos available in the database.

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

    Running a predefined query

    In addition to manually connecting to a database and entering an SQL statement, the eVisDatabase Connection tool has the ability to load predefined queries that are stored in an xmlfile. 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

    \eVis_Data\ directory. Right click on the file, and (in Windows) chooseOpen With -> Notepad. There are three predefined queries in this file, all located betweenthe and tags. And each query is between the and tags. Notethat the information needed to set a database connection and query between each descriptor tag.These can be edited, or more examples can be added. * Note that the 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 ifthe files are residing in a different directory than the one noted.

  • 8/6/2019 Intro eVis

    13/13

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

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

    3. In this sample file, three queries have been defined, that can be accessed from the drop

    down menu. A description of each can be seen in the text box. The xml file can bemanipulated 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 photos

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

    photos that mention "limestone"4. Choose Import photo points "looking across Valley", and then click theDatabase

    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 forthe new layer in the Database File Selection dialog. The resulting point layer willconsist only of points that have looking across a valley in the comment field. Thisquery method can be used to select points with any type of identifier, such as species,township, violation type, etc.