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

John Ciolek jciolek at alphatrac.com
Wed Jan 8 16:46:30 PST 2014


On Jan 8, 2014, at 12:35 PM, Markus Metz wrote:

> 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?

I am trying to create areas from the contours, where the areas clip to the set region.

> 
> 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


Wouldn't this create a very blocky contour?  

The contouring is done in batch mode for a real-time modeling system.  Right now I'm thinking it would be easiest to write a program to add one extra point to the vector if the first and last points do not match.  Was hoping for an easier way.

John





More information about the grass-user mailing list