I have a very large shapefile of building polygons and a shapefile of the country they reside in (England). The building shapefile was built by merging 94 smaller shapefiles. Both files have the same CRS.

I have been trying to use the difference tool in QGIS to create a country polygon with holes in where the buildings are.

Oddly the tool completes after about an hour and adds the new difference layer but it is blank. I have 12 GB of RAM and 64bit QGIS but still suspect it's a memory/software issue as I tried the exact same worfklow with just a 25 sq km section of the polygons and it was fine.

Can anyone recommend alternative software (or alternative workflows) to try?

Examples: I wondered if I could load it into a PostGIS database and do a spatial query for example? OR if i could create a batch process to calculate the difference for each building file one after another.

  • 2
    Use Postgis if you can and use postgis.net/docs/ST_Difference.html related gis.stackexchange.com/questions/11592/… – Mapperz Oct 8 '15 at 17:31
  • 2
    If the shapefile is very large could it perhaps go over the file size limits when you add huge amounts of holes? BTW I fear that the monster polygon that you are building will be too heavy for practical use. – user30184 Oct 8 '15 at 17:38
  • I'll look at that thanks @mapperz. Yes the monster polygon is an experiment and might be an interim solution. – JonoPatterson Oct 8 '15 at 17:42
  • 1
    Yeah look into PostGIS for sure. Even a workflow where you use one layer after the other will be too much, you still have to load the monster polygon in each time. I mean you could always just try straight OGR too, or OGR via GRASS, but its likely that will fail the same way (I can't remember if the built-in QGIS difference function uses the OGR function or not). – Thomas Oct 8 '15 at 17:58
  • Even PostGIS isn't happy :0) day 1: last 30gb hdd drive space eaten before crashing out with a disk space error, using a create table and st_difference query. day 2 pure select st_difference ate up all the RAM. Plan C may be to break the country polygon down. Possibly time to learn more about raster operations too. – JonoPatterson Oct 11 '15 at 17:53

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.