We have a polygon. We want to create a grid (sort of) with certain intervals, let's just say - 200ms. In QGIS, using "Vector grid" option we can do this. But, once it's get clipped, it's like Fig -1. Obviously the purpose of clipping is to a smooth and perfect snap.

But, while field surveying (for which the map is going to be used) we can't just end the line perfectly with the AOI (polygon). At times, field person will not be able to do that. So what we would like to do is, extend the grid lines equally on all sides so that the whole survey line will be traversed properly.

Currently, some of my colleagues are doing this using MapObjects wherein which we can Round-off north end to, say 20. Which means, if the north coordinate for a line is 2906161, it will be rounded off to 2906170 (the next round integer). Since we have very limited number of licenses for MapInfo, I just want to try it with QGIS. Hope it can be done using Python script. If not, is it possible to do this through Model builder?

enter image description here

  • If I understand your query properly what u need is to extend line to 20m where it got intersect with boundary of polygon.. Is it so..? Commented Aug 27, 2014 at 9:59
  • Yes. But the extend distance will change according to the AOI. If it is a perfect rectangle 10m will be suffice.
    – joseph_k
    Commented Aug 27, 2014 at 10:17
  • Is it possible for you to share sample data..? Commented Aug 27, 2014 at 10:56
  • @Sanjayr Don't know where to share the sample data.
    – joseph_k
    Commented Sep 2, 2014 at 5:49

2 Answers 2


Easiest solution would be to create a buffer of 20m around your polygon, and clip the grid to that.

You can always re-clip the grid to the exact polygon later.

  • Till now, we are doing the same. But desperate to know how to do this through python. I'll edit my question and try to share the Mapbasic code which we are using now to extend lines
    – joseph_k
    Commented Sep 2, 2014 at 5:46

The open-source GIS Whitebox Geospatial Analysis Tools has a tool called Extend vector lines that can be used to perform this task exactly. From the help documentation:

This tool can be used to extend vector lines by a specified distance. The user must input the names of the input and output shapefiles, the distance to extend features by, and whether to extend both ends, line starts, or line ends. The input shapefile must be of a POLYLINE base shape type.

It could be that other GIS have a similar tool too, but as a developer of Whitebox, I am most familiar with its functionality.

enter image description here

  • Thank you. But the thing is, our survey - field guys are going to do this and they prefer to do all the process in one software, either in QGIS or in Whitebox. So, is there any grid maker sort of tool is available in Whitebox ? Or is it possible to use the same python code in QGIS environment(i've tried. But it didn't work out)
    – joseph_k
    Commented Sep 2, 2014 at 5:15
  • @saravanaganesh18, There is a tool called Create Rectangular Vector Grid (in fact there is a Create Hexagonal Vector Grid tool too), that might be of use for this purpose, I'm not sure. Commented Sep 2, 2014 at 14:44

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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