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.
Geographic Information Systems Stack Exchange is a question and answer site for cartographers, geographers and GIS professionals. It only takes a minute to sign up.Sign up to join this community
After making a selection in a layer, right click on it and choose save selection as.
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..."
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"
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 asto 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 asand choose either
New vector layeror
New memory layerfrom 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.
In QGIS 2.6.2 Brighton, you can do the following:
That should do
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.
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:
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)
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.