Opened 6 years ago

Closed 6 years 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 6 years ago.
new patch adding where option in v.rast.stats
v_rast_stats_add_where_2.diff (1.5 KB ) - added by mmetz 6 years 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)

in reply to:  description ; comment:1 by mmetz, 6 years ago

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.

in reply to:  1 comment:2 by veroandreo, 6 years ago

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

by veroandreo, 6 years ago

Attachment: v_rast_stats_add_where.diff added

new patch adding where option in v.rast.stats

comment:3 by veroandreo, 6 years ago

MarkusM, do you think I can commit it now?

in reply to:  3 comment:4 by mmetz, 6 years ago

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 by veroandreo, 6 years ago

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?

in reply to:  5 comment:6 by mmetz, 6 years ago

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

by mmetz, 6 years ago

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

comment:7 by veroandreo, 6 years ago

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

in reply to:  7 comment:8 by mmetz, 6 years ago

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 by veroandreo, 6 years ago

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.