Data selection and Queries in ArcGIS

Similar documents
Microsoft Access 3: Understanding and Creating Queries

UNLEASHED. The Field Calculator. By Tom Neer, EDAW, Inc.

Selecting Features by Attributes in ArcGIS Using the Query Builder

University of Arkansas Libraries ArcGIS Desktop Tutorial. Section 4: Preparing Data for Analysis

Personal Geodatabase 101

How to Import Data into Microsoft Access

Government 1008: Introduction to Geographic Information Systems. LAB EXERCISE 4: Got Database?

ArcGIS Tutorial: Adding Attribute Data

Access Queries (Office 2003)

Microsoft Excel 2010 Part 3: Advanced Excel

Ohio University Computer Services Center August, 2002 Crystal Reports Introduction Quick Reference Guide

GEOGRAPHIC INFORMATION SYSTEMS Lecture 20: Adding and Creating Data

Data Tool Platform SQL Development Tools

Tutorial Creating a regular grid for point sampling

Exploring Microsoft Office Access Chapter 2: Relational Databases and Multi-Table Queries

Introduction to Microsoft Access 2003

Fig. 1 Suitable data for a Crosstab Query.

Click to create a query in Design View. and click the Query Design button in the Queries group to create a new table in Design View.

Linking FLIPS to a GIS Shapefile

Lab 9 Access PreLab Copy the prelab folder, Lab09 PreLab9_Access_intro

Access 2010 Intermediate Skills

Creating QBE Queries in Microsoft SQL Server

Groundwater Chemistry

Spatial Analyst Tutorial

Working with the Raster Calculator

University of Arkansas Libraries ArcGIS Desktop Tutorial. Section 2: Manipulating Display Parameters in ArcMap. Symbolizing Features and Rasters:

Geodatabase Tutorial. Copyright Esri All rights reserved.

Access 2003 Introduction to Queries

Geodatabase Programming with SQL

How To Use Excel With A Calculator

Create a New Database in Access 2010

Microsoft Access 2010 Part 1: Introduction to Access

MAS 500 Intelligence Tips and Tricks Booklet Vol. 1

Access Part 2 - Design

Microsoft Excel 2007 Consolidate Data & Analyze with Pivot Table Windows XP

Excel Database Management Microsoft Excel 2003

Reference Management with

WFP Liberia Country Office

The Center for Teaching, Learning, & Technology

BID2WIN Workshop. Advanced Report Writing

Access 2010: Creating Queries Table of Contents INTRODUCTION TO QUERIES... 2 QUERY JOINS... 2 INNER JOINS... 3 OUTER JOINS...

Exercise 4 Learning Python language fundamentals

Web Intelligence User Guide

Creating Calculated Fields in Access Queries and Reports

Excel Level Two. Introduction. Contents. Exploring Formulas. Entering Formulas

Analyzing Excel Data Using Pivot Tables

Converting Excel Spreadsheets or Comma Separated Values files into Database File or Geodatabases for use in the USGS Metadata Wizard

3.GETTING STARTED WITH ORACLE8i

Creating Basic Excel Formulas

A database is a collection of data organised in a manner that allows access, retrieval, and use of that data.

Crystal Reports Payroll Exercise

Querying a Database Using the Select Query Window

Joins Joins dictate how two tables or queries relate to each other. Click on the join line with the right mouse button to access the Join Properties.

Step 2. Open ArcMap, set Projection to State Plane NAD 83 Feet Apply

Instructions for Creating an Outlook Distribution List from an Excel File

Tutorial 5: Summarizing Tabular Data Florida Case Study

Tutorial 3 - Map Symbology in ArcGIS

ModelBuilder - Creating Tools Tutorial

Database Applications Microsoft Access

Using SQL Queries in Crystal Reports

Databases in Microsoft Access David M. Marcovitz, Ph.D.

2.1 Data Collection Techniques

Taking Advantage of Crystal Reports

How To Create A Report In Excel

Data Interoperability Extension Tutorial

Introduction to PASW Statistics

Excel Working with Data Lists

Visualization with Excel Tools and Microsoft Azure

INTRODUCTION to ESRI ARCGIS For Visualization, CPSC 178

Tutorial 3: Working with Tables Joining Multiple Databases in ArcGIS

