[GRASSLIST:1828] Creating a DEM

Hi,

I'm trying to create a DEM from a "scannerized" map, because of the
large amount of feature I thought to extract in some way the contour
lines using r.thin and r.line, then I heard that maybe there is som
problems in doing that (something like r.surf.contour doesn't work fine
yet..).
Well, is my idea possible to do? I know that any line will be
reproduced but I wanted to eliminate manually by v.digit the "not-
contour" lines.
Anyway, even it I decide to copy all contour lines point by point, is
there a working feature in GRASS to create the DEM?

Thanks, Michele

On Fri, 11 May 2001, michele.rocc@libero.it wrote:

Hi,

I'm trying to create a DEM from a "scannerized" map, because of the
large amount of feature I thought to extract in some way the contour
lines using r.thin and r.line, then I heard that maybe there is som
problems in doing that (something like r.surf.contour doesn't work fine
yet..).

The present weakness with r.surf.contour is only that it does not generate
floating point output, just CELL. However, in my experience it works well,
and we have used it to produce output with much less "dominance" of
contour valued terraces than interpolating treating contours as sites. If
you look at the "leics" example files, you will find that that is how the
"topo" layer was constructed. It does run quite slowly for very large
regions, and you may need to watch local troughs and summits, but I
wouldn't drop r.surf.contour unless you have a better alternative for use
with contour data.

Roger

--
Roger Bivand
Economic Geography Section, Department of Economics, Norwegian School of
Economics and Business Administration, Breiviksveien 40, N-5045 Bergen,
Norway. voice: +47 55 95 93 55; fax +47 55 95 93 93
e-mail: Roger.Bivand@nhh.no
and: Department of Geography and Regional Development, University of
Gdansk, al. Mar. J. Pilsudskiego 46, PL-81 378 Gdynia, Poland.

On Fri, May 11, 2001 at 10:33:14AM +0200, michele.rocc@libero.it wrote:

Hi,

I'm trying to create a DEM from a "scannerized" map, because of the
large amount of feature I thought to extract in some way the contour
lines using r.thin and r.line, then I heard that maybe there is som
problems in doing that

Hi,

