Opened 11 years ago

Last modified 6 years ago

#2324 new defect

v.to.rast: useless area warning on points-only maps

Reported by: neteler Owned by: grass-dev@…
Priority: normal Milestone: 7.6.2
Component: Vector Version: svn-releasebranch70
Keywords: v.to.rast Cc:
CPU: Unspecified Platform: Unspecified

Description

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.

Change History (9)

comment:1 by annakrat, 11 years ago

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.

comment:2 by hcho, 11 years ago

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 */
    }
...
}

comment:3 by hcho, 11 years ago

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);
    }

comment:4 by neteler, 10 years ago

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

comment:5 by martinl, 9 years ago

Milestone: 7.0.07.0.5

comment:6 by neteler, 8 years ago

Milestone: 7.0.57.0.6

comment:7 by neteler, 7 years ago

Milestone: 7.0.67.0.7

comment:8 by martinl, 6 years ago

Milestone: 7.0.77.6.1

comment:9 by martinl, 6 years ago

Milestone: 7.6.17.6.2

Ticket retargeted after milestone closed

Note: See TracTickets for help on using tickets.