5

This is a very simple question but a Google search did not provide an answer.

Basically suppose you have a map of the U.S. with states and county layers, as well as other layers like roads, etc.

I want to work with a map of only one state, with all layers (e.g. counties, roads, etc) in that state.

I remember in ArcGIS it had something to do with taking an intersection, not sure how it works in QGIS.

3 Answers 3

4

I can think of two ways to do this:

  1. If all the layers have an attribute that tells you what state they're in, you could add a query to the layer (definition query in the Esri world) along the lines of STATE='CA'. This will only work if you have this attribute on all layers.

  2. Alternately, you can enable the Spatial Query plugin (Plugins -> Manage Plugins) and use it to accomplish this task:

    1. Select the state on the states (polygon) layer using whatever tools you like (e.g., attribute table or interactive selection).
    2. Open up the Spatial Query window (Plugins -> Spatial Query -> Spatial Query).
    3. Set it to select source features from one of your layers (leaving the 'n selected geometries' box unchecked - that would create a subset of the current selection on that layer). We'll call this layer the source layer.
    4. Set the method ('Where the feature') to 'Intersects'. You want to use intersects, not within, because otherwise you'll lose features that lie partly in the state but not fully in it. Also, if there are slivers in the polygon layers, some polys might not be selected at the edges.
    5. You can create a new layer after you've selected what you want by right-clicking the layer name in the Layers pane and choosing Save selection as...; note that it will save it in the projection of the project, not the projection of the source.

    Repeat this procedure for each layer. Be aware of http://hub.qgis.org/issues/3518

3

Take a look at this similar question: QGIS- How to create an “area of interest” polygon mask

If you just want to direct your readers attention to a specific area without modifying each feature layer, you might consider creating a "mask" polygon to hide the underlying features. The mask polygon will effectively be a donut where the donut hole allows you to see only the individual state(s) you are interested in.

0

Select the State of interest with (one of) the selection tools, then save it as a separate vector (ie shapefile) with the "save selection as..." dialog.

Then load it to the canvas and use it to clip the other layers (e.g. counties, roads, etc.) with the "clip" tool you find in the "vector" menu.

The "clip layer" would be the state one (the one used to clip), where the "input layer" will be the layers you want to clip.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.