[GRASS-dev] [GRASS GIS] #2324: v.to.rast: useless area warning on points-only maps

#2324: v.to.rast: useless area warning on points-only maps
-------------------------+--------------------------------------------------
Reporter: neteler | Owner: grass-dev@…
     Type: defect | Status: new
Priority: normal | Milestone: 7.0.0
Component: Vector | Version: svn-releasebranch70
Keywords: v.to.rast | Platform: Unspecified
      Cpu: Unspecified |
-------------------------+--------------------------------------------------
There is a small issue which confuses (new) users a lot:

{{{
# rasterizing a map with only points:
# GRASS 7.1.svn (nc_spm_08_grass7):~ >

v.info -t geodetic_pts | grep 'points\|areas'
points=29939
areas=0

# ... but there is an area related warning!:
v.to.rast input=geodetic_pts output=test use=attr attr=GDC_ID
WARNING: No areas selected from vector map <geodetic_pts>
Reading features...
  100%
Writing raster map...
  100%
Converted points/lines: 29939 of 29939
v.to.rast complete.
}}}

The issue is here:

{{{
vect2rast.c:

     Points = Vect_new_line_struct();

     if (use != USE_Z && use != USE_D && (ftype & GV_AREA)) {
         if ((nareas = sort_areas(&Map, Points, field, cat_list)) == 0)
             G_warning(_("No areas selected from vector map <%s>"),
                           vector_map);
}}}

but I don't know how to change the if() condition properly.

--
Ticket URL: <http://trac.osgeo.org/grass/ticket/2324&gt;
GRASS GIS <http://grass.osgeo.org>

#2324: v.to.rast: useless area warning on points-only maps
-------------------------+--------------------------------------------------
Reporter: neteler | Owner: grass-dev@…
     Type: defect | Status: new
Priority: normal | Milestone: 7.0.0
Component: Vector | Version: svn-releasebranch70
Keywords: v.to.rast | Platform: Unspecified
      Cpu: Unspecified |
-------------------------+--------------------------------------------------

Comment(by annakrat):

It seems to me that the condition is ok. You get the warning because the
default value of type parameter is point,line and area. So you should
specify explicitly type=point to avoid the warning. To avoid the confusion
the type parameter could be required but then we need to type more which
is probably not what we want.

BTW, I wonder why there is no warning about lines as well.

--
Ticket URL: <http://trac.osgeo.org/grass/ticket/2324#comment:1&gt;
GRASS GIS <http://grass.osgeo.org>

#2324: v.to.rast: useless area warning on points-only maps
-------------------------+--------------------------------------------------
Reporter: neteler | Owner: grass-dev@…
     Type: defect | Status: new
Priority: normal | Milestone: 7.0.0
Component: Vector | Version: svn-releasebranch70
Keywords: v.to.rast | Platform: Unspecified
      Cpu: Unspecified |
-------------------------+--------------------------------------------------

Comment(by hcho):

IMO, type=point,line,area means to select those types only if they are
valid type in the input map. If a map is point only, type=line,area should
be ignored and no warnings about areas should be printed.

{{{
int sort_areas(...)
{
...
     nareas = Vect_get_num_areas(Map);
     if (nareas == 0)
         return -1;
...
}

int vect_to_rast(...)
{
...
     if (use != USE_Z && use != USE_D && (ftype & GV_AREA)) {
         if ((nareas = sort_areas(&Map, Points, field, cat_list)) >= 0) {
             if (nareas == 0)
                 G_warning(_("No areas selected from vector map <%s>"),
                           vector_map);

             G_debug(1, "%d areas sorted", nareas);
         } /* else map with no areas */
     }
...
}
}}}

--
Ticket URL: <http://trac.osgeo.org/grass/ticket/2324#comment:2&gt;
GRASS GIS <http://grass.osgeo.org>

#2324: v.to.rast: useless area warning on points-only maps
-------------------------+--------------------------------------------------
Reporter: neteler | Owner: grass-dev@…
     Type: defect | Status: new
Priority: normal | Milestone: 7.0.0
Component: Vector | Version: svn-releasebranch70
Keywords: v.to.rast | Platform: Unspecified
      Cpu: Unspecified |
-------------------------+--------------------------------------------------

Comment(by hcho):

Maybe, even shorter:
{{{
     if (use != USE_Z && use != USE_D && (ftype & GV_AREA) &&
         ((nareas = sort_areas(&Map, Points, field, cat_list)) >= 0) {
         if (nareas == 0)
             G_warning(_("No areas selected from vector map <%s>"),
                       vector_map);

         G_debug(1, "%d areas sorted", nareas);
     }
}}}

--
Ticket URL: <http://trac.osgeo.org/grass/ticket/2324#comment:3&gt;
GRASS GIS <http://grass.osgeo.org>

#2324: v.to.rast: useless area warning on points-only maps
-------------------------+--------------------------------------------------
Reporter: neteler | Owner: grass-dev@…
     Type: defect | Status: new
Priority: normal | Milestone: 7.0.0
Component: Vector | Version: svn-releasebranch70
Keywords: v.to.rast | Platform: Unspecified
      Cpu: Unspecified |
-------------------------+--------------------------------------------------

Comment(by neteler):

(Reported in http://lists.osgeo.org/pipermail/grass-
user/2014-June/070411.html)

Points-only patching with v.patch reports the confusing messages:

{{{
Intersections at borders will have to be snapped
Lines common between files will have to be edited
The header information also may have to be edited
}}}

Likely only the last message should be shown in case that no areas/lines
are present.

--
Ticket URL: <http://trac.osgeo.org/grass/ticket/2324#comment:4&gt;
GRASS GIS <http://grass.osgeo.org>