Complemento eVis

The Biodiversity Informatics Facility at the American Museum of Natural History’s (AMNH) Center for Biodiversity and Conservation (CBC) (this section is derived from Horning, N., K. Koy, P. Ersts. 2009. eVis (v1.1.0) User’s Guide. American Museum of Natural History, Center for Biodiversity and Conservation. Available from http://biodiversityinformatics.amnh.org/, and released under the GNU FDL.) has developed the Event Visualization Tool (eVis), another software tool to add to the suite of conservation monitoring and decision support tools for guiding protected area and landscape planning. This plugin enables users to easily link geocoded (i.e., referenced with latitude and longitude or X and Y coordinates) photographs, and other supporting documents, to vector data in QGIS.

eVis is now automatically installed and enabled in new versions of QGIS, and as with all plugins, it can be disabled and enabled using the Plugin Manager (See Gerenciar Complementos).

The eVis plugin is made up of three modules: the ‘Database Connection tool’, ‘Event ID tool’, and the ‘Event Browser’. These work together to allow viewing of geocoded photographs and other documents that are linked to features stored in vector files, databases, or spreadsheets.

Navegador de Evento

The Event Browser module provides the functionality to display geocoded photographs that are linked to vector features displayed in the QGIS map window. Point data, for example, can be from a vector file that can be input using QGIS or it can be from the result of a database query. The vector feature must have attribute information associated with it to describe the location and name of the file containing the photograph and, optionally, the compass direction the camera was pointed when the image was acquired. Your vector layer must be loaded into QGIS before running the Event Browser.

Iniciando o módulo Navegador de Evento

To launch the Event browser module either click on the event_browser eVis Event Browser icon or click on Database ‣ eVis ‣ eVis Event Browser. This will open the Generic Event Browser window.

The Event Browser window has three tabs displayed at the top of the window. The Display tab is used to view the photograph and its associated attribute data. The Options tab provides a number of settings that can be adjusted to control the behavior of the eVis plugin. Lastly, the Configure External Applications tab is used to maintain a table of file extensions and their associated application to allow eVis to display documents other than images.

Entendendo a Janela de Exibição

To see the Display window click on the Display tab in the Event Browser window. The Display window is used to view geocoded photographs and their associated attribute data.

Figure eVis 1:

../../../_images/evisdisplay.png

The eVis display window

  1. Display window: A window where the photograph will appear.
  2. Zoom in button: Zoom in to see more detail. If the entire image cannot be displayed in the display window, scroll bars will appear on the left and bottom sides of the window to allow you to pan around the image.
  3. Zoom out button: Zoom out to see more area.
  4. Zoom to full extent button: Displays the full extent of the photograph.
  5. ** Janela informações de atributo **: Todas as informações de atributo para o ponto associado com a fotografia que está sendo visualizada é apresentada aqui. Se o tipo de arquivo que está sendo referenciado no registro exibido não é uma imagem, mas é de um tipo de arquivo definido no: guilabel: Configurar aplicações externas guia então quando você clicar duas vezes sobre o valor do campo que contém o caminho para o arquivo, o aplicativo para abrir o arquivo será lançado para ver ou ouvir o conteúdo do arquivo. Se a extensão do arquivo é reconhecida os dados dos atributos serão exibidos em verde.

  6. Navigation buttons: Use the Previous and Next buttons to load the previous or next feature when more than one feature is selected.

Entendendo a janela Opções

Figure eVis 2:

../../../_images/evisoptions.png

The eVis Options window

  1. File path: A dropdown list to specify the attribute field that contains the directory path or URL for the photographs or other documents being displayed. If the location is a relative path then the checkbox must be clicked. The base path for a relative path can be entered in the Base Path text box below. Information about the different options for specifying the file location are noted in the section Especificando o local e o nome de uma fotografia below.
  2. Compass bearing: A dropdown list to specify the attribute field that contains the compass bearing associated with the photograph being displayed. If compass bearing information is available it is necessary to click the checkbox below the dropdown menu title.
  3. Compass offset: Compass offsets can be used to compensate for declination (adjust bearings collected using magnetic bearings to true north bearings). Click the radiobuttonon Manual radiobutton to enter the offset in the text box or click the radiobuttonon From Attribute radiobutton to select the attribute field containing the offsets. For both of these options east declinations should be entered using positive values and west declinations should use negative values.
  4. Caminho Diretório base: O caminho de base para que o caminho relativo definido no Figure_eVis_2 (A) será anexado.

  5. Substitua o caminho: Se esta opção estiver marcada, somente o nome do arquivo A será anexado ao caminho de base.

  6. Aplicar regra a todos os documentos: Se marcado, as mesmas regras de caminho que são definidas para as fotografias serão usadas para os documentos não-imagem, como filmes, documentos de texto e arquivos de som. Se não marcado as regras de caminho só se aplica a fotografias e outros documentos ignorará o parâmetro Caminho base.

  7. Remember settings: If the checkbox is checked the values for the associated parameters will be saved for the next session when the window is closed or when the [Save] button below is pressed.
  8. Redefinir valores: Redefine os valores nesta linha para a configuração padrão.

  9. Restore defaults: This will reset all of the fields to their default settings. It has the same effect as clicking all of the [Reset] buttons.
  10. Save: This will save the settings without closing the Options pane.

Entendendo a janela Configurar Aplicações Externas

Figure eVis 3:

../../../_images/evisexternal.png

The eVis External Applications window

  1. **Arquivo tabela de referência **: Uma tabela contendo os tipos de arquivos que podem ser abertos usando eVis. Cada tipo de arquivo tem uma extensão de arquivo e o caminho para um aplicativo poder abrí-lo. Isso fornece a capacidade de abrir uma ampla gama de arquivos como filmes, gravações sonoras, e documentos de texto em vez de apenas imagens.

  2. Adicionar novo tipo de arquivo: Adicionar um novo tipo de arquivo com uma extensão única e o caminho para o aplicativo poder abrí-lo.

  3. ** Excluir linha atual **: Exclui o tipo de arquivo em destaque na tabela e definido por uma extensão de arquivo e um caminho para um aplicativo associado.

Especificando o local e o nome de uma fotografia

O local e o nome da fotografia podem ser armazenados usando um caminho absoluto ou relativo ou um URL (Uniform Resource Locator em português Localizador-Padrão de Recursos) se a fotografia está disponível em um servidor web. Exemplos das diferentes abordagens estão listadas na Tabela eVis_exemplos `` _.

X        Y        FILE                                                BEARING
780596   1784017  C:\Workshop\eVis_Data\groundphotos\DSC_0168.JPG     275
780596   1784017  /groundphotos/DSC_0169.JPG                          80
780819   1784015  http://biodiversityinformatics.amnh.org/\
                  evis_testdata/DSC_0170.JPG                          10
780596   1784017  pdf:http://www.testsite.com/attachments.php?\
                  attachment_id-12                                    76

Especificando o local e o nome de outros documentos suportados

Supporting documents such as text documents, videos, and sound clips can also be displayed or played by eVis. To do this it is necessary to add an entry in the file reference table that can be accessed from the Configure External Applications window in the Generic Event Browser that matches the file extension to an application that can be used to open the file. It is also necessary to have the path or URL to the file in the attribute table for the vector layer. One additional rule that can be used for URLs that don’t contain a file extension for the document you want to open is to specify the file extension before the URL. The format is — file extension:URL. The URL is preceded by the file extension and a colon, and is particularly useful for accessing documents from Wikis and other web sites that use a database to manage the web pages (see Table evis_examples).

Using the Event Browser

When the Event Browser window opens a photograph will appear in the display window if the document referenced in the vector file attribute table is an image and if the file location information in the Options window is properly set. If a photograph is expected and it does not appear it will be necessary to adjust the parameters in the Options window.

If a supporting document (or an image that does not have a file extension recognized by eVis) is referenced in the attribute table the field containing the file path will be highlighted in green in the attribute information window if that file extension is defined in the file reference table located in the Configure External Applications window. To open the document double-click on the green-highlighted line in the attribute information window. If a supporting document is referenced in the attribute information window and the file path is not highlighted in green then it will be necessary to add an entry for the file’s filename extension in the Configure External Applications window. If the file path is highlighted in green but does not open when double-clicked it will be necessary to adjust the parameters in the Options window so the file can be located by eVis.

If no compass bearing is provided in the Options window a red asterisk will be displayed on top of the vector feature that is associated with the photograph being displayed. If a compass bearing is provided then an arrow will appear pointing in the direction indicated by the value in the compass bearing display field in the Event Browser window. The arrow will be centered over the point that is associated with the photograph or other document.

To close the Event Browser window click on the [Close] button from the Display window.

Ferramenta ID de Evento

The ‘Event ID’ module allows you to display a photograph by clicking on a feature displayed in the QGIS map window. The vector feature must have attribute information associated with it to describe the location and name of the file containing the photograph and optionally the compass direction the camera was pointed when the image was acquired. This layer must be loaded into QGIS before running the ‘Event ID’ tool.

Iniciando o módulo Identificação de Evento

To launch the ‘Event ID’ module either click on the event_id Event ID icon or click on Database ‣ eVis ‣ Event ID Tool. This will cause the cursor to change to an arrow with an ‘i’ on top of it signifying that the ID tool is active.

To view the photographs linked to vector features in the active vector layer displayed in the QGIS map window, move the Event ID cursor over the feature and then click the mouse. After clicking on the feature, the Event Browser window is opened and the photographs on or near the clicked locality are available for display in the browser. If more than one photograph is available, you can cycle through the different features using the [Previous] and [Next] buttons. The other controls are described in the ref:evis_browser section of this guide.

Conexão com o Base de Dados

The ‘Database Connection’ module provides tools to connect to and query a database or other ODBC resource, such as a spreadsheet.

eVis can directly connect to four types of databases:PostgreSQL, MySQL, SQLite, and can also read from ODBC connections (e.g.MS Access). When reading from an ODBC database (such as an Excel spreadsheet) it is necessary to configure your ODBC driver for the operating system you are using.

Iniciando o módulo Conexão com a Base de Dados

To launch the ‘Database Connection’ module either click on the appropriate icon evis_connect eVis Database Connection or click on Database ‣ eVis ‣ Database Connection. This will launch the Database Connection window. The window has three tabs: Predefined Queries, Database Connection, and SQL Query. The Output Console window at the bottom of the window displays the status of actions initiated by the different sections of this module.

Conectar a uma base de dados

Click on the Database Connection tab to open the database connection interface. Next, use the Database Type selectstring combobox to select the type of database that you want to connect to. If a password or username is required, that information can be entered in the Username and Password textboxes.

Enter the database host in the Database Host textbox. This option is not available if you selected ‘MS Access’ as the database type. If the database resides on your desktop you should enter “localhost”.

Enter the name of the database in the Database Name textbox. If you selected ‘ODBC’ as the database type, you need to enter the data source name.

When all of the parameters are filled in, click on the [Connect] button. If the connection is successful, a message will be written in the Output Console window stating that the connection was established. If a connection was not established you will need to check that the correct parameters were entered above.

Figure eVis 4:

../../../_images/evisdatabase.png

The eVis Database connection window

  1. Tipo de Base de dados: Uma lista suspensa para especificar o tipo de base de dados que será usado.

  2. Base de dados hospedeiro: O nome da base de dados hospedeiro.

  3. Port The port number if a MySQL or PostgreSQL database type is selected.
  4. Nome da Base de Dados O nome da base de dados.

  5. Conectar Um botão para conectar-se a banco de dados usando os parâmetros definidos acima.

  6. Console de Saída A janela do console onde as mensagens relacionadas ao processamento são exibidos.

  7. Nome de Usuário: Nome de usuário para uso quando uma base de dados é protegida por senha.

  8. Senha: Senha para uso quando uma base de dados é protegida por senha.

  9. Consultas pré-definidas: Guia para abrir a janela “Consultas pré-definidas”.

  10. **Conexão com a base de dados **: Guia para abrir a janela “Conexão com a Base de dados”.

  11. Consulta SQL: Guia para abrir a janela “Consulta SQL”.

  12. Ajuda: Exibe a ajuda on line.

  13. OK: Fecha a janela principal do “Conexão com a Base de Dados”.

Execução de consultas SQL

SQL queries are used to extract information from a database or ODBC resource. In eVis the output from these queries is a vector layer added to the QGIS map window. Click on the SQL Query tab to display the SQL query interface. SQL commands can be entered in this text window. A helpful tutorial on SQL commands is available at http://www.w3schools.com/sql. For example, to extract all of the data from a worksheet in an Excel file, select * from [sheet1$] where sheet1 is the name of the worksheet.

Click on the [Run Query] button to execute the command. If the query is successful a Database File Selection window will be displayed. If the query is not successful an error message will appear in the Output Console window.

In the Database File Selection window, enter the name of the layer that will be created from the results of the query in the Name of New Layer textbox.

Figure eVis 5:

../../../_images/evissql_query.png

The eVis SQL query tab

  1. Janela de Texto de Consulta SQL: Uma tela para escrever consultas SQL.

  2. Run Query: Button to execute the query entered in the SQL Query Window.
  3. Janela Console: A janela console onde as mensagens relacionadas ao processamento são exibidas.

  4. Ajuda: Exibe a ajuda on line.

  5. OK: Closes the main Database Connection window.

Use the X Coordinate selectstring and Y Coordinate selectstring comboboxes to select the field from the database that store the X (or longitude) and Y (or latitude) coordinates. Clicking on the [OK] button causes the vector layer created from the SQL query to be displayed in the QGIS map window.

To save this vector file for future use, you can use the QGIS ‘Save as...’ command that is accessed by right clicking on the layer name in the QGIS map legend and then selecting ‘Save as...’

Dica

Criando uma camada vetorial a partir de uma planilha do Microsoft Excel

When creating a vector layer from a Microsoft Excel Worksheet you might see that unwanted zeros (“0”) have been inserted in the attribute table rows beneath valid data.This can be caused by deleting the values for these cells in Excel using the Backspace key. To correct this problem you need to open the Excel file (you’ll need to close QGIS if there if you are connected to the file to allow you to edit the file) and then use Edit ‣ Delete to remove the blank rows from the file. To avoid this problem you can simply delete several rows in the Excel Worksheet using Edit ‣ Delete before saving the file.

Executando consultas pré-definidas

Com consultas predefinidas você pode selecionar consultas previamente escritas e armazenadas no formato XML em um arquivo. Isto é particularmente útil se você não estiver familiarizado com os comandos SQL. Clique no: guilabel: guia `Consultas Predefinidas’ para exibir a interface de consulta prédefinida.

To load a set of predefined queries click on the evis_file Open File icon. This opens the Open File window which is used to locate the file containing the SQL queries. When the queries are loaded their titles, as defined in the XML file, will appear in the dropdown menu located just below the evis_file Open File icon, the full description of the query is displayed in the text window under the dropdown menu.

Selecione a consulta que você deseja executar no menu suspenso e, então clique em: guilabel: guia Consulta SQL para ver se a consulta foi carregada na janela Consulta. Se for a primeira vez que você estiver executando uma consulta predefinida ou estiver migrando bancos de dados, você precisa ter certeza de estar conectado ao banco de dados.

Click on the [Run Query] button in the SQL Query tab to execute the command. If the query is successful a Database File Selection window will be displayed. If the query is not successful an error message will appear in the Output Console window.

Figure eVis 6:

../../../_images/evispredefined.png

The eVis Predefined queries tab

  1. Open File: Launches the “Open File” file browser to search for the XML file holding the predefined queries.
  2. ** Consultas predefinidas **: Uma lista suspensa com todas as consultas definidas pelo arquivo consultas prédefinidas XML.

  3. Consulta descrição: Uma breve descrição da consulta. Esta descrição é do arquivo consultas prédefinida XML.

  4. Janela Console: A janela console onde as mensagens relacionadas ao processamento são exibidas.

  5. Ajuda: Exibe a ajuda on line.

  6. OK: Fecha a janela principal do “Conexão com a Base de Dados”.

Formato XML para consultas predefinidas eVis

As marcas XML lidas por eVis

Marcas

Descrição

Consulta

Define o início e o fim de uma instrução de consulta.

Descrição Breve

Uma breve descrição da consulta que aparece no menu suspenso eVis.

Descrição

Uma descrição mais detalhada da consulta exibida na janela de texto Consulta Predefinida.

Tipo de Base de Dados

O tipo base de dados, conforme definido no menu suspenso Tipo de Base de Dados na guia Conexão Base de Dados.

Porta da Base de Dados

A porta conforme definido na caixa de texto Porta na guia Conexão com a Base de Dados.

Nome da Base de Dados

O nome da base de dados, conforme definido na caixa de texto Nome da Base de Dados na guia Conexão com a Base de Dados.

Nome de Usuário da Base de Dados

O nome de usuário da base de dados, conforme definido na caixa de texto Nome de usuário na guia Conexão com a Base de Dados.

Senha de Base de Dados

A senha da base de dados, conforme definido na caixa de texto Senha na guia Conexão com a Base de Dados.

Instrução SQL

O comando SQL.

autoconexão

A bandeira (“verdadeira” “ou” falsa ”) para especificar se as marcas acima devem ser usadas para conectar-se automaticamente à base de dados sem executar a rotina de conexão com a base de dados na guia Conexão com a Base de Dados.

Um exemplo de arquivo XML completo com três consultas é exibido abaixo:

<?xml version="1.0"?>
<doc>
 <query>
   <shortdescription>Import all photograph points</shortdescription>
   <description>This command will import all of the data in the SQLite database to QGIS
      </description>
   <databasetype>SQLITE</databasetype>
   <databasehost />
   <databaseport />
   <databasename>C:\textbackslash Workshop/textbackslash
eVis\_Data\textbackslash PhotoPoints.db</databasename>
   <databaseusername />
   <databasepassword />
   <sqlstatement>SELECT Attributes.*, Points.x, Points.y FROM Attributes LEFT JOIN
      Points ON Points.rec_id=Attributes.point_ID</sqlstatement>
   <autoconnect>false</autoconnect>
 </query>
  <query>
   <shortdescription>Import photograph points "looking across Valley"</shortdescription>
   <description>This command will import only points that have photographs "looking across
      a valley" to QGIS</description>
   <databasetype>SQLITE</databasetype>
   <databasehost />
   <databaseport />
   <databasename>C:\Workshop\eVis_Data\PhotoPoints.db</databasename>
   <databaseusername />
   <databasepassword />
   <sqlstatement>SELECT Attributes.*, Points.x, Points.y FROM Attributes LEFT JOIN
      Points ON Points.rec_id=Attributes.point_ID where COMMENTS='Looking across
      valley'</sqlstatement>
   <autoconnect>false</autoconnect>
 </query>
 <query>
   <shortdescription>Import photograph points that mention "limestone"</shortdescription>
   <description>This command will import only points that have photographs that mention
      "limestone" to QGIS</description>
   <databasetype>SQLITE</databasetype>
   <databasehost />
   <databaseport />
   <databasename>C:\Workshop\eVis_Data\PhotoPoints.db</databasename>
   <databaseusername />
   <databasepassword />
   <sqlstatement>SELECT Attributes.*, Points.x, Points.y FROM Attributes LEFT JOIN
      Points ON Points.rec_id=Attributes.point_ID where COMMENTS like '%limestone%'
      </sqlstatement>
   <autoconnect>false</autoconnect>
 </query>
</doc>