maybe my last mail on r.line was confusing. In fact it does what's expected
(generates vector lines from raster lines even with diagonal lines. Hi Aldo
Clercini, maybe it's what you have been looking for).

(something like r.surf.contour doesn't work fine yet..).

It does, however it is still limited to CELL maps (no floating point dem's).
You can use it with fp maps as well, but will loose the precision.

Well, is my idea possible to do? I know that any line will be
reproduced but I wanted to eliminate manually by v.digit the "not-
contour" lines.
Anyway, even it I decide to copy all contour lines point by point, is
there a working feature in GRASS to create the DEM?

You may use the v.surf.rst which runs very well and produces smooth DEMs.

Regards

Markus

On Fri, May 11, 2001 at 12:24:08PM +0200, Andrea Aime wrote:

Hi everybody,
some time ago I was told that DEM generated from contour lines
suffer some problems and that it's better to start from sites...
anyone can confirm/reject this? In general, what's the best starting
point to generate a DEM? Are r.surf.contour and v.surf.rst equivalent?
Regards
Andrea Aime

Hi Andrea,

(I cc to the list)

no, the r.surf.contour and v.surf.rst differ. While r.surf.contour is using
an flood fill algorithm for linear interpolation and v.surf.rst is using
regularized splines with tension.

I have added this to the r.surf.contour html page right now (found the
explanation in the old mailing list archive).

Hope this helps,

Markus

Markus Neteler wrote:
>
> On Fri, May 11, 2001 at 10:33:14AM +0200, michele.rocc@libero.it wrote:
> > Hi,
> >
> > I'm trying to create a DEM from a "scannerized" map, because of the
> > large amount of feature I thought to extract in some way the contour
> > lines using r.thin and r.line, then I heard that maybe there is som
> > problems in doing that
>
> Hi,
>
> maybe my last mail on r.line was confusing. In fact it does what's expected
> (generates vector lines from raster lines even with diagonal lines. Hi Aldo
> Clercini, maybe it's what you have been looking for).
>
> > (something like r.surf.contour doesn't work fine yet..).
> It does, however it is still limited to CELL maps (no floating point dem's).
> You can use it with fp maps as well, but will loose the precision.
>
> > Well, is my idea possible to do? I know that any line will be
> > reproduced but I wanted to eliminate manually by v.digit the "not-
> > contour" lines.
> > Anyway, even it I decide to copy all contour lines point by point, is
> > there a working feature in GRASS to create the DEM?
>
> You may use the v.surf.rst which runs very well and produces smooth DEMs.
>
> Regards
>
> Markus

--
Markus Neteler * University of Hannover
Institute of Physical Geography and Landscape Ecology
Schneiderberg 50 * D-30167 Hannover * Germany
Tel: ++49-(0)511-762-4494 Fax: -3984

Hi,
is it possible to refer to different
categorie-values in a single raster-map? (maybe stored in
a database with the database-interface) I want to do a
mapcalc expression somehow like:

r.mapcalc test = 'if(raster==1 and raster$tabelinfo2 == 3,1,0)'

Thanks,
Dieter

----------------------------------
Dieter Lehmann
University of applied Sciences
Schelmenwasen 4-8
D-72622 Nuertingen, Germany
lehmann@fh-nuertingen.de
Phone: +49 (0) 7022 404 Ext. 207
Fax: +49 (0) 7022 404 Ext. 209

Date: Thu, 11-May-01 12:00:00 +0000 (GMT)
Time: 13:57:20

----------------------------------

Grass raster approach is to store on category for each
raster map: if you want two attributes you'll use two raster
maps. If they refer to the same phenomena, you may use a
map name convention, such as a common prefix:

r.mapcalc test = if(raster_a1 == 1 and raster_a2 == 3, 1, 0)

Hope this helps
Andrea Aime

Dieter Lehmann wrote:

Hi,
is it possible to refer to different
categorie-values in a single raster-map? (maybe stored in
a database with the database-interface) I want to do a
mapcalc expression somehow like:

r.mapcalc test = 'if(raster==1 and raster$tabelinfo2 == 3,1,0)'

Thanks,
Dieter

----------------------------------
Dieter Lehmann
University of applied Sciences
Schelmenwasen 4-8
D-72622 Nuertingen, Germany
lehmann@fh-nuertingen.de
Phone: +49 (0) 7022 404 Ext. 207
Fax: +49 (0) 7022 404 Ext. 209

Date: 11-May-01
Time: 13:57:20

----------------------------------

Hi,
thanks Andrea, sometimes the simplest solution is the best...

Another question:

I don't find a way to extract only the borderlines from rasterized polygons.
I need this borders in a new raster map (for expample the borders between two
different soil types).

I found the script r.edge.dig. It's not exact what I need because this
extract only between two given categories and not between all
values in a given raster map.

Another attemp was to use r.poly, but I don't find the way to make lines from
the areas (the other way round there is a script available). After that I would
use v.to.rast

Thanks a lot.
Dieter

On 11-May-01 Andrea Aime wrote:

Grass raster approach is to store on category for each
raster map: if you want two attributes you'll use two raster
maps. If they refer to the same phenomena, you may use a
map name convention, such as a common prefix:

r.mapcalc test = if(raster_a1 == 1 and raster_a2 == 3, 1, 0)

Hope this helps
Andrea Aime

Dieter Lehmann wrote:

Hi,
is it possible to refer to different
categorie-values in a single raster-map? (maybe stored in
a database with the database-interface) I want to do a
mapcalc expression somehow like:

r.mapcalc test = 'if(raster==1 and raster$tabelinfo2 == 3,1,0)'

Thanks,
Dieter

----------------------------------
Dieter Lehmann
University of applied Sciences
Schelmenwasen 4-8
D-72622 Nuertingen, Germany
lehmann@fh-nuertingen.de
Phone: +49 (0) 7022 404 Ext. 207
Fax: +49 (0) 7022 404 Ext. 209

Date: 11-May-01
Time: 13:57:20

----------------------------------

----------------------------------
Dieter Lehmann
University of applied Sciences
Schelmenwasen 4-8
D-72622 Nuertingen, Germany
lehmann@fh-nuertingen.de
Phone: +49 (0) 7022 404 Ext. 207
Fax: +49 (0) 7022 404 Ext. 209

Date: Thu, 11-May-01 12:00:00 +0000 (GMT)
Time: 16:03:23

----------------------------------

Hmmm... sorry, but I can't help you... I guess I should add an option
to r.poly in order to make it output border lines, not area features...
I hope to have enough time this weekend, that's not difficult to do...
but then you have to wait at least until Monday, and then get sources
from CVS and recompile. Now I'm leaving for weekend, I'll be back
on Monday
Regards
Andrea Aime

Dieter Lehmann wrote:

Hi,
thanks Andrea, sometimes the simplest solution is the best...

Another question:

I don't find a way to extract only the borderlines from rasterized polygons.
I need this borders in a new raster map (for expample the borders between two
different soil types).

I found the script r.edge.dig. It's not exact what I need because this
extract only between two given categories and not between all
values in a given raster map.

Another attemp was to use r.poly, but I don't find the way to make lines from
the areas (the other way round there is a script available). After that I would
use v.to.rast

Thanks a lot.
Dieter

On 11-May-01 Andrea Aime wrote:
> Grass raster approach is to store on category for each
> raster map: if you want two attributes you'll use two raster
> maps. If they refer to the same phenomena, you may use a
> map name convention, such as a common prefix:
>
> r.mapcalc test = if(raster_a1 == 1 and raster_a2 == 3, 1, 0)
>
> Hope this helps
> Andrea Aime
>
> Dieter Lehmann wrote:
>>
>> Hi,
>> is it possible to refer to different
>> categorie-values in a single raster-map? (maybe stored in
>> a database with the database-interface) I want to do a
>> mapcalc expression somehow like:
>>
>> r.mapcalc test = 'if(raster==1 and raster$tabelinfo2 == 3,1,0)'
>>
>> Thanks,
>> Dieter
>>
>> ----------------------------------
>> Dieter Lehmann
>> University of applied Sciences
>> Schelmenwasen 4-8
>> D-72622 Nuertingen, Germany
>> lehmann@fh-nuertingen.de
>> Phone: +49 (0) 7022 404 Ext. 207
>> Fax: +49 (0) 7022 404 Ext. 209
>>
>> Date: 11-May-01
>> Time: 13:57:20
>>
>> ----------------------------------

----------------------------------
Dieter Lehmann
University of applied Sciences
Schelmenwasen 4-8
D-72622 Nuertingen, Germany
lehmann@fh-nuertingen.de
Phone: +49 (0) 7022 404 Ext. 207
Fax: +49 (0) 7022 404 Ext. 209

Date: 11-May-01
Time: 16:03:23

----------------------------------

On Fri, May 11, 2001 at 04:24:58PM +0200, Dieter Lehmann wrote:

Hi,
thanks Andrea, sometimes the simplest solution is the best...

Another question:

I don't find a way to extract only the borderlines from rasterized polygons.
I need this borders in a new raster map (for expample the borders between two
different soil types).

I found the script r.edge.dig. It's not exact what I need because this
extract only between two given categories and not between all
values in a given raster map.

Another attemp was to use r.poly, but I don't find the way to make lines from
the areas (the other way round there is a script available). After that I would
use v.to.rast

Thanks a lot.
Dieter

Hi Dieter,

(funny, I am just proof-reading this in the ongoing translation of the
GRASS-Handbook)

an unelegant way might be to use r.poly and convert the resulting vector map
to ASCII vector (v.out.ascii). Then edit the file in $LOCATION/dig_ascii,
changing all "A " to "L " (take care to search for Aspacespace).
Then get it in with v.in.ascii, v.support and you are there. Unfortunately
all labels are lost (the v.llabel will enumberate them).

It would be great to have r.poly to generate lines with a flag or something
else doing this.

Hope this helps,

Markus

On 11-May-01 Andrea Aime wrote:
> Grass raster approach is to store on category for each
> raster map: if you want two attributes you'll use two raster
> maps. If they refer to the same phenomena, you may use a
> map name convention, such as a common prefix:
>
> r.mapcalc test = if(raster_a1 == 1 and raster_a2 == 3, 1, 0)
>
> Hope this helps
> Andrea Aime
>
> Dieter Lehmann wrote:
>>
>> Hi,
>> is it possible to refer to different
>> categorie-values in a single raster-map? (maybe stored in
>> a database with the database-interface) I want to do a
>> mapcalc expression somehow like:
>>
>> r.mapcalc test = 'if(raster==1 and raster$tabelinfo2 == 3,1,0)'
>>
>> Thanks,
>> Dieter
>>
>> ----------------------------------
>> Dieter Lehmann
>> University of applied Sciences
>> Schelmenwasen 4-8
>> D-72622 Nuertingen, Germany
>> lehmann@fh-nuertingen.de
>> Phone: +49 (0) 7022 404 Ext. 207
>> Fax: +49 (0) 7022 404 Ext. 209
>>
>> Date: 11-May-01
>> Time: 13:57:20
>>
>> ----------------------------------

----------------------------------
Dieter Lehmann
University of applied Sciences
Schelmenwasen 4-8
D-72622 Nuertingen, Germany
lehmann@fh-nuertingen.de
Phone: +49 (0) 7022 404 Ext. 207
Fax: +49 (0) 7022 404 Ext. 209

Date: 11-May-01
Time: 16:03:23

----------------------------------

--
Markus Neteler * University of Hannover
Institute of Physical Geography and Landscape Ecology
Schneiderberg 50 * D-30167 Hannover * Germany
Tel: ++49-(0)511-762-4494 Fax: -3984

Another question:

I don't find a way to extract only the borderlines from rasterized
polygons. I need this borders in a new raster map (for expample the borders
between two different soil types).

I found the script r.edge.dig. It's not exact what I need because this
extract only between two given categories and not between all
values in a given raster map.

Another attemp was to use r.poly, but I don't find the way to make lines
from the areas (the other way round there is a script available). After
that I would use v.to.rast

Hi Dieter, (cc to Markus, cc to GRASSLIST)
I've looked at the problem at home, and I've prepared another version
of r.poly that has a flag to output border lines, and not area features. I've
sent it to Markus so you'll find it in the CVS next week (well, I hope so).
Now, I don't know if you can use CVS, so I've also found another solution:
here you'll find v.area2line, a script that does the opposite of v.line2area.
After running v.line2area you'll have to run v.llabel in order to attach a
label to each line, and finally v.to.rast to get borders in raster format.
I also found a solution based on a fully raster approach: let's say that
you raster map is r_area. Then you can extract borders in the following way:

r.neighbors r_area o=r_area_diff m=diversity
r.mapcalc
r_area_border=if(r_area_diff>1,1,null())

You may also want to run r.thin on results to get one pixel wide borders.
Hope this helps. Regards
Andrea

PS: Markus, would you add v.area2line to GRASS5? Althought it's a new
command, it's only a slightly modified version of v.line2area...

-------------------------------------------------------------------------
Here's the source for v.area2line. You must put it in
$GISBASE/scripts/v.area2line and make it executable using
chmod a+x v.area2line
-------------------------------------------------------------------------

#!/bin/sh
#################################################################################
*** This is v.area2line . ***
#
# @(#) takes lines and translates them to areas by taking the file out to
ASCII,# @(#) changing the 'A's to 'L's, then bringing the file back in
# @(#) dig_att file is not copied back since area labels cannot match
# @(#) lines correctly
#
# Written by Andrea Aime (aaime@libero.it),
# based on v.line2area by Rick Thompson (CAST)
#
################################################################################
if [ "$1" = "-help" -o "$1" = "help" ]
then
echo v.area2line vectormap
exit
fi

if [ `uname -m` = mips ] ; then
  ECHON="/usr/bsd43/bin/echo -n"
elif [ `uname -s` = SunOS -a `uname -r | sed 's/\...*$//'` = 5 ] ; then
  ECHON="/usr/ucb/echo -n"
else
  ECHON="echo -n"
fi

clear
echo ''
if [ $# = 1 ] ; then
  name="$1"
else
  g.ask type=old prompt="Which vector map to translate?" element=dig
desc=vector unixfile=/tmp/$$
  . /tmp/$$
  rm -f /tmp/$$
  if [ -z $name ]; then
    echo "Vector map $name not found."
    exit
  fi
fi

################################################################################
v.out.ascii in=$name out=$name
cat $LOCATION/dig_ascii/$name | sed 's/A /L /' > $LOCATION/dig_ascii/$name.2
v.in.ascii in=$name.2 out=$name.2
v.support -r $name.2 op=build
rm $LOCATION/dig_ascii/$name $LOCATION/dig_ascii/$name.2

echo ''
$ECHON "Want to rename $name.2 to $name? (n) "
read ans
if [ "$ans" = "Y" -o "$ans" = "y" ] ; then
  g.rename vect=$name.2,$name
  echo ''
  echo "$name now contains lines."
else
  clear
  echo ''
  echo "$name.2 now contains lines."
fi