Take the 2-minute tour ×
Geographic Information Systems Stack Exchange is a question and answer site for cartographers, geographers and GIS professionals. It's 100% free, no registration required.

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

3 Answers 3

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.

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

 
discard

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.