DbSchema Tutorial with Introduction in SQL Databases

Introduction to SPSS 16.0

Excel 2007 Basic knowledge

Web Editing Tutorial. Copyright Esri All rights reserved.

Appendix III: SPSS Preliminary

Retrieving Data Using the SQL SELECT Statement. Copyright 2006, Oracle. All rights reserved.

Data Visualization. Prepared by Francisco Olivera, Ph.D., Srikanth Koka Department of Civil Engineering Texas A&M University February 2004

MS Access: Advanced Tables and Queries. Lesson Notes Author: Pamela Schmidt

Using SPSS, Chapter 2: Descriptive Statistics

Chapter 2: Elements of Java

BusinessObjects: General Report Writing for Version 5

Eventia Log Parsing Editor 1.0 Administration Guide

Q&As: Microsoft Excel 2013: Chapter 2

Chapter 2 Introduction to SPSS

Linear Referencing Tutorial

Attribute Data and Relational Database. Lecture 5 9/21/2006

Table of Contents. Introduction: 2. Settings: 6. Archive 9. Search Browse Schedule Archiving: 18

Microsoft Excel 2010 Tutorial

OpenInsight 9.3 Quick Start Guide

Web GIS User Guide MainStreetGIS, LLC

DataPA OpenAnalytics End User Training

Working with the Geodatabase Using SQL

MS Excel. Handout: Level 2. elearning Department. Copyright 2016 CMS e-learning Department. All Rights Reserved. Page 1 of 11

Analyzing Data Using Access

Data Visualization. Brief Overview of ArcMap

Access Database Design

Tutorial 4 - Attribute data in ArcGIS

Using an Access Database

Transcription:

Data selection and Queries in ArcGIS BASICS Whether you are selecting or querying data there are a minimum of 3 elements you will need; a field, an, operator and a value Field Operator Value "AREA" > 1500 "TYPE" = WATER Data Query Builder window Building a query This dialog lets you select features in a layer or records in a table by building a query. To create an expression, double-click the field you want to use, click an operator, then double-click the value. You can also type directly into the query. For example, this query will select all the houses of more than 1,500 square feet in a coverage: "AREA" > 1500 When you use this dialog, you are actually creating a SQL query. The syntax of the query differs depending on the data source you are querying. The expression is sent to the data source and interpreted there rather than being parsed in the dialog, so expressions are in the native format for the database at which they are aimed. Values from data User defined value

OPERATORS The following is the full list of query operators supported by file geodatabases, shapefiles, coverages, and other file-based data sources. They are also supported by personal and ArcSDE geodatabases, although these data sources may require different syntax. In addition to the operators below, personal and ArcSDE geodatabases support additional capabilities. Please see your DBMS documentation for details. Arithmetic operators You use an arithmetic operator to add, subtract, multiply, and divide numeric values. Operator Description * Arithmetic operator for multiplication / Arithmetic operator for division + Arithmetic operator for addition - Arithmetic operator for subtraction Arithmetic operators Comparison operators You use comparison operators to compare one expression to another. < <= <> > >= Operator Description Less than. It can be used with strings (comparison is based on alphabetical order), numbers, and dates. Less than or equal to. It can be used with strings (comparison is based on alphabetical order), numbers, and dates. Not equal to. It can be used with strings (comparison is based on alphabetical order), numbers, and dates. Greater than. It can be used with strings (comparison is based on alphabetical order), numbers, and dates. Greater than or equal to. It can be used with strings (comparison is based on alphabetical order), numbers, and dates. For example, this query selects all the cities with names starting with the letters M to Z: [NOT] BETWEEN x AND y "CITY_NAME" >= 'M' Selects a record if it has a value greater than or equal to x and less than or equal to y. When preceded by NOT, it selects a record if it has a value outside the specified range. For example, this expression selects all records with a value greater than or equal to 1 and less than or equal to 10:

