[GRASS-user] r.contour fails to close a contour at the region's border

Markus Metz markus.metz.giswork at gmail.com
Wed Jan 8 11:35:14 PST 2014


On Thu, Dec 12, 2013 at 11:13 PM, John Ciolek <jciolek at alphatrac.com> wrote:
> I have automatically generated raster data from which I create a contour
> using r.contour.  Sometimes the "feature" to be contoured is not completely
> contained within the specified region.  When this happens, r.contour
> generates an open contour - basically the beginning line segment point does
> not equal the ending line segment point.
>
> Is there a way to get r.contour to close the contour at the region's border?

No. This is a feature of r.contour because it is impossible to tell
where a contour would continue if it hits the region's border.
>
> If not, is there an easy way to close the contour?

Why do you want to close the contour?

If you want to convert the contour lines to areas, you might instead
modify the raster with r.mapcalc, e.g. for contours at every 100 unit
step

r.mapcalc "surface.classified = int(surface / 100) * 100"

but here a value of 99 would be converted to 0, thus as an alternative

r.mapcalc "surface.classified = int((surface + 50) / 100) * 100"

which would convert e.g. all values >= 50 and < 150 to 100.

After that the classified raster could be converted to vector areas
with r.to.vect type=area

HTH,

Markus M


More information about the grass-user mailing list