[GIS] How to subset X number of features from shapefile in QGIS

clippolygonqgisshapefilevector

I'm looking for a means to take a rather large shapefile and split it out into separate, smaller shapefiles based on number of features. So for example, if I have a file with 1 million features, subset it out into smaller files of 100k features each.

I know how to grid a shapefile and subset into smaller files, but I don't want to grid it as I want to preserve the original feature geometry (e.g. gridding polygons will ruin the geometry).

Does anyone know how this can be done with QGIS?

Best Answer

Is there a field in the attribute table you can use to group the smaller sets by? If so, you can use ogr2ogr's -sql switch to specify a query that will pull just those records and export them to their own shapefile.

Boston GIS's site has a nice ogr2ogr cheatsheet if you need an example to work from

http://www.bostongis.com/?content_name=ogr_cheatsheet

That said, with a million records I would stuff that sucker into a PostGIS database. It would almost certainly be faster to work with, especially if those features are complex.