My original file is thousands of points across the US. I would like to create separate files for each state and have them named using the attributes from the clip layer.

I have been able to get the separate files using Clip from the processing tool box but I then have to go in and rename each file. Is there a way to select the output name by attribute? I want each file named after the state they are in.

  • There is a python way
    – geoJshaun
    Jan 12, 2017 at 20:19
  • are you familiar with pyqgis? looks like overlaying the point and clip and copy the value from the clip layer 's attribute table will do the job. and it would be nice if you can put up some screen shot as well coz I am not quite sure what the clip layer is? Jan 12, 2017 at 20:26

1 Answer 1


you could use a slightly different approach. No code required. Note that this will only work if your polygon shapes don't overlap. But as you're talking about states, this should work for you :-

  1. use Query attributes by location from you points layer to your polygon layer, so each point inherits attributes from the polygon it falls inside. Join from your points layer to the polygon layer, and use the "Within" operator, and keep the other defaults ("Take attributes of first located feature", "Only keep matching records"). The latter means that any points not inside a state will not be kept.

  2. use Split vector layer on your joined points layer, and select the field you want to use to separate out the shapefiles. For example, each point should now have the state's name or other identifier.

Both of these options are under Vector > Data Management Tools

TIP: create a new empty directory/folder, and write to there in step 2. This doesn't give you the option (in 2.18 at least) to open the new layers in the canvas once it's finished. Doing this makes it easier to load your shapefiles back in afterwards.

Your shapefiles will be given names in this format

[original_layer_name]_[field name]_[Value].shp
  • Very cool, thank you. Sorry it took so long, I got pulled away onto another project. Nothing is more annoying then having to manually name a bunch of shapefiles.
    – brink
    Feb 2, 2017 at 23:27

Your Answer

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

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