GIS Summer Institute - Harvard University
Transcript of GIS Summer Institute - Harvard University
![Page 1: GIS Summer Institute - Harvard University](https://reader031.fdocuments.us/reader031/viewer/2022012506/61813a3727635824ec18db47/html5/thumbnails/1.jpg)
GIS Summer InstituteCenter for Geographic Analysis
Databases & Queries
![Page 2: GIS Summer Institute - Harvard University](https://reader031.fdocuments.us/reader031/viewer/2022012506/61813a3727635824ec18db47/html5/thumbnails/2.jpg)
Outline
Databases
Joining Tables
types of joins
spatial or non spatial
Queries
by attribute
by location
US Census data
![Page 3: GIS Summer Institute - Harvard University](https://reader031.fdocuments.us/reader031/viewer/2022012506/61813a3727635824ec18db47/html5/thumbnails/3.jpg)
GIS and Database Management
System (DBMS)
1. Non spatial or attribute data managed by
DBMS cannot be related to locations without
GIS
2. GIS has embedded DBMS, or links to a DBMS
for data management
3. GIS in combination with DBMS allows for
geographic search which is key to GIS data
retrieval
![Page 4: GIS Summer Institute - Harvard University](https://reader031.fdocuments.us/reader031/viewer/2022012506/61813a3727635824ec18db47/html5/thumbnails/4.jpg)
Role of
DBMS
![Page 5: GIS Summer Institute - Harvard University](https://reader031.fdocuments.us/reader031/viewer/2022012506/61813a3727635824ec18db47/html5/thumbnails/5.jpg)
Definitions
A database is a collection of files, an integrated set of data on a particular subject
A file is a collection of records
A record is a set of items for an object or event
An item is a description of an object or an event
Items, records, and files are usually linked according to some well defined structure
![Page 6: GIS Summer Institute - Harvard University](https://reader031.fdocuments.us/reader031/viewer/2022012506/61813a3727635824ec18db47/html5/thumbnails/6.jpg)
Geodatabase
Represents geographic features and
attributes as objects and is hosted inside a
relational database management system
Manages coverages, grids, and shapefiles
inside a database management system, or
DBMS
![Page 7: GIS Summer Institute - Harvard University](https://reader031.fdocuments.us/reader031/viewer/2022012506/61813a3727635824ec18db47/html5/thumbnails/7.jpg)
Joining Tables
Tables can be linked by a relational join
A primary key of a table is linked to another key on another table
Joins can be:
one-to-one
one-to-many
many-to-one
many-to-many
![Page 8: GIS Summer Institute - Harvard University](https://reader031.fdocuments.us/reader031/viewer/2022012506/61813a3727635824ec18db47/html5/thumbnails/8.jpg)
Keys
Foreign Key
Primary Key
Primary Key
![Page 9: GIS Summer Institute - Harvard University](https://reader031.fdocuments.us/reader031/viewer/2022012506/61813a3727635824ec18db47/html5/thumbnails/9.jpg)
Types of Joins: Example 1
One to one
Census tracts
Income by household for each census tract
![Page 10: GIS Summer Institute - Harvard University](https://reader031.fdocuments.us/reader031/viewer/2022012506/61813a3727635824ec18db47/html5/thumbnails/10.jpg)
Types of Joins: Example 2
One to Many
One Town has
Many homes sold
![Page 11: GIS Summer Institute - Harvard University](https://reader031.fdocuments.us/reader031/viewer/2022012506/61813a3727635824ec18db47/html5/thumbnails/11.jpg)
Types of Joins: Example 3
Many to Many
Parcels and Owners
![Page 12: GIS Summer Institute - Harvard University](https://reader031.fdocuments.us/reader031/viewer/2022012506/61813a3727635824ec18db47/html5/thumbnails/12.jpg)
Spatial data and non spatial
data joins
![Page 13: GIS Summer Institute - Harvard University](https://reader031.fdocuments.us/reader031/viewer/2022012506/61813a3727635824ec18db47/html5/thumbnails/13.jpg)
Add Data Table in ArcMap
![Page 14: GIS Summer Institute - Harvard University](https://reader031.fdocuments.us/reader031/viewer/2022012506/61813a3727635824ec18db47/html5/thumbnails/14.jpg)
Download Shapefile
![Page 15: GIS Summer Institute - Harvard University](https://reader031.fdocuments.us/reader031/viewer/2022012506/61813a3727635824ec18db47/html5/thumbnails/15.jpg)
Check Fields to Join
Problem!
Fields are not the same
![Page 16: GIS Summer Institute - Harvard University](https://reader031.fdocuments.us/reader031/viewer/2022012506/61813a3727635824ec18db47/html5/thumbnails/16.jpg)
SQL Query
SELECT tracts
FROM census_tracts_us
WHERE pop2010 > pop2000
ORDER BY tracts_ID;
![Page 17: GIS Summer Institute - Harvard University](https://reader031.fdocuments.us/reader031/viewer/2022012506/61813a3727635824ec18db47/html5/thumbnails/17.jpg)
Spatial SQL
Query: List the ID, population, and area of each tract listed in a
table with data about census block groups (B)
SELECT B.ID,B.Pop, Area(B.Shape)AS "Area"
FROM B
Query: Find the names of all tracts which are neighbors of the tract which includes 1730 Cambridge St in the table
SELECT B1.Name AS "Neighbors of 1730"
FROM B1, B2
WHERE Touch(B1.Shape,B2.Shape)=1
AND B2.Name =‘1730 cambridge st’
![Page 18: GIS Summer Institute - Harvard University](https://reader031.fdocuments.us/reader031/viewer/2022012506/61813a3727635824ec18db47/html5/thumbnails/18.jpg)
Attribute Query Example
Select tracts
that have had
population
increase since
2000
![Page 19: GIS Summer Institute - Harvard University](https://reader031.fdocuments.us/reader031/viewer/2022012506/61813a3727635824ec18db47/html5/thumbnails/19.jpg)
Attribute Query Example
![Page 20: GIS Summer Institute - Harvard University](https://reader031.fdocuments.us/reader031/viewer/2022012506/61813a3727635824ec18db47/html5/thumbnails/20.jpg)
Select
by
location:select all
tracts within
0.5 miles of
Charles river
![Page 21: GIS Summer Institute - Harvard University](https://reader031.fdocuments.us/reader031/viewer/2022012506/61813a3727635824ec18db47/html5/thumbnails/21.jpg)
![Page 22: GIS Summer Institute - Harvard University](https://reader031.fdocuments.us/reader031/viewer/2022012506/61813a3727635824ec18db47/html5/thumbnails/22.jpg)
Select by Location Query
![Page 23: GIS Summer Institute - Harvard University](https://reader031.fdocuments.us/reader031/viewer/2022012506/61813a3727635824ec18db47/html5/thumbnails/23.jpg)
Export Selection and Add
Layer
![Page 24: GIS Summer Institute - Harvard University](https://reader031.fdocuments.us/reader031/viewer/2022012506/61813a3727635824ec18db47/html5/thumbnails/24.jpg)
Spatial Joins
Join points, lines, areas to polygons
or vice versa
![Page 25: GIS Summer Institute - Harvard University](https://reader031.fdocuments.us/reader031/viewer/2022012506/61813a3727635824ec18db47/html5/thumbnails/25.jpg)
Spatial Joins
No common attributes
![Page 26: GIS Summer Institute - Harvard University](https://reader031.fdocuments.us/reader031/viewer/2022012506/61813a3727635824ec18db47/html5/thumbnails/26.jpg)
Spatial
Joins: how
many
restaurants and
grocery stores in
each tract?
![Page 27: GIS Summer Institute - Harvard University](https://reader031.fdocuments.us/reader031/viewer/2022012506/61813a3727635824ec18db47/html5/thumbnails/27.jpg)
Spatial Joins
![Page 28: GIS Summer Institute - Harvard University](https://reader031.fdocuments.us/reader031/viewer/2022012506/61813a3727635824ec18db47/html5/thumbnails/28.jpg)
US Census
![Page 29: GIS Summer Institute - Harvard University](https://reader031.fdocuments.us/reader031/viewer/2022012506/61813a3727635824ec18db47/html5/thumbnails/29.jpg)
Census Geographies
![Page 30: GIS Summer Institute - Harvard University](https://reader031.fdocuments.us/reader031/viewer/2022012506/61813a3727635824ec18db47/html5/thumbnails/30.jpg)
US Census historic data
![Page 31: GIS Summer Institute - Harvard University](https://reader031.fdocuments.us/reader031/viewer/2022012506/61813a3727635824ec18db47/html5/thumbnails/31.jpg)
Social Explorer
![Page 32: GIS Summer Institute - Harvard University](https://reader031.fdocuments.us/reader031/viewer/2022012506/61813a3727635824ec18db47/html5/thumbnails/32.jpg)
Other resources
http://gis.harvard.edu/icb/icb.do?keyword=k235&pageid=icb.page190080
![Page 33: GIS Summer Institute - Harvard University](https://reader031.fdocuments.us/reader031/viewer/2022012506/61813a3727635824ec18db47/html5/thumbnails/33.jpg)
At the end of this lab you
should be able to
Join a table to a shapefile using a
primary key
Do a spatial join
Query
By attribute
By location
Calculate statistics for an attribute
Save a selection as a new spatial
dataset