Download presentation
Presentation is loading. Please wait.
Published byMyrtle Blair Modified over 9 years ago
1
NSF DUE-1205110; 0903270 Wen M. Andrews J. Sargeant Reynolds Community College Richmond, Virginia
2
NSF DUE-1205110; 0903270 GeoTEd Partners
3
NSF DUE-1205110; 0903270 What are Query Expressions (SQL ) Query expressions adhere to Structured Query Language (SQL) which is a special purpose programming language designed for managing data held in a relational database management systems (RDBMS) It is the standard language for relational database management systems such as ArcGIS. Some common relational database management systems that use SQL are: Oracle, Sybase, Microsoft SQL Server, Access, Ingres, etc.
4
NSF DUE-1205110; 0903270 Query Expressions (continue) Queries are used to perform tasks on database tables such as: Selects Inserts Updates Creates Deletes Simply put, queries are used to communicate with databases to get specific information on a selected portion of a larger database Saving the generated query can produce a new database without changing the original database
5
NSF DUE-1205110; 0903270 General Format of a Query Typical query expressions use the general form as follows: Select * From Where The table name that follows the keyword from specifies the table that will be queried to retrieve the desired results The where clause (optional) specifies which data values or rows will be returned or displayed
6
NSF DUE-1205110; 0903270 General Format of a Query (continue) Conditional selections used in the where clause: = Equal > Greater than < Less than >= Greater than or equal <= Less than or equal <> Not equal to LIKE
7
NSF DUE-1205110; 0903270 What Can SQL’s Do? Execute queries against a database Retrieve data from a database Insert records in a database Update records in a database Delete records from a database Create new databases Create new tables in a database Create stored procedures in a database Create views in a database Set permissions on tables, procedures, and views
8
NSF DUE-1205110; 0903270 Creating ArcGIS Queries ESRI provides an easy to use “Query Builder” tool to create the necessary queries without knowing how to write the SQL statement. Versions of Query Builder are used in several tools in ArcMap but the most common is from the Selection menu in the Standard toolbar. The two main options are: Attribute queries Spatial/Location queries
9
NSF DUE-1205110; 0903270 Anatomy of an Attribute Query Select appropriate action for data This screen allows the user to create the SQL expression easily without programming knowledge. The user selects the appropriate layer to query (layer), how to save it (method), the fields of interest, & the conditions that the user is wanting to pull out Available fields based on columns in the selected table Available values from selected table SQL Statement Box “Where” condition options
10
NSF DUE-1205110; 0903270 Attribute Query Example This is the completed screen once the users has chosen all the fields. In this example the query is going to “Create a new selection” based on the field “ProjectTyp” that meets the requirement of looking only at the “Final Subdivision”. This is a very simple query. It is important to remember, it is necessary to know what your data fields are before making your selection.
11
NSF DUE-1205110; 0903270 Attribute Query Example When the user opens the table associated with the query expression they will see something similar to what is below. Those rows that are selected will be outlined on the map showing their location relative to the other features of the dataset. In this example the total dataset contained 2465 records, only 40 met the criteria in the query expression.
12
NSF DUE-1205110; 0903270 Attribute Query Example When looking at the map the areas meeting the query conditions will be highlighted. This is only a temporary file, it is good to show visually where the conditions are and to completed some simple analysis on the data.
13
NSF DUE-1205110; 0903270 Attribute Query Example If this information is necessary for later use it is a good idea to save this as a separate or new data layer which can be pulled into the current project or future projects. When exporting the data be sure to select the right output location and select the correct file type
14
NSF DUE-1205110; 0903270 Advanced Attribute Query Example This is an example of a more complex query using the “equal to” and the “and” condition. This means that the only data to be returned must meet both conditions: Final Subdivision and Approved. This returned only 23 rows of data out of 2465 instead of 40
15
NSF DUE-1205110; 0903270 Attribute vs. Spatial Queries Query By Attribute Requires an SQL statement either generated in a command line or by using the Query Builder Can be simple with only one condition in the “where” clause or complex with multiple conditions Involves only one layer but can involve multiple fields Can be points, lines, or polygons Query By Location This query shows the spatial relationship to other features within the same layer or in another layer Base or source layer usually is a polygon feature More than one feature layer (point or line) can be chosen to pull data from multiple datasets
16
NSF DUE-1205110; 0903270 Anatomy of a Spatial Query Select the layer that is being used as the location or base layer, typically a polygon. Select appropriate action for data Choose which layers you want to have included in the search. Spatial queries allow for data from more than one layer to be displayed.
17
NSF DUE-1205110; 0903270 Anatomy of a Spatial Query (cont) Select appropriate action for selecting data Can apply a buffer to the search criteria
18
NSF DUE-1205110; 0903270 Spatial Query Example In this example the user wants to find all the Community Centers, Public Schools, and Points of Interest located in a specific Elementary School Zone which is highlighted by the blue outline. The selected zone was chosen with the selection tool, clicking on the polygon of interest. The blue circles are the facilities that met the criteria in the query from the target layers. 18
19
NSF DUE-1205110; 0903270 Spatial Query Example (cont) By opening the tables and choosing the selected points the user is able to see the information from each table on the selected features. Again, this is a temporary file and does not affect the original database. As with “Attribute Queries” if this is needed for later use the data must be saved from each layer into a new dataset. 19
20
NSF DUE-1205110; 0903270 Anatomy of an Individual Query There is a third type of query that is used quite often for a quick analysis of a layer. This is used by completing the following steps: Select layer Select “Properties” Select “Definition Query” tab Select “Query Builder” tool Create the query Verify Hit “OK” 20
21
NSF DUE-1205110; 0903270 Individual Query Example (cont) This is what the screen would look like before the query is run and then what it would look like after the query is run. Remember this query was run on only one layer, the elementary school zones. This could then be used for quick analysis or as a starting point for the spatial query to look at the data within the selected zones. Remember this is still just a temporary file and does not change the original database 21
22
NSF DUE-1205110; 0903270 Questions? Wen M. Andrews Professor and Program Head Department of Architectural & Civil Engineering Technology J. Sargeant Reynolds Community College Richmond, Virginia wandrews@reynolds.edu
Similar presentations
© 2024 SlidePlayer.com. Inc.
All rights reserved.