ArcGIS
Example using 'ERASE' Operator:
Cut out the industrial area from two block
groups near Sherman and Walden St. in Cambridge (near Fresh
Pond). The folder, cambridge_lecture7.zip,
in the class data locker contains all the files needed for this
example.
Cambridge block groups: STCNTRBG
= 250173546003 and 250173546001
with Industrial land use (LU21_CODE=16)
overlaid across Sherman St.
|
|
Choose the ERASE extract tool in
ArcToolbox
|
|
Use the industrial land use boundaries
to erase the industrial parts of the two block groups
|
|
End up with the industrial area cut out
from the two block groups
|
|
BEWARE: all attribute values are retained in
attribute table - even if no longer correct (e.g., area,
perimeter, and landacre). You can recalculate area and
perimeter, but the change in landacre is unknown. (Do you
understand this?) |
|
|
Note that the new area of the block groups is reduced by
the erased area.
|
ArcGIS
Example of 'polygon-in-polygon' operation
(to
find which blockgroups are in which town for your use in
Homework #2)
- Here are the steps we used to produce the
Town/Blockgroup cross reference table (so the homework would
be easier and you would not have to figure out all these
steps):
- A 'Spatial Join' involving
polygon-to-polygon operations will have problems
- It results in many 'sliver' issues
along the edges of the blockgroups and town boundaries
- Instead, compute centroid of
blockgroups and then do a point-in-polygon operation to
find all the blockgroups in Cambridge and the surrounding
towns
- Recent versions of ArcGIS can do this
easily by:
- Using the 'centroid within' choice
when doing a 'spatial join' polygon-on-polygon
operation, (see the parameters for the 'spatial join'
operator in ArcToolbox), or
- Using the 'calculate geometry'
options in the 'field caculator' to add fields with
the XY centroid values
- We will do it the 'long way' to
demonstrate the use of Python code and visual basic
scripts (VB Script) to grab data from the in-memory ArcMap
geometry and save the values in attribute columns of
shapefile layers
- How
can we compute (and save) centroid XY values
?
- Centroids are interior points 'close' to
the 'middle' of a polygon
- What should be the centroid of a C-shaped polygon?
- Beware, ArcMap centroids are *not* guaranteed to be
interior to the polygon
- How can you tell if a point is 'inside' of a polygon?
- Centroids are NOT part of 'shapefile' data
model - which only stores boundaries
- BUT, they are already computed and
available in the runtime ArcMap data model
- Use ArcGIS help to find
a way: look up 'Centroid - calculating coordinates' in
ArcGIS help
- First, simplify the task by selecting the
blockgroups in the 5-town area around Cambridge
- Select blockgroups in and around the 5 towns and
save to a new shapefile (blkgrp_start.shp)
- add empty fields (called centX and centY) to the
attribute table of blkgrp_start (as double
precision numbers)
- Strategy: using Python code (for ArcGIS
version 10+) to pull centroid X,Y data from the ArcMap
data model into the XY fields of the attribute table
- You may read about Python coding in the online
ArcGIS help files.
- Right click on your new X field and select
Calculate Values...
- Click the 'Python' button in the 'Parser' section at
the top and then set centX to be the python expression
for the 'X' portion of the 'centroid' parameter of the
feature layer: !shape.centroid.X!
- There is no need to click the Show
Codeblock box.
- Click 'OK' to calculate the values and then repeat
for centY
- Use
DataManagement/Add-X-Y-data option in
ArcToolbox to create a pin map of the centroids
(search for 'XY' and find the 'make XY event layer' tool to
turn the centroid columns into a mappable point layer)
- Once you can see the pin map, you still
need to turn it into a shapefile in order for ArcGIS to
be able to use it in a 'join by location' operation.
Otherwise, ArcMap will complain that it does not know
the coordinate system for the newly created
cambbgrp_layer of block group centroids.
- Export the pin map into a point
shapefile 'blkgrp_c_shape' of
the XY centroids and add it back into your table of
contents
- Finally,
Use the point-in-polygon spatial join
operation (join-by-location) to attach town attribute
information to the point attribute table 'blkgrp_c_shape'.
- Right-click on the 'blkgrp_c
shape' layer and choose the 'join'
option from the 'joins & relates' menu
item,
- Instead of joining attributes based on
relating two tables, we want to 'join data from another
layer based on spatial location'
- The layer we want to join to the selected
layer (blkgrp_c shape) is the town layer
(which we called cambridge5 when we saved
the 5-town boundaries above),
- This operation will add the columns in the
cambridge5 attribute table to the columns
in the 'blkgrp_c Events' attribute table
where the rows are matched based on the town that contains
each block group centroid. The results are stored in a new
shapefile with the same block group centroid points and the
expanded attribute table.
- You won't be able to do the spatial join
unless each of the layers you are joining have a known
spatial reference system - because the spatial join won't be
meaningfull unless both layers can have all their coordinate
expressed (or transformed) into the same coordinate system.
- This expanded attribute table has the
blk_key in one column and, now, the town name and code in
another column. So, we turned off all the columns except for
blk_key and Town and and selected only those blockgroups in
the 5 towns. Exporting this table produced the
block-group-to-town (blkgrp2t.dbf) lookup
table that we have included in the 11.520 data locker for
your use in HW#2.
Homework
#2, part 2: This will take some time! Spread out the work!
- start
early,
focus on spatial operations for suitability analysis
- save
often, take care in naming intermediate files, save several
*.mxd project files early and often - with different version
numbers as you move along.
- expect
to redo overlays a few times before you like result (so you
need to remember the saved pieces and combine them into new
projects)