44

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.

Selecting
enter image description here

Saving
enter image description here

Adding
enter image description here

6
  • 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
    Commented May 25, 2012 at 14:29
  • If QGIS works similar to ArcGIS, I guess I will not have tough time switching
    – Stat-R
    Commented May 25, 2012 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
    Commented May 25, 2012 at 14:40
  • QGIS Documentation site has the QGIS User Guide, or the QGIS 2.0 Training Manual is in the works by Linfiniti. Commented Jan 24, 2014 at 15:47
  • 1
    Is it possible in QGIS 2.0? I can't find the way.
    – user26553
    Commented Feb 26, 2014 at 16:24

7 Answers 7

34

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

4
  • 3
    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
    Commented May 25, 2012 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
    Commented May 26, 2012 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... Commented Jan 24, 2014 at 16:24
  • Thank you for updating the answer, made things much simpler to find :) Commented Nov 10, 2021 at 14:39
23

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.

6
  • 1
    New memory layer is the trick
    – geotheory
    Commented Jun 17, 2014 at 16:40
  • That is a great tool - thanks for sharing, very helpful!
    – Kristina
    Commented Dec 3, 2014 at 18:53
  • 1
    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
    Commented Feb 23, 2016 at 19:40
  • 1
    Which is the difference between "new vector layer" and "new memory vector layer"? Commented Oct 5, 2016 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 Commented Oct 5, 2016 at 14:11
13

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

2
  • 6
    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
    Commented Feb 16, 2015 at 18:07
  • This also works for 2.8 Wien
    – Freeze
    Commented Apr 15, 2015 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.

2
  • 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. Commented Jan 24, 2014 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
    Commented Dec 17, 2014 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

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.

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\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

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.