QGIS Tutorial 2: Exporting part of a vector layer to its own shapefile

In the first walk-through using QGIS v. 2.0.1, we loaded the US Census Bureau’s Tiger/Line Shapefiles for all counties in the US as a vector layer. We then filtered the layer to show the state of Vermont. However, all counties in the US are still  there. If we go back to the Query Builder and clear the STATEFP = 50 query, the vector layer will return, showing the counties for the entire United States. Assuming we want to work with all of the counties in the United States, this is great.

However, my focus is a single state. It is easier to carve out a single state shapefile, save file size space, computer memory and avoid having to deal with multiple queries later in the project.

Saving a smaller subset of the vector layer as a shapefile
  • click on Project | Open (or, Project | Open recent) and load the QGIS project for Vermont
  • in the Layer pane click on the layer file name, tl_2013_us_county, to ensure it is selected/highlighted
  • in the Layer menu, select Save as… (if Save as is grayed out, the layer file name was not selected)

QGIS 02-06b

The Save vector layer as dialog box will appear.

Hopefully, ESRI Shapefile is selected as the Format. If not, click on the drop down box and select this option. Note the entry I typed into the Data Source box. Documenting the source of the original data might prove useful when I need to re-work my map a year or so from now.

Also, click the check box for Add saved file to map.

Once satisfied with the settings, click on the OK button.

QGIS 02-07b

A typical Windows save dialog will launch. Navigate to where you want to save the new shapefile and save it.

Please help…

I am still looking for a way to set a default save or working directory in QGIS…without success. So far in my experience, QGIS does not always go back to the last used location. If you know how to set a default working directory within QGIS, please share in the comments.

If you forget to check the box for Add saved file to map or, for some reason want to wait and add the layer later, the process is the same as with the first walk-through; either:

  • use the Layer | Add Vector Layer, or
  • using Window’s explorer, drag the new shapfile to the map pane

Regardless of the method used, we should now have two layers in our project:

QGIS 02-08b

Notice the the check box for the tl_2013_us_county is selected. Click on the x and turn this layer off. We could just remove the entire US counties layer by clicking on the layer name and then using the Layer | Remove Layers (or, control-d, or by right-clicking on the layer name), but this layer might prove useful later. Turn it off for now.

Let’s take a look at our new shapefile
  • double-click on the smaller Vermont shapefile name in the Layer pane
  • click on Layer | Properties (or, double-click on the shapefile)
  • under General note that Query Builder is now empty

Outside of QGIS, navigate to the saved location via Windows Explorer and take a look a the file size. The new shapefile is much smaller than the original .

As with any project:

  • save  early
  • save often
Please comment

Please share in the comments any thoughts, correction, tips or tricks relating to this walk-through.

Next time: adding county level data to the shapefile

Create a custom atlas of maps suitable for scribbling upon

Fieldpapers.org lets you zoom in on an area and save the map to an Adobe .pdf printable multi-page atlas. The authors, Stamen Design, also include a map template with room for notes and they encourage users to upload annotated maps which, in turn, will help improve the OpenStreet effort. According to the site’s About page, Fieldpapers builds upon walkingpapers.org (another interesting mapping site ripe for exploration), OpenStreet and other open source GIS efforts.  The site offers free customizable maps in black and white line drawing as well as color satellite views.

My first atlas took me several attempts as I kept messing up the scale, unable to get a street level print out. Considering it is a free site, the developer was very responsive to my emailed questions. Turns out I was missing the obvious. I had to increase the number of pages and then use the “grid grabber” located on the lower right corner of the page grid. Once I scaled the print grid to optimize coverage of the area I wanted, I downloaded my custom 50 page, street level atlas.