Geographic Information Systems Stack Exchange is a question and answer site for cartographers, geographers and GIS professionals. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I'm looking for a means to take a rather large Shape file 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?

share|improve this question

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

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.

share|improve this answer

If you just want to sample X number of features from a vector file:

  • QGIS has a function in the vector menu "Research tools" called Random selection within subjects. Open this tool and calculate a subset containing any number or percentage of X features within your vector layer.

If you want to totally separate your polygon into equal parts:

  • The way to go would be to create a separate attribute field with an index and attach it to your vectors attribute table. I would create the column with a R or a python-script. Afterwards execute the Dissolve-Tool from your vector menu and choose your newly created column.

Of course there might be an easier solution if you use PostGIS.

share|improve this answer

If you don't have postgis available and don't need multi-user access then load the shapefile into a spatialite db, the speed is amazing and even that many records would be a breeze.

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

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