Читать книгу The GIS 20 - Gina Clemmer - Страница 23

Customize shapefiles

Оглавление

Shapefiles downloaded from the Census Bureau, or anywhere else, may need to be modified to suit your purposes. A great example is when you downloaded the county file. You had no option to download a county file only for your state. The only file given was at the national level, containing all counties for the entire US.

For the following exercises, it would be better to have a shapefile of counties only in your state (like the place shapefile). How do you do that? The Census Bureau does not provide the shapefiles that way. However, it is easy to carve up shapefiles. In the next few steps, you’ll isolate your state’s counties and create a new shapefile that contains just those counties.

1 1.In the table of contents, right-click the place (Cities) shapefile, and then click Open Attribute Table.

2 2.Find the column titled StateFP (the third column from the left), and make a note of your state’s two-digit FIPS code. For Alabama, this code is 01. Close the attribute table.


1 3.In the table of contents, right-click the county file, and then click Open Attribute Table.

2 4.Right-click the StateFP column heading, and then click Sort Ascending to organize the table by state. Scroll down and find the first record in the StateFP column that corresponds to your state’s FIPS code. Finding the code for Alabama is easy. The code for the state is 01, so the counties in this state are at the top of the attribute table.


1 5.Once you find the first record for your state, click the first gray cell at the beginning of the row that contains the first record for your state. Clicking the cell creates a bright-blue highlighted record on that line item. Continue to highlight the remaining records for your state by dragging the mouse down the records (you must be on the beginning gray cells to drag highlighting). Highlight all records in your state.

2 6.It is important to close the attribute table now. Notice that counties in your state are highlighted on the map. The attribute table and map are linked. You may need to zoom in to see your state more closely.


Now you’re going to create a new shapefile for just those counties in your state.

1 7.Right-click the Counties layer name in the table of contents. Click Data, and then click Export Data. Leave all default options, except click the Browse button and navigate to your save folder (under Folder Connections).


1 8.Name the file your state’s name plus Counties—for example, “AlabamaCounties.” From the “Save as type” list, select Shapefile. Click Save, and then click OK. When prompted with the box that says, “Do you want to add the exported data to the map as a layer?” click Yes. Notice that a new layer appears in the table of contents.


Now you can organize things a bit. The US county layer is no longer needed. So you can remove it.

1 9.In the table of contents, right-click the US county layer name (this file is your original county file), and then click Remove. Drag the place file into first position in the table of contents. Notice all the cities in your state, as well as all the counties.

TIP Never include spaces in file names.

The GIS 20

Подняться наверх