Você está na página 1de 13

Intro to eVis: the event visualization tool

Background
The Remote Sensing/Geographic Information Systems (RS/GIS) Facility of the Center for Biodiversity and Conservation (CBC) at the American Museum of Natural History (AMNH) has developed a software tool, eVis, to add to the suite of conservation monitoring and decision support 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 allow protected-area managers and other conservation practitioners to easily link and visualize location-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 with latitude 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 develop management 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 WWF MOSAIC) 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. By updating and analyzing these records systematically, managers can use the enforcement data to create strategies for effective and efficient patrolling. With eVis, managers can also readily examine and combine wildlife observations from monitoring transects and camera traps to understand 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 on using QGIS, see the accompanying Intro to Quantum GIS exercise. eVis has the ability to connect 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 Hue and 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 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 is has been unzipped, and follow from there. 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 yet provide these instructions. If you are unfamiliar with this operation, skip this section, and continue with the Relational Database connection section.

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.

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 Event ID Tool Opens the Database connection menu window 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 photos 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 photo was taken. Examples of the three formats are: Absolute photo path:
X 780596 780596 780819 780819 Y 1784017 1784017 1784015 1784015 FILE BEARING C:\Workshop\eVis_Data\groundphotos\DSC_0168.JPG 275 C:\Workshop\eVis_Data\groundphotos\DSC_0169.JPG 80 C:\Workshop\eVis_Data\groundphotos\DSC_0170.JPG 10 C:\Workshop\eVis_Data\groundphotos\DSC_0171.JPG 350 photos must reside in the C:\Workshop\eVis_Data\groundphotos\ directory.

In this example, the

Relative photo path:


X 780596 780596 780819 780819 Y 1784017 1784017 1784015 1784015 FILE \groundphotos\DSC_0168.JPG \groundphotos\DSC_0169.JPG \groundphotos\DSC_0170.JPG \groundphotos\DSC_0171.JPG BEARING 275 80 10 350

Using relative paths, the files can be located in any directory, as long as the photographs or the directory containing the photographs, groundphotos in this example, are in the same directory as the data layer. URL photo path:
X 780596 780596 780819 780819 Y 1784017 1784017 1784015 1784015 FILE http://geospatial.amnh.org/groundphotos/DSC_0168.JPG http://geospatial.amnh.org/groundphotos/DSC_0169.JPG http://geospatial.amnh.org/groundphotos/DSC_0170.JPG http://geospatial.amnh.org/groundphotos/DSC_0171.JPG BEARING 275 80 10 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 <workshop directory>\eVis_Data\ directory to QGIS using the Add Vector Layer dialog. *Note, NonWindows users, choose Photo_Points_relative.shp as 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 to open the tool. 2. Select FILE in the Field Containing Path to Image drop down menu. If using the Relative shapefile, check the Path is Relative option. The first point feature photo will automatically 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 the attribute info associated with the point location, and the and buttons can be used to scroll through the points. The point 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 browsers title bar.

3. If the database contains a field for bearing, the direction the camera was pointing when the photo was taken, 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. 4. Browse through several photos to examine what can be seen in the photo, and what can be 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 for the selected location. In areas where several photos 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 browsers title bar.

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 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 in MS excel 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) 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.

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.

5. In the Select Workbook dialogue, choose <workshop directory>\eVis_Data\PhotoPoints.xls and click the windows to complete the ODBC definition.

button in all three

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.

8. Click the been established. SQL Query

button. A message should appear displaying that the connection has

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 Access database, 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.

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. 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 photos taken at these locations. A graphical representation of these two tables, and their relationship follows:

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. 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 photos 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. 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 Query tab. 2. Click the Open File button and load predefined_sqlite.xml in the <workshop directory>\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 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 QGIS b. 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 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.

Você também pode gostar