"OBJECTID" BETWEEN 1 AND 10 This is the equivalent of the following expression: "OBJECTID" >= 1 AND OBJECTID <= 10 However, the expression with BETWEEN provides better performance if you're querying an indexed field. [NOT] EXISTS Returns TRUE if the subquery returns at least one record; otherwise, it returns FALSE. For example, this expression returns TRUE if the OBJECTID field contains a value of 50: EXISTS (SELECT * FROM parcels WHERE "OBJECTID" = 50) EXISTS is supported in file, personal, and ArcSDE geodatabases only. [NOT] IN IS [NOT] NULL Selects a record if it has one of several strings or values in a field. When preceded by NOT, it selects a record if it doesn't have one of several strings or values in a field. For example, this expression searches for four different state names: "STATE_NAME" IN ('Alabama', 'Alaska', 'California', 'Florida') For file, personal, and ArcSDE geodatabases, this operator can also be applied to a subquery: "STATE_NAME" IN (SELECT "STATE_NAME" FROM states WHERE "POP" > 5000000) Selects a record if it has a null value for the specified field. When NULL is preceded by NOT, it selects a record if it has any value for the specified field. For example, this expression selects all records with a null value for population: "POPULATION" IS NULL Use the LIKE operator (instead of the = operator) with wildcards to build a partial string search. For example, this expression selects Mississippi and Missouri among USA state names: x [NOT] LIKE y [ESCAPE 'escapecharacter'] "STATE_NAME" LIKE 'Miss%' The percent symbol (%) means that anything is acceptable in its place: one character, a hundred characters, or no character. Alternatively, if you want to search with a wildcard that represents one character, use and underscore (_). For example, this expression finds Catherine Smith and Katherine Smith: "OWNER_NAME" LIKE '_atherine Smith' The percent symbol and underscore wildcards work for any file-based data or multiuser geodatabase data. LIKE works with character data on both sides of the expression. If you need to access noncharacter data, use the CAST function. For example, this query returns numbers that begin with 8 from the integer field SCORE_INT: CAST ("SCORE_INT" AS VARCHAR) LIKE '8%' To include the percent symbol or underscore in your search string, use the ESCAPE

