Opened 5 months ago

Closed 4 months ago

#3689 closed enhancement (fixed)

v.rast.stats: add where option

Reported by: veroandreo Owned by: grass-dev@…
Priority: normal Milestone: 7.6.0
Component: Vector Version: svn-trunk
Keywords: v.rast.stats Cc:
CPU: Unspecified Platform: Unspecified

Description

Would you agree to add where option in G7:v.rast.stats? I find it useful in some occasions where user is interested in querying only some features meeting a certain category. I attach the diff

Attachments (2)

v_rast_stats_add_where.diff (1.4 KB) - added by veroandreo 5 months ago.
new patch adding where option in v.rast.stats
v_rast_stats_add_where_2.diff (1.5 KB) - added by mmetz 4 months ago.
patch to add where option o v.rast.stats, working with and without where option used

Download all attachments as: .zip

Change History (11)

comment:1 in reply to:  description ; Changed 5 months ago by mmetz

Replying to veroandreo:

Would you agree to add where option in G7:v.rast.stats? I find it useful in some occasions where user is interested in querying only some features meeting a certain category. I attach the diff

A where option would make sense. You need to add this where option to the call to G7:v.to.rast in G7:v.rast.stats.

comment:2 in reply to:  1 Changed 5 months ago by veroandreo

Replying to mmetz:

Replying to veroandreo:

Would you agree to add where option in G7:v.rast.stats? I find it useful in some occasions where user is interested in querying only some features meeting a certain category. I attach the diff

A where option would make sense. You need to add this where option to the call to G7:v.to.rast in G7:v.rast.stats.

Right! See new patch attached. I tested with:

v.rast.stats map=urbanarea@PERMANENT where="NAME == 'Raleigh'" raster=aspect@PERMANENT column_prefix=aspect method=number

and got expected results and no errors :)

Changed 5 months ago by veroandreo

Attachment: v_rast_stats_add_where.diff added

new patch adding where option in v.rast.stats

comment:3 Changed 4 months ago by veroandreo

MarkusM, do you think I can commit it now?

comment:4 in reply to:  3 Changed 4 months ago by mmetz

Replying to veroandreo:

MarkusM, do you think I can commit it now?

Have you tested your patch also if the new where option is not given? If this succeeds you can commit.

comment:5 Changed 4 months ago by veroandreo

I tested... it does not work. It keeps extracting only where="NAME == 'Raleigh'" even if I remove the column and do not set any where... I added this:

if where == "" or where == " " or where == "\n":
		where = None

but it does not work... There seems to be something I need to clean/remove from previous run, but do not know where nor how. Would you help me, please?

comment:6 in reply to:  5 Changed 4 months ago by mmetz

Replying to veroandreo:

I tested... it does not work. It keeps extracting only where="NAME == 'Raleigh'" even if I remove the column and do not set any where... I added this:

if where == "" or where == " " or where == "\n":
		where = None

but it does not work... There seems to be something I need to clean/remove from previous run, but do not know where nor how. Would you help me, please?

See attached patch.

Test commands for the NC sample dataset:

g.region rast=elev_state_500m
g.copy vect=railroads,myrailroads

v.rast.stats map=myrailroads raster=elev_state_500m column_prefix=ele method=average -d where="cat = 8802"
v.db.select map=myrailroads

v.db.update map=myrailroads col=ele_average val=NULL
v.rast.stats map=myrailroads raster=elev_state_500m column_prefix=ele method=average -d 
v.db.select map=myrailroads

v.db.update map=myrailroads col=ele_average val=NULL
v.rast.stats map=myrailroads raster=elev_state_500m column_prefix=ele method=average
v.db.select map=myrailroads

v.db.update map=myrailroads col=ele_average val=NULL
v.rast.stats map=myrailroads raster=elev_state_500m column_prefix=ele method=average -d where="cat = 8802"
v.db.select map=myrailroads

Changed 4 months ago by mmetz

patch to add where option o v.rast.stats, working with and without where option used

comment:7 Changed 4 months ago by veroandreo

Thanks so much, MarkusM! Committed in r73666. Milestone was set to 7.8, but is it worth a backport to next 7.6 release?

comment:8 in reply to:  7 Changed 4 months ago by mmetz

Replying to veroandreo:

Thanks so much, MarkusM! Committed in r73666. Milestone was set to 7.8, but is it worth a backport to next 7.6 release?

I think it's ok if you backport to 7.6

comment:9 Changed 4 months ago by veroandreo

Milestone: 7.8.07.6.0
Resolution: fixed
Status: newclosed

Milestone changed to 76 and change backported. Closing.

Thanks again, markusM :)

Note: See TracTickets for help on using tickets.