30

Is it possible to create layers from selection in QGIS?

I am using QGIS 1.7.4-Wroclaw.

To make it easier for others to see this, here are some pics. I used QGIS 2.0.1-Dufour.

SELECT

enter image description here

SAVE

enter image description here

ADD enter image description here

  • It works a similar way to ArcGIS see johns answer. See more and more user/clients want to switch to QGIS- it is comparable to ArcView license and direct connect to PostGIS makes it better than ArcGIS in my book. – Mapperz May 25 '12 at 14:29
  • If QGIS works similar to ArcGIS, I guess I will not have tough time switching – Stat-R May 25 '12 at 14:35
  • @Mapperz Can you please suggest me place where I can find standard tutorials? Googling does not seem to give me any comprehensive resource. – Stat-R May 25 '12 at 14:40
  • QGIS Documentation site has the QGIS User Guide, or the QGIS 2.0 Training Manual is in the works by Linfiniti. – RyanDalton Jan 24 '14 at 15:47
  • 1
    Is it possible in QGIS 2.0? I can't find the way. – user26553 Feb 26 '14 at 16:24
21

After making a selection in a layer, right click on it and choose save selection as.


Update for QGIS 3.2 Bonn as of 2018

As this is the accepted answer and the way of doing this has evolved somewhat, beginners might find this answer incomplete, so:

After making a selection in a layer, right click on it and choose "Export" > "Save Selected Feature As..."

menu selection

which is actually just a nice redundancy, because it takes you to the same mask as clicking "Save Feature As...", but it already checks the box "Save only selected features"

Save Vector Layer As Mask

  • 2
    Note that you can make a selection using the 'select' tool, but also can run queries directly on a layer with a right-click and selecting "Query..." and then construct a search (which will then hide items that don't match). "Save as" will then save just the displayed features. – Simbamangu May 25 '12 at 15:09
  • Using can be much quicker if you have lots of features that are spread out over the map. Saves selecting them one at a time, or using the inbuilt search. – Nathan W May 26 '12 at 2:35
  • @johns that isn't the same as making a layer on a selection ... what you've described is saving a new shapefile entirely... – DPSSpatial Jan 24 '14 at 16:24
13

A new feature just came up in QGIS 2.2 called "Paste as new vector layer":

It is a common activity in a GIS to create a sub-selection and then to create a new layer from the selection. In QGIS you can already do save selection as to save a layer from your selection, and now offers functionality that allows you to create a new file or memory layer from whatever is in your clipboard. Simply select some features, copy them to your clipboard and then do Edit -> Paste features as and choose either New vector layer or New memory layer from the submenu. The best part of this new feature is that if you have some Well Known Text (WKT) features in your clipboard from another app, you can simply paste them into QGIS as a new layer now.

  • 1
    New memory layer is the trick – geotheory Jun 17 '14 at 16:40
  • That is a great tool - thanks for sharing, very helpful! – Kristina Dec 3 '14 at 18:53
  • Sadly, it has some unlisted limits - i.e., it works if I select, say, 100 points from a vector layer but if I select some 20000 points then copying to clipboard fails silently. – Peteris Feb 23 '16 at 19:40
  • Which is the difference between "new vector layer" and "new memory vector layer"? – Andreu Amoros Oct 5 '16 at 9:25
  • 2
    When you copy a selected feature and paste as a new vector layer, it will open the 'save layer as' dialogue box and save as a new shapefile. New Memory Vector layer only persists in the QGIS document (and will persist when you open it next time if you have the memory layer saver plugin installed) @AndreuAmoros – DPSSpatial Oct 5 '16 at 14:11
10

In QGIS 2.6.2 Brighton, you can do the following:

  1. Select features
  2. Right click on the layer
  3. Save as...
  4. Select the option "Save only selected objects"
  5. Save

That should do

  • 5
    The "save selection as..." feature has been deprecated in favor of this new method - so this answer is now the correct way to save selected features to a new layer. – SaultDon Feb 16 '15 at 18:07
  • This also works for 2.8 Wien – Freeze Apr 15 '15 at 10:52
6

Or right-click on the layer, choose "Query", and write a SQL construct. This is analagous to creating a "Definition Query" in ArcGIS if you do not want to write a new shapefile to disk.

  • 1
    that still isn't the same as the arcgis 'save selection as layer' concept... If you do an ArcMap query or set of queries and end up with a selected set, how would you replicate that in a new layer based on a "query" in QGIS? I just don't think the same ability is in QGIS as in ArcMap - not saying it should be...just saying its not there. – DPSSpatial Jan 24 '14 at 16:27
  • An update for anyone who comes across this and finds this answer helpful, as I did. In QGIS 2.2, right-click on a layer and choose "Filter" and write a SQL statement. – Barbarossa Dec 17 '14 at 23:39
1

I actually miss the older version's option to Save selection as new layer. I'm using QGIS 2.6.0 Brighton and using Edit > Paste options as just doesn't work. One attempted workaround was to create a new layer, then paste features into that layer, however this does not appear to have copied any attribute data for me.

Therefore my solution has been to:

  1. Copy desired layer.
  2. Make my selection.
  3. Open attribute table.
  4. Invert selection.
  5. Delete unwanted features.
  6. Save.
0

I'm using QGIS 2.10.1-Pisa. To save selected features with PyQGIS, you can try the following:

import processing
##Once selection has been done
#Layer which contains selected features
layer= iface.activeLayer()
#Specify where you want to save your new file (in my case)
result='C:\Users\Cesar Araya\Desktop\Test\selected.shp'
#Using geoprocessing alg "Save selected features"
processing.runalg('qgis:saveselectedfeatures', layer, result)
#Add saved file to map
processing.load(result)

Reference: https://docs.qgis.org/2.8/en/docs/user_manual/processing_algs/qgis/vector_general_tools/saveselectedfeatures.html

0

In QGIS 2.18.17, make the selection using either a filter or manual selection then right-click on the layer in the Layer Panel, then select 'Save As'. As you only want to save the selection select the tick-box for selection only.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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