keyword to designate another character as the escape character, which in turn indicates that a real percent sign or underscore immediately follows. For example, this expression returns any string containing 10%, such as 10% DISCOUNT or A10%: "AMOUNT" LIKE '%10$%%' ESCAPE '$' The wildcards you use to query personal geodatabases are asterisk (*) for any number of characters and question mark (?) for one character. The pound sign (#) is also used as a wildcard to match a single digit (numeric value). For example, this query returns parcel numbers A1, A2, and so on, from a personal geodatabase: [PARCEL_NUMBER] LIKE 'A#' Comparison operators Logical operators Operator Description Combines two conditions together and selects a record if both conditions are true. For example, the following expression selects any house with more than 1,500 square AND feet and a garage for more than two cars: OR NOT "AREA" > 1500 AND "GARAGE" > 2 Combines two conditions together and selects a record if at least one condition is true. For example, the following expression selects any house with more than 1,500 square feet or a garage for more than two cars: "AREA" > 1500 OR "GARAGE" > 2 Selects a record if it doesn't match the expression. For example, the following expression selects all states but California: NOT "STATE_NAME" = 'California' Field names The Field list in this dialog automatically lists fields with the appropriate delimiters for the type of data you are querying: - If you are querying data in a file geodatabase, shapefile, dbase table, coverage, INFO table, then field names are enclosed in double quotes: "AREA" - If you are querying data in a personal geodatabase then field names are enclosed in square brackets: [AREA] - If you are querying data in an ArcSDE geodatabase (i.e., data accessed via a database connection to an ArcSDE Enterprise geodatabase, or data accessed from a database server running ArcSDE Personal Edition or Workgroup Edition) or an ArcIMS image service or feature service, then fields are not enclosed: AREA

- If you are querying data in a worksheet in an Excel file (.xls file) or a text file (.txt file), fields are delimited in single quotes 'AREA' unless you are working in the Select By Attributes dialog launched from the table window, in which case square brackets [AREA] are used. Strings Strings must always be enclosed within single quotes. For example: "STATE_NAME" = 'California' Strings in expressions are case sensitive, except when you are querying personal geodatabase feature classes and tables. To make a case insensitive search in other data formats, you can use a SQL function to convert all values to the same case. For file-based data sources, use either the UPPER or LOWER function. For example, the following expression will select customers whose last name is stored as either Jones or JONES: UPPER("LAST_NAME") = 'JONES' Other data sources have similar functions. Personal geodatabases, for example, have functions named UCASE and LCASE that perform the same function. Use the LIKE operator (instead of the = operator) to build a partial string search. For example, this expression would select Mississippi and Missouri among the USA state names: "STATE_NAME" LIKE 'Miss%' You can use greater than (>), less than (<), greater than or equal (>=), less than or equal (<=) and BETWEEN operators to select string values based on sorting order. For example, this expression will select all the cities in a coverage with names starting with the letters M to Z: "CITY_NAME" >= 'M' The not equal (<>) operator can also be used when querying strings. Wildcard Characters A wildcard character is a special symbol that stands for one or more characters. For any file-based data, '%' means that anything is acceptable in its place: one character, a hundred characters, or no character. Alternatively, if you want to search with a wildcard that represents one character, use '_'. For example, this expression would select any name starting with the letters Cath, such as Cathy, Catherine, and Catherine Smith: "NAME" LIKE 'Cath%' But this expression would find Catherine Smith and Katherine Smith: "OWNER_NAME" LIKE '_atherine smith' The wildcards you use to query personal geodatabases are '*' for any number of characters and '?' for one character. Wildcard characters appear as buttons on the query dialog. You can click the button to enter the wildcard into the expression you re building. Only the wildcard characters that are appropriate to the data source of the layer or table you are querying are displayed. If you use a wildcard character in a string with the = operator, the character is treated as part of the string, not as a wildcard. With a joined table, use wildcards appropriate for the side of the join that you are querying. If the query only applies to fields in the target table (the left-side table), use the target table wildcards. If the query only applies to fields in the join table (the right-side table), use the join table wildcards. If the query involves fields from both sides of the join, use the '%' and '_' wildcards.

For example, if you join a dbf file (the join table) to a personal GDB feature class (the target table): 1) Use * for queries that only involve personal GDB fields. 2) Use % for queries that only involve dbf columns. 3) Use % for queries involving columns from both sides of the table. The NULL keyword Null values are supported in fields for geodatabases and for date fields in shapefiles/dbase tables and coverages/info tables. If you select a field of a type that supports null values, and if that field contains any null values in the records displayed by the Unique Values list, you'll see a NULL keyword at the top of the Unique Values list. You can double-click the NULL keyword to add it into your expression, where you can use the IS operator to query the field to select all its null values: "POPULATION96" IS NULL or IS NOT to select all its values that aren't null: "POPULATION96" IS NOT NULL The NULL keyword is always preceded by IS or IS NOT. Querying numbers You can query numbers using the equal (=), not equal (<>), greater than (>), less than (<), greater than or equal (>=), and less than or equal (<=) operators. "POPULATION96" >= 5000 The point is always used as the decimal delimiter regardless of your regional settings. The comma cannot be used as a decimal or thousands delimiter in a query. Calculations Calculations can be included in queries using these arithmetic operators: + - * / Calculations can be between fields and numbers. For example: "AREA" >= "PERIMETER" * 100 Calculations can also be performed between fields. For example, to find the countries with a population density of less than or equal to 25 people per square mile, you could use this expression: "POP1990" / "AREA" <= 25 Note: calculations between fields in a coverage or shapefile (or an INFO table or a dbase table) are not supported. Operator precedence Expressions evaluate according to standard operator precedence rules. For example, the part of an expression enclosed in parentheses is evaluated before the part that isn t enclosed. This example: HOUSEHOLDS > MALES * POP90_SQMI + AREA evaluates differently from: HOUSEHOLDS > MALES * (POP90_SQMI + AREA)

You can either click to add parentheses and then enter the expression you want to enclose, or highlight the existing expression that you want to enclose and then press the Parentheses button to enclose it. Combining expressions Expressions can be combined together with the AND and OR operators. AREA > 1500 AND GARAGE > 3 When you use the OR operator, at least one expression of the two expressions separated by the OR operator must be true for the record to be selected. RAINFALL < 20 OR SLOPE > 35 Use the NOT operator at the beginning of an expression to find features or records that don't match the specified expression. NOT expressions can be combined with AND and OR. SUB_REGION = 'New England' AND NOT STATE_NAME = 'Maine' Querying dates The syntax required for querying dates depends on the data type. ArcMap will automatically write the proper syntax for you when you double-click a date value in the Unique Values list. See the SQL reference mentioned above for more about querying dates. Clearing the selected features Use the Clear Selected Features command to unselect all the selected features and clear the selection set. You can find this command in the Selection pulldown menu, where it operates on all the layers in the active data frame whether or not they are currently selectable, or by right-clicking a layer, where it just operates on that layer. A shortcut for using the Clear Selected Features command is to use one of these tools: - Select Features tool in the Tools toolbar - Edit tool in the Editor toolbar and click or drag a box on the map without selecting any features. This will clear the selection sets for all the layers in the active data frame. SUMMARIZING AND GETTING STATISTICS FROM TABLES Open up the attribute table and right click on any column. Access to a few tools is possible including summarize and statistics.

Summarizing data creates a simple summary table that can be added to your map. Getting statistics from a table

We will be doing our queries and selections on a VRI dataset. Below is a simplified description of the data VRI Background Information The Forest Resources Commission recommended a review of the provincial resource inventory process in its report The Future of our Forests. The Resources Inventory Standards Committee (RISC) was established with the objective of achieving common standards and procedures. The Vegetation Resources Inventory is a photo-based, two-phased vegetation inventory program consisting of: Phase I: Photo Interpretation Phase II: Ground Sampling Within the ground sampling phase, Net Volume Adjustment Factor (NVAF) sampling is a mandatory component that is integral in the calculation of inventory adjustment factors. The Ministry of Forests and Range and forest licensees, is implementing the components of the Vegetation Resources Inventory. What is the Vegetation Resource Inventory designed to do? The Vegetation Resources Inventory is designed to answer two questions: 1. Where is the resource located? 2. How much of a given vegetation resource (for example, timber or coarse woody debris) is within an inventory unit? Questions: Add the VRI dataset to your map open the attribute table and answer the following questions 1. What feature type is the data? 2. What TRIM mapsheet is the data on? 3. How many features are in the dataset? 4. Go to the shape_area field. From the using the statistics function a. What is the size of the largest polygon? b. What is the size of the smallest polygon? 5. Look at the LINE_3_TREE_SPECIES field and compare it to the SPECIES_CD_1, SPECIES_CD_2, SPECIES_CD_3... fields. What do you notice. 6. How many polygons have a SPECIES_CD_1 that is = Sw? 7. How many polygons have a SPECIES_CD_1 that start with S

8. What value do you get when you put in the following SQL statement a. [SPECIES_CD_1] = 'PLI' b. [SPECIES_CD_1] = 'PLI' and [SPECIES_PCT_1] > 50 c. [SPECIES_CD_1] = 'PLI' or [SPECIES_PCT_1] > 50 (why the difference between b and c) 9. How many <Null> values are in the [SPECIES_CD_2] column? 10. How many polygons Have a [SPECIES_CD_1] the is PLI and [SPECIES_PCT_1] = 60 and a [SPECIES_CD_2] of SW [SPECIES_PCT_2] less than or equal to 30 11. What is the area in hectares of the following polygon whose map_id is 093G098 and poly_id is 1328? 12. Add a field called OPENING_ID (TEXT, 25). Populate the field with the values from MAPSHEET and Polygon_id, separated by a hyphen ( - ) i.e 93G098-102 13. How many polygons are greater than 40 hectares? a. What is the sum of these polygons? b. What is the sum of these polygons excluding the Null values 14. Remove all queries from your data. Go to the data view and symbolize the data on [SPECIES_CD_1]. Add the VRI_Species1.lyr 15. Add the data again and this time add the following layer file Level5.lyr a. What is the size of the large lake (Tabor Lake) in the south portion of the data. b. Print a map with a scale bar and north arrow that shows the area of Tabor Lake in hectares 16. How many polygons have 6 species codes? a. What is the maximum percentage? b. Look at the selected data on your map. Where on the mapsheet is the majority of the data located? c. Duplicate the same query on the layer and symbolize based on the [SPECIES_PCT_6]. In the layout view add a scale bar and north arrow. Set the scale to 80000. Export the map to a.pdf and load it onto your web page.