1

Is there a way in QGIS or opensource GIS to split a shapefile containing point objects into multiple temporary shapefiles each containing 1 object (i.e. each point to a new scratch shapefile)?

Needed to insert in a routine where I will call each temporary individual point shapefile, as the routine isn't set up to cycle through multiple points within the original source file.

  • What version of QGIS are you using? In 3.2 you might try Processing Toolbox - Vector general - Split vector layer and have it save to a temporary layer which is the default generally. But I haven't used it to make sure it adds the layers. – johns Jul 6 '18 at 16:37
  • In 3.2, the split vector layer tool has an option to "save to temporary folder" but it doesn't load the layers to the project as temporary layers, and I'm not sure where the temporary folder is. In 3.0, this tool doesn't have the option to create temporary layers. – csk Jul 6 '18 at 17:07
2

Use the Split vector layer tool to output each feature into a separate layer.

This requires that the layer has a field with a unique value for each point. If your layer doesn't have a unique identifier field, follow this process to add one:

Field Calculator > Create a new field >

  • Name: UID
  • Output field type: Integer
  • Expression: @row_number

enter image description here

Run the Split vector layer tool (Processing Menu > Toolbox > Vector general > Split vector layer tool). Use the unique identifier field where the tool ask for a Unique ID field. Use the default Output directory, [save to a temporary folder].

enter image description here

The flaw with this tool (hopefully to be fixed in future versions) is that there's no option to automatically add the output layers to your project. This means you have to go digging around in your computer's file structure to figure out where the temporary folder is. On Windows I found it by going to:

  • C:\Users\ myusername \AppData\Local\Temp\

  • In the Temp folder, look for a folder called processing_ followed by a long string of letters and numbers. It may help to view the folder in details mode, sort by date and look for a folder created today.

  • The processing_ folder contained a single folder with a random string of letters and numbers for a name. This folder contained a folder called OUTPUT. The shapefiles were in the folder called output.

  • The shapefiles are named after the unique ID field, followed by an underscore and a number.

Summary: C:\Users\ myusername \AppData\Local\Temp\ processing_random\ random\OUTPUT\UID_1.shp, UID_2.shp, etc.

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.