Download presentation
Presentation is loading. Please wait.
Published byScott Gilbert Modified over 8 years ago
1
Faculty of Applied Engineering and Urban Planning Civil Engineering Department 2 nd Semester 2008/2009 GIS
2
Queries and table operations for a single layer in Arc GIS Intro to queries in Access
3
Queries and table operations for a single layer
4
Queries: New Selection A simple query in Arc GIS PRICE > $250,000.
5
Queries: New Selection That results in the following selection on the map
6
Queries: New Selection And it also selects the corresponding records in the attribute table
7
Four query methods in Arc GIS Create a New Selection Add to Current Selection Remove from Current Selection Select from Current Selection
8
Queries: New Selection Here’s an example with a polygon layer: Identify all census block groups with a population density of more than 250 people/square mile.
9
Multiple Criteria Query: The AND operator High density block groups (>250 per/sq mi) where median household income is greater than $50,000/year
10
Multiple Criteria Query: Select from selected records High density block groups (>250 per/sq mi) where median household income is greater than $50,000/year
11
Multiple Criteria Query: The OR operator Select all records where the price is greater than $250,000 OR the house was built after 1970
12
Multiple Criteria Query: Add to selected records Select all records where the price is greater than $250,000 OR the house was built after 1970
13
Queries: Strings Queries can also be made on text strings, but it is imperative to put the values in quotes. Here we query for both BLM and Parks and Rec land.
14
Queries: Strings and numbers String and number queries can be combined. For example, let’s say we’re looking for land for a suburban park and our criteria are that we need areas whose land use is classed as agricultural and that are bigger than 500,000 square feet.
15
©2007 Austin Troy Queries: Strings and numbers Results in:
16
Queries: Strings and numbers Whereas if our query asks for agricultural land use without the area criterion, we get:
17
So what can Arc GIS do with queries? A query selects records; once selected you can: Look at the selection Requery the selection Do stats on the selection Create new fields that recategorize the selection by an attribute field Create new fields by doing calculations across several fields Create a shapefile from the selection
18
Examples Let’s query high unemployment census tracts in LA
19
Right click on the heading to get this menu Now let’s calculate “statistics” to determine the population in those areas. Answer: almost 5 million people live in tracts with 6%+ unemployment (see Sum). We can also see that there are 844 tracts meeting that description (see Count)
20
Another thing we can do is convert the selection to a new shapefile or geodatabase feature class Right click data layer >> Data >> Export data
21
Now, let’s say we wanted to prioritize inner city areas for urban redevelopment projects: Let’s query based on unemployment and home value Based on these we’ll create a new field that classes all tracts into High, Medium and Low priority areas Tracts with median home value 12% are “High”
22
To reclassify, we create a new field, “priority”, activate the field heading and use the field calculator to set all selected records to “high” Note: we must uses quotes with a text field
23
Identifying “medium” priority parcels is a bit more complex because we’re querying for records, say, between 8 and 12% unemployment and between $100,000 and $150,000 median value.
24
Now, for the third class our task is easier—we just select everything that has not been selected yet. To do this we query for “priority”= ‘’ By putting empty quote marks, you’re querying for records with no values in them for that field. Now you’d set all those fields equal to “low.”
25
Now we can make a category map showing us that classification based, which is based on two attributes—median value and unemployment
26
Another example: This time, let’s take a vegetation layer and query for stands with crown fire potential
27
Then let’s calculate a fire hazard index for selected polygons equal to 0.5(rate of spread * flame length) We’ll create a new field, “fireindex” (floating point) and calculate the values of the selected polygons
28
Finally, for all other polygons without crown fire potential, a different equation can be used, say.38(rate of spread * flame length). But first we have to take the inverse of the selection by using the “switch selection” function Then we can do the new calculation on the new selection
29
Now we can plot out the map of fire index, plotted out using graduated color (quantity) mapping
30
Introduction to queries in Access
31
Access and Arc GIS queries You can do all these queries and much more in MS Access, which is a relational DBMS. For the most part, you’ll use Access to manipulate and query your attribute tables from geodatabases This can be done because a geodatabase is an MS Access file (.MDB) There are six basic queries you can do in Access: Select, cross-tab, make table, update, append, delete
32
Access Queries Select: the most general purpose and versatile query—creates a new temporary table; used for getting summary statistics for a field, or breaking down summary statistics by category Cross-tab: for summarizing statistics across two factors (row and column) Make table: for creating a new, stand-alone data table from a query Update query: this is where we fill a field (could be an empty field) in an existing table with new values, either equal to a constant, to values in another field or to an operation using values from another field; can use Where criteria on this Append/delete queries: query that defines rows to append to or delete from a table; append queries usually require another table.
33
Access Queries Queries can be used to: Summarize information stored in one or many tables (e.g. sales by year, sales by category, sales by saleperson, sales by date, orders by date, orders by product type, orders by zip code) Create new fields using simple or complex expressions, with the option of using criteria to specify which records will be filled in for that field Derive averages, maxima, minima, sums, standard deviations, and counts for values in fields, with or without criteria Derive those same things for categories within a field Summarize and ask questions of attribute data stored in different tables
34
Access Queries Example of query run to get sums of sales values across product categories:
35
©2007 Austin Troy Relational attribute queries Here’s an Access select query; note how it queries across various linked tables This one asks for a summary of sales by category and product name for the dates between 1/1/1997 and 12/31/1997
36
Advanced Single layer query operations Queries can be used to return statistics: here we get the mean price from a database of housing sales
37
Advanced Single layer query operations And here we summarize mean price by zip code
38
Remember the food database?
39
©2007 Austin Troy Advanced Single layer query operations This simple select query yields a summary table of sales by category for a given year period: generates a mean value for each category criteria relates
40
Advanced Single layer query operations This select query perform a math operation: it multiplies price and quantity, times a discount and delivers a table of order subtotals
41
Advanced Single layer query operations Here we sort sales by product and city operation criteria
42
Advanced Single layer query operations Here we sort sales by city only
43
©2007 Austin Troy Advanced Single layer query operations Queries can also be used to make reports, like this invoice
44
Multi-layer vector query operations in Arc GIS Vector Spatial Joining
45
1. Multi-layer vector queries in Arc GIS
46
Let’s say we want get information about all the houses in four sample neighborhoods and see which ones overlay fire hazard zones Selecting By Location
47
Now with “sample houses” active, we click select by theme and tell it to choose features that intersect the features of fire hazard zone Layer to be selected Selection Method Selection rule Selection overlay theme Selecting By Location
48
Those that overlay a hazard zone are selected selected Not selected Selecting By Location
49
…Zooming in to one of those neighborhoods Selecting By Location
50
Now run statistics on the selection; 1955 houses overlay fire zones; mean price is $467,551! Selecting By Location
51
Invert selection; non fire zone houses are worth less on average!Only $246,752 Selecting By Location
52
Select houses within 1 mile of a Starbucks Selecting By Location: Distance
53
©2007 Austin Troy This time we use a different selection method with different parameters Selecting By Location :Distance Note how we can specify the distance for selection
54
Results in the following selection Selecting By Location :Distance
55
Zooming into a neighborhood… Selecting By Location :Distance
56
Now if we run statistics on price again… Selecting By Location :Distance Those within a mile of a Starbucks have a mean value of $504,972 Those not within a mile of a Starbucks have a mean value of $273,866! By the way, these are real data, I’m not making this up!!
57
For that same selection we could get statistics on a different variable—here we’ll look at lot size Selecting By Location :Distance Those within a mile of a Starbucks have a mean size of 8776 square feet Those not within a mile of a Starbucks have a mean lot size of 10,024 sq feet. Why might that be?
58
©2007 Austin Troy Linear feature: selecting houses in a neighborhood within a mile of a highway Selecting By Location :Distance Note that these smaller roads are in a different layer
59
©2007 Austin Troy Selecting based on existing selection Find homes within 500 meters of Valley Blvd. (let’s say there’s going to be a parade and the city needs to inform all those homeowners near that street). Query Hwyname = “Valley Blvd” Selecting By Location :Distance
60
©2007 Austin Troy Once that feature is selected we can do a “select by location” operation Selecting By Location :Distance Notice that this time we check “Use selected features”
61
Thus we end up only selecting those houses within 500 m of Valley Blvd, and none within 500 m of other roads Selecting By Location :Distance
62
©2007 Austin Troy Spatial overlap problem: whole polygon will be selected even if only a small part is coincident, assuming we are using the default selection overlay method, “intersect.” Selecting By Location: Polygons However, there are many other methods we can choose from that will change the number of polygons selected.
63
Example: let’s select any census tract that intersects even slightly with a fire zone; here’s the pre- selection map Selecting By Location: Polygons
64
Using the “intersect” overlay method we get this Selecting By Location: Polygons
65
Using “that are completely within” method, we get no selected feature. But, with “have their center in” we get Selecting By Location: Polygons
66
Likewise, if we select Merced County in the counties layer, activate “highways” in the TOC, and then select by theme, we will only choose those road segments that intersect that county Selecting By Location on Selections
67
Note that the resulting selection was made using the “intersect method.” If the “completely within” method is used, a different set of lines will be selected Selecting By Location on Selections
68
Left: intersect method Right: completely within method Selecting By Location on Selections
69
Once a selection has been done using “select by location” you can do all the same things you would do with a normal single-layer selection: Make a new layer from the selection Do statistics on it Make a new field in that layer (e.g.a field called “Parade”, where “yes” means the house is within 500m of the parade route). Calculate or recalculate a field for a selection What can be done with multi-layer selections?
70
2. Vector Spatial Joining — assigning attributes by location
71
Spatial Join Assigns attribute data from features in one layer to spatially coincident features in another Can assign polygon data to a point that overlays Can assign point to point and point to line distances between two layers Simply adds attributes to the DBF table
72
Spatial Join We access Spatial Join by right clicking on the “to” layer and clicking Joins and Relates>>join We then specify that we want to join by location and choose which layer we are joining from
73
Spatial Join In this case we are going to join tracts to the houses from our sample neighborhoods. Each house inherits all the attributes of the tract in which it falls. Note that this creates a new layer
74
Spatial Join Plot of houses graduated by percent unemployment of the tract to which they belong
75
Spatial Join: Distance We can also do spatial joins based on distance. Whenever we join a point or line layer to another point or line layer, for each feature in the To layer it gives us the attributes of the nearest feature in the FROM layer PLUS the distance between those features in whatever map units we specify
76
Spatial Join: Distance Use Spatial Join to assign as attribute to our house point layer the name of the nearest major road.
77
Spatial Join: Distance Two options: choose to numerically summarize for each point the values of the lines intersecting it, or assign all attributes from the nearest line. My FROM layer
78
Spatial Join: Distance Now name of nearest highway is an attribute for each housing point
79
Spatial Join: Distance Distance from each point to the nearest road feature was also recorded under the attribute “Distance.”
80
Spatial Join:Distance We can also do a join to get the distance from a series of points in one layer to a series of points in another: here is distance of houses to nearest Starbucks
81
Spatial Join: Polygons What about polygons? Problem: a polygon is layer A may overlay several polygons in layer B, so whose attributes to you give it? Layer A Layer B
82
Spatial Join: Polygons Answer: we can do spatial join and summarize (by average, for instance) each polygon in layer A the values of all the overlapping polygons in layer B. Example: Marketing study; have a census tract layer with all sorts of demographic info (population, race, etc) and a zip code layer with no demographic info attached to it. Client needs map showing median age and percent Hispanic by zip code.
83
Spatial Join: Polygons Unfortunately, the tract boundaries and zip code boundaries do not match up in the slightest. Note that tracts are not nested within zip codes—they cut across
84
Spatial Join: Polygons Do a spatial join of two polygon layers and choose the “summarize” option (the first radio button). Choose a statistic by which to summarize values
85
Spatial Join: Polygons Plot of median age
86
Vector Limitations Multi-layer vector polygon analysis is limited in that generally polygons in different layers are of different sizes and shapes: irregular minimum mapping unit Next ; we will discuss how vector reprocessing can be used to help overcome this to a certain extent Geoprocessing includes methods by which vector features are broken down into smaller features, or aggregated into larger features.
87
Vector Geoprocessing
88
Geoprocessing Geoprocessing is the processing of geographic information. Three general classes of tools 1- Breaking features into smaller features (e.g. Clip, Intersect, Union) 2- Aggregating features into larger features (e.g. Dissolve, Merge) 3- Creating new polygon features through buffering (e.g. Buffer)
89
Geoprocessing in ArcGIS Perform geoprocessing in ArcGIS Run a tool using its dialog box. Run tools at a command line. Build and run a model Create and run a script
90
Geoprocessing in ArcGIS Perform geoprocessing in ArcGIS Run a tool using its dialog box.
91
Tools: Geoprocessing Tools for breaking down the size of map features: Union, Intersect, Clip Tools for increasing the size of map features: 1. dissolve and merge (indirectly) 2. Arc/Info and Arc Toolbox include various other geoprocessing overlay operations, such as Update and Dissolve Regions
92
Union Combines features of two or several themes Keeps all line work Breaks down features, and creates new polygons Keeps all attributes
93
Tools: Union Polygons only A list of Polygons
94
Find the Geoprocessing Tools
95
Intersect Yields polygons representing areas that are common to both layers Preserves line work within common extent Usually creates many new, smaller polygons Preserves all attributes from both
96
Tools: Intersect Two features
97
Union vs. Intersection Union is the union of two overlapping set of features and intersection is the intersection Layer 1 + Layer 2 Intersect: “1 AND 2” “1 OR 2” Union: Layer 2Layer 1 +
98
Union vs. Intersection: Example Here’s an example. Say we have deer wintering areas in one layer and conserved lands in another.
99
Union vs. Intersection: Example Union gives us land that is EITHER conserved OR that is a deer wintering areas
100
Union vs. Intersection: Example Intersect gives us land that is BOTH, and preserves all polygon boundaries within that common extent
101
Clip This uses one theme to “clip,” or serve as the outer boundary of another theme Breaks down features into smaller units Preserve the input theme’s attributes Point, line & polygon Polygon
102
Tools: Clip Point, line, polygon Polygon
103
Clipping highways Note that the “use selected features only” option was used
104
Clipping roads
105
Dissolve Tool for aggregating polygons—making them bigger. Single layer operation
106
Tools: Dissolve
107
Dissolve: Example Dissolve zip codes (small) into counties (large)
108
Dissolve: Example Choose the dissolve field: e.g. Dissolve based on the County field
109
Dissolve : Example Summarize the resulting field values. For instance, I could sum population for each county
110
Dissolve : Example Now we have created a county map, and for each county we have an attribute as the sum of population of the constituent zip codes
111
Merge Allows you to “join” two adjacent or non-adjacent themes into the same layer Like “tiling” Best when attributes match
112
Tool: Merge
113
Merge Often when you merge you will want to follow up by dissolving.
114
Tools: Buffering Buffering is when you draw a polygon around a feature (point, line or polygon)
115
Tools: Buffering Based on distance Based on attribute
116
Tools: Variable Width Buffering
117
Combining Geoprocessing Tools Involve multiple tasks performed in sequence, such as those that clip, buffering, intersect, union, then select datasets. – Create and run a script – Build and run a model – Step by step
118
Combining Buffering and Geoprocessing: Example Question: How to find areas that are near deer wintering areas and water bodies but far from traffic? Geospatial Data Polygon layer for deer wintering areas Polygon layer for Water bodies Roads layer: line features
119
Combining Buffering and Geoprocessing: Example Question: How to find areas that are near deer wintering areas and water bodies but far from traffic? – Areas that are near deer wintering areas AND water bodies: – Combining the layers: Intersect – “Near” or “Far from”: Buffering Union – Selecting: Query for areas that are not within a traffic buffer
120
Combining Buffering and Geoprocessing: Example Buffering: Made fixed buffers around deer wintering areas and water bodies, and a variable buffer around roads, based on traffic
121
Combining Buffering and Geoprocessing: Example Intersecting: The intersection of deer wintering buffers and water buffers (the area in the red)
122
Combining Buffering and Geoprocessing: Example The union of that intersection with the traffic buffer:
123
Combining Buffering and Geoprocessing: Example Selecting: Query for polygons that are not within (far from) a traffic buffer
124
Combining Buffering and Geoprocessing: Example Create a new layer by exporting the selected features (polygons)
Similar presentations
© 2025 SlidePlayer.com. Inc.
All rights reserved.