# Is it possible to generate a boustrophedon pattern which fill a vector Region with GRASS?

Is it possible to generate a boustrophedon pattern which fill a vector Region with GRASS?

I have a vector region in GRASS. And I would like to generate a vector (a polyline) being the bostrophedon pattern which fill this region.

In the picture bellow, I have the "gray" area, and I would like to generate the red polyline automatically.

Is it possible with GRASS or another GIS tool ?

In a perfect world, the function will take the following argumets :

• A starting point (which must be anywhere in the area)
• A distance between two parallels lines
• A direction (a vector which will help to draw the pattern)
• Interesting question. How would you determine the starting point? "Top Left" may not always relate to a nice corner point as in your example. Feb 13, 2015 at 14:41
• I answered to your comment in the question Feb 13, 2015 at 15:47
• Probably something could be cooked up using PyGRASS: grass.osgeo.org/grass70/manuals/libpython/pygrass_index.html Feb 14, 2015 at 14:42
• Is the required output just an image with the lines drawn on it, or are you really after some output of coordinates that could be given to a tractor to most efficiently plough a field? Jul 5, 2015 at 8:40

I have no idea about how to build such function, but the steps to perform might be

1. Draw one line with the desired azimuth and create new lines with offset so that the polygon is totally covered.

1. Buffer the polygon for defining the gap between the polygon boundary and boustrophedon. Cut the lines at boundaries of the buffered polygon and keep the internal parts.

1. Connect the end and start points of the lines in correct order.

• I tried the same thing, I think you're onto something here. Steps 1 and 2 are fairly easy - or can be mocked up. Step 3 is trickier.. it might be possible in postgis to sort the points representing the `st_intersection()` of the parallel lines / inner buffer by their `ST_LineLocatePoint()` value along the inner buffer, and join alternate pairs. Dec 21, 2015 at 16:15
• If the boundary of the polygon has inner corners or spikes then the lines which connect end and start points may intersect the boundary. It is not difficult to test if intersection happens but what would be the right way to draw the linestring in such case and how to make it automatically? It may not be easy to find a general solution. Dec 21, 2015 at 18:32
• you're right, getting directions correct will be tricky. also, suspect this approach will have edge cases, e.g. u-shaped fields, or fields with holes :) Dec 21, 2015 at 18:37