2

I want to divide a shapefile based on a 500x500m grid into a series of individual shapefile using the clip function, each only having the contents of one of the 500x500 areas.

May I ask how to do this?

The suggestions I found are primarily for using a single shapefile as a clip shape to cut through multiple layers. But there is no method to do this.

As shown below, I have a few building and a grid of 200m: enter image description here

I want to use each tile in the grid to clip the building layer and save the clipped part as a new layer: enter image description here enter image description here enter image description here

  • For clarifying the question: how many shapefiles are you expect to have as a result? – Mykola Kozyr Jan 15 '18 at 15:54
  • 4
    Possible duplicate of QGIS clipping lines with polygon grid – ahmadhanb Jan 16 '18 at 1:01
  • The QGIS clipping function as suggested will only divide the polygons in a a particular layer into sections corresponding to the grid, rather than saving each section into an independent new shp file or new layer. Plus, the attributes got lost in the clipping process ... – oat Jan 31 '18 at 3:35
2

You'll need to say what software you're using.

It's super easy with FME, you do the clip, so that features are split at the boundaries, but retain all the features, and then write an attribute to the features that need to be in each file. And then, you have a dynamic writer that puts features into files based on that attribute.

You'll be able to come up with a workflow with Python too, I think doing it file-based will be better, and use OGR to do the clipping, maybe even on the command line. But you might have success loading features into memory and doing a clip and write operation using Fiona, perhaps.

You may find success using the QGIS plugin called gridSplitter too.

  • This is what I'm looking for. Thanks, Alex, for your suggestion. – oat Jan 31 '18 at 3:53

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.