Random selection of a given number of points/pixels per class

classic Classic list List threaded Threaded
3 messages Options
SBL
Reply | Threaded
Open this post in threaded view
|

Random selection of a given number of points/pixels per class

SBL

Dear devs,

 

Recently, I was trying to generate a fixed number of random points per class in a vector or raster map.

 

So I looked at both v.random and r.random. However, neither seemed to give me the desired result:

v.random with restrict option seems to generate points per area even if areas belong to the same class and share the same cat value.

r.random does not have a restrict option.

 

So I ended up writing a small script that basically loops over the classes and extracts n points/pixels per class from a input raster map. My question now is did I overlook some less obvious feature of v.random or r.random?

If not I might create a small wrapper addon…

 

Cheers

Stefan


_______________________________________________
grass-dev mailing list
[hidden email]
https://lists.osgeo.org/mailman/listinfo/grass-dev
Reply | Threaded
Open this post in threaded view
|

Re: Random selection of a given number of points/pixels per class

Anna Petrášová
r.sample.category in addons seems like what you want?

On Fri, Aug 30, 2019 at 3:59 AM Stefan Blumentrath <[hidden email]> wrote:

Dear devs,

 

Recently, I was trying to generate a fixed number of random points per class in a vector or raster map.

 

So I looked at both v.random and r.random. However, neither seemed to give me the desired result:

v.random with restrict option seems to generate points per area even if areas belong to the same class and share the same cat value.

r.random does not have a restrict option.

 

So I ended up writing a small script that basically loops over the classes and extracts n points/pixels per class from a input raster map. My question now is did I overlook some less obvious feature of v.random or r.random?

If not I might create a small wrapper addon…

 

Cheers

Stefan

_______________________________________________
grass-dev mailing list
[hidden email]
https://lists.osgeo.org/mailman/listinfo/grass-dev

_______________________________________________
grass-dev mailing list
[hidden email]
https://lists.osgeo.org/mailman/listinfo/grass-dev
SBL
Reply | Threaded
Open this post in threaded view
|

Re: Random selection of a given number of points/pixels per class

SBL

Yes, thanks! Thats it. Thanks also for reviewing the PR so quickly!

 

Cheers

Stefan

 

From: Anna Petrášová <[hidden email]>
Sent: fredag 30. august 2019 20:47
To: Stefan Blumentrath <[hidden email]>
Cc: GRASS developers list <[hidden email]>
Subject: Re: [GRASS-dev] Random selection of a given number of points/pixels per class

 

r.sample.category in addons seems like what you want?

 

On Fri, Aug 30, 2019 at 3:59 AM Stefan Blumentrath <[hidden email]> wrote:

Dear devs,

 

Recently, I was trying to generate a fixed number of random points per class in a vector or raster map.

 

So I looked at both v.random and r.random. However, neither seemed to give me the desired result:

v.random with restrict option seems to generate points per area even if areas belong to the same class and share the same cat value.

r.random does not have a restrict option.

 

So I ended up writing a small script that basically loops over the classes and extracts n points/pixels per class from a input raster map. My question now is did I overlook some less obvious feature of v.random or r.random?

If not I might create a small wrapper addon…

 

Cheers

Stefan

_______________________________________________
grass-dev mailing list
[hidden email]
https://lists.osgeo.org/mailman/listinfo/grass-dev


_______________________________________________
grass-dev mailing list
[hidden email]
https://lists.osgeo.org/mailman/listinfo/grass-dev