Dear all,
I am working on a multitype point pattern, and I'd like to estimate how many of each type of point occurs into each quadrant. I know it is possible to use the quandracount on split marks as follows using spatstats: quadratcount(split(marks)). But the result produces as many windows as they are marks. I am wondering is there is a way to know many occurrence of each type there is per quadrant and to plot it in a single grid. Thanks, Guy This email and any files transmitted with it are confide...{{dropped:10}} _______________________________________________ R-sig-Geo mailing list [hidden email] https://stat.ethz.ch/mailman/listinfo/r-sig-geo |
Hi Guy,
You can know how many points of each type are in each cell with sapply, i.e.: >data (lansing) >qs<- quadratcount(split(lansing)) #trees in the fist row, first column: > sapply(qs, function(x) x[1,1]) blackoak hickory maple misc redoak whiteoak 13 66 0 0 4 23 #trees in the fist row, second column: > sapply(qs, function(x) x[1,2]) blackoak hickory maple misc redoak whiteoak 16 38 3 0 9 16 # ETC. On the other hand I don't know if it is a good idea to have all this numbers printed in just one cell or how to print them without the result being a mess... Cheers, Marcelino. El 12/09/2017 a las 16:11, Guy Bayegnak escribió: > Dear all, > > > > I am working on a multitype point pattern, and I'd like to estimate how many of each type of point occurs into each quadrant. I know it is possible to use the quandracount on split marks as follows using spatstats: quadratcount(split(marks)). But the result produces as many windows as they are marks. I am wondering is there is a way to know many occurrence of each type there is per quadrant and to plot it in a single grid. > > Thanks, > > Guy > > > > This email and any files transmitted with it are confide...{{dropped:10}} > > _______________________________________________ > R-sig-Geo mailing list > [hidden email] > https://stat.ethz.ch/mailman/listinfo/r-sig-geo > . > -- Marcelino de la Cruz Rot Depto. de Biología y Geología Física y Química Inorgánica Universidad Rey Juan Carlos Móstoles España _______________________________________________ R-sig-Geo mailing list [hidden email] https://stat.ethz.ch/mailman/listinfo/r-sig-geo |
In reply to this post by Guy Bayegnak
On 13/09/17 02:11, Guy Bayegnak wrote: > Dear all, > > I am working on a multitype point pattern, and I'd like to estimate > how many of each type of point occurs into each quadrant. I know it > is possible to use the quandracount on split marks as follows using > spatstats: quadratcount(split(marks)). But the result produces as > many windows as they are marks. I am wondering is there is a way to > know many occurrence of each type there is per quadrant and to plot > it in a single grid. > > Thanks. You really should start by mentioning that you are dealing with the spatstat package. It's not clear to me what you are after. A minimal reproducible example would be helpful. I presume that by "quadrant" you mean one of the four equal sub-windows formed by bisecting your (rectangular) window vertically and horizontally. If my presumption is correct then perhaps lapply(split(X),quadratcount,nx=2) (where "X" is your point pattern) does what you want. E.g.: > lapply(split(amacrine),quadratcount,nx=2) > $off > x > y [0,0.801) [0.801,1.6] > [0.5,1] 36 36 > [0,0.5) 34 36 > > $on > x > y [0,0.801) [0.801,1.6] > [0.5,1] 35 39 > [0,0.5) 42 36 Is this something like what you wish to achieve? cheers, Rolf Turner -- Technical Editor ANZJS Department of Statistics University of Auckland Phone: +64-9-373-7599 ext. 88276 _______________________________________________ R-sig-Geo mailing list [hidden email] https://stat.ethz.ch/mailman/listinfo/r-sig-geo |
Thanks a lot for your response and suggestion Rolf. Yes, by "quadrant" I mean the little sub-windows. My problem is the following:
We have collected thousands of groundwater samples across a vast area, and analysed them. Based on the analysis we are able to assign a "type" to each water sample. When plotted, there seems to be a spatial trend in water type. But a given area may have more than one water type, usually with a dominant type (most frequently occurring). What I am trying to do is identify the dominant type for each sub-region /sub-windows but show the count side by side, for example: x y [0,0.801) [0.801,1.6] [0.5,1] Off = 36 Off = 6 On = 3 On = 39 [0,0.5) Off = 4 Off = 36 On = 42 On = 6 I think I can achieve what I am looking for with your suggestion. Once I get the table list, I will copy the numbers side by side manually. Sincerely, Guy -----Original Message----- From: Rolf Turner [mailto:[hidden email]] Sent: September 12, 2017 3:45 PM To: Guy Bayegnak <[hidden email]> Cc: [hidden email]; [hidden email]; Ege Rubak <[hidden email]> Subject: Re: [R-sig-Geo] quadracount on multitype points On 13/09/17 02:11, Guy Bayegnak wrote: > Dear all, > > I am working on a multitype point pattern, and I'd like to estimate > how many of each type of point occurs into each quadrant. I know it is > possible to use the quandracount on split marks as follows using > spatstats: quadratcount(split(marks)). But the result produces as many > windows as they are marks. I am wondering is there is a way to know > many occurrence of each type there is per quadrant and to plot it in a > single grid. > > Thanks. You really should start by mentioning that you are dealing with the spatstat package. It's not clear to me what you are after. A minimal reproducible example would be helpful. I presume that by "quadrant" you mean one of the four equal sub-windows formed by bisecting your (rectangular) window vertically and horizontally. If my presumption is correct then perhaps lapply(split(X),quadratcount,nx=2) (where "X" is your point pattern) does what you want. E.g.: > lapply(split(amacrine),quadratcount,nx=2) > $off > x > y [0,0.801) [0.801,1.6] > [0.5,1] 36 36 > [0,0.5) 34 36 > > $on > x > y [0,0.801) [0.801,1.6] > [0.5,1] 35 39 > [0,0.5) 42 36 Is this something like what you wish to achieve? cheers, Rolf Turner -- Technical Editor ANZJS Department of Statistics University of Auckland Phone: +64-9-373-7599 ext. 88276 This email and any files transmitted with it are confidential and intended solely for the use of the individual or entity to whom they are addressed. If you have received this email in error please notify the system manager. This message contains confidential information and is intended only for the individual named. If you are not the named addressee you should not disseminate, distribute or copy this e-mail. _______________________________________________ R-sig-Geo mailing list [hidden email] https://stat.ethz.ch/mailman/listinfo/r-sig-geo |
Hi Guy,
Maybe your explorative analysis could also benefit from `relrisk` in case you don't know that function? It basically gives you a list of smooth images (one for each type) of the probability that a hypothetical sample at that location is of a given type. E.g. for the built-in multitype point pattern dataset `lansing` you would do: library(spatstat) prob <- relrisk(lansing, diggle=TRUE) plot(prob) This example and more (e.g. a division of the sampling area into subsets of dominant types) can be found in Chapter 14 of our "spatstat book" if you need more details (sorry about the shameless self promotion, but I don't know a better source for this :-)). Kind regards, Ege On 09/13/2017 01:08 AM, Guy Bayegnak wrote: > Thanks a lot for your response and suggestion Rolf. Yes, by "quadrant" I mean the little sub-windows. My problem is the following: > > We have collected thousands of groundwater samples across a vast area, and analysed them. Based on the analysis we are able to assign a "type" to each water sample. When plotted, there seems to be a spatial trend in water type. But a given area may have more than one water type, usually with a dominant type (most frequently occurring). What I am trying to do is identify the dominant type for each sub-region /sub-windows but show the count side by side, for example: > > x > y [0,0.801) [0.801,1.6] > [0.5,1] Off = 36 Off = 6 > On = 3 On = 39 > > [0,0.5) Off = 4 Off = 36 > On = 42 On = 6 > > I think I can achieve what I am looking for with your suggestion. Once I get the table list, I will copy the numbers side by side manually. > > Sincerely, > > Guy > > -----Original Message----- > From: Rolf Turner [mailto:[hidden email]] > Sent: September 12, 2017 3:45 PM > To: Guy Bayegnak <[hidden email]> > Cc: [hidden email]; [hidden email]; Ege Rubak <[hidden email]> > Subject: Re: [R-sig-Geo] quadracount on multitype points > > > On 13/09/17 02:11, Guy Bayegnak wrote: > >> Dear all, >> >> I am working on a multitype point pattern, and I'd like to estimate >> how many of each type of point occurs into each quadrant. I know it is >> possible to use the quandracount on split marks as follows using >> spatstats: quadratcount(split(marks)). But the result produces as many >> windows as they are marks. I am wondering is there is a way to know >> many occurrence of each type there is per quadrant and to plot it in a >> single grid. >> >> Thanks. > > You really should start by mentioning that you are dealing with the spatstat package. > > It's not clear to me what you are after. A minimal reproducible example would be helpful. I presume that by "quadrant" you mean one of the four equal sub-windows formed by bisecting your (rectangular) window vertically and horizontally. > > If my presumption is correct then perhaps > > lapply(split(X),quadratcount,nx=2) > > (where "X" is your point pattern) does what you want. E.g.: > >> lapply(split(amacrine),quadratcount,nx=2) >> $off >> x >> y [0,0.801) [0.801,1.6] >> [0.5,1] 36 36 >> [0,0.5) 34 36 >> >> $on >> x >> y [0,0.801) [0.801,1.6] >> [0.5,1] 35 39 >> [0,0.5) 42 36 > > Is this something like what you wish to achieve? > > cheers, > > Rolf Turner > > -- > Technical Editor ANZJS > Department of Statistics > University of Auckland > Phone: +64-9-373-7599 ext. 88276 > This email and any files transmitted with it are confi...{{dropped:3}} _______________________________________________ R-sig-Geo mailing list [hidden email] https://stat.ethz.ch/mailman/listinfo/r-sig-geo |
In reply to this post by Guy Bayegnak
On 13/09/17 11:08, Guy Bayegnak wrote:
> Thanks a lot for your response and suggestion Rolf. Yes, by "quadrant" I mean the little sub-windows. My problem is the following: > > We have collected thousands of groundwater samples across a vast area, and analysed them. Based on the analysis we are able to assign a "type" to each water sample. When plotted, there seems to be a spatial trend in water type. But a given area may have more than one water type, usually with a dominant type (most frequently occurring). What I am trying to do is identify the dominant type for each sub-region /sub-windows but show the count side by side, for example: > > x > y [0,0.801) [0.801,1.6] > [0.5,1] Off = 36 Off = 6 > On = 3 On = 39 > > [0,0.5) Off = 4 Off = 36 > On = 42 On = 6 > I don't understand the counts in the foregoing. Have some digits been left off in places? I.e. should this be: > > x > y [0,0.801) [0.801,1.6] > [0.5,1] Off = 36 Off = 36 > On = 35 On = 39 > > [0,0.5) Off = 34 Off = 36 > On = 42 On = 36 ??? > > I think I can achieve what I am looking for with your suggestion. Once I get the table list, I will copy the numbers side by side manually. Yeucch! Manually? Saints preserve us! Do you really mean "quadrant" or do you simply mean *quadrat*??? Sticking with quad*rant* (it doesn't really matter), how about something like: rants <- tiles(quadrats(Window(amacrine),nx=2)) lapply(rants,function(w,pat){table(marks(pat[w]))},pat=amacrine) which gives: > $`Tile row 1, col 1` > > off on > 36 35 > > $`Tile row 1, col 2` > > off on > 36 39 > > $`Tile row 2, col 1` > > off on > 34 42 > > $`Tile row 2, col 2` > > off on > 36 36 cheers, Rolf P. S. But you are probably well-advised to forget all this quadrat counting stuff and use relrisk() as suggested by Ege Rubak. R. -- Technical Editor ANZJS Department of Statistics University of Auckland Phone: +64-9-373-7599 ext. 88276 _______________________________________________ R-sig-Geo mailing list [hidden email] https://stat.ethz.ch/mailman/listinfo/r-sig-geo |
In reply to this post by Ege Rubak
Hi Guy,
I only like real pies :-) but, what about something like this: library(spatstat) data(lansing) qs<- quadratcount(split(lansing)) dqs <- dim(qs[[1]]) nr <- dqs[1] nc <- dqs[2] le <- length(qs[[1]]) m<- matrix( 1:le, nr=nr, nc=nc, byrow=T) layout(m, heights=rep(1,nr), widths=rep(1,nc)) #layout.show(25) par(mar=c(0,0,0,0)) for (i in 1:nc){ for (j in 1:nr){ pie(sapply(qs, function(x) x[i,j]), labels=NA ) box() } } Cheers, Marcelino El 13/09/2017 a las 10:21, Ege Rubak escribió: > Hi Guy, > > Maybe your explorative analysis could also benefit from `relrisk` in > case you don't know that function? > > It basically gives you a list of smooth images (one for each type) of > the probability that a hypothetical sample at that location is of a > given type. E.g. for the built-in multitype point pattern dataset > `lansing` you would do: > > library(spatstat) > prob <- relrisk(lansing, diggle=TRUE) > plot(prob) > > This example and more (e.g. a division of the sampling area into > subsets of dominant types) can be found in Chapter 14 of our "spatstat > book" if you need more details (sorry about the shameless self > promotion, but I don't know a better source for this :-)). > > Kind regards, > Ege > > On 09/13/2017 01:08 AM, Guy Bayegnak wrote: >> Thanks a lot for your response and suggestion Rolf. Yes, by >> "quadrant" I mean the little sub-windows. My problem is the following: >> >> We have collected thousands of groundwater samples across a vast >> area, and analysed them. Based on the analysis we are able to assign >> a "type" to each water sample. When plotted, there seems to be a >> spatial trend in water type. But a given area may have more than one >> water type, usually with a dominant type (most frequently >> occurring). What I am trying to do is identify the dominant type for >> each sub-region /sub-windows but show the count side by side, for >> example: >> >> x >> y [0,0.801) [0.801,1.6] >> [0.5,1] Off = 36 Off = 6 >> On = 3 On = 39 >> >> [0,0.5) Off = 4 Off = 36 >> On = 42 On = 6 >> >> I think I can achieve what I am looking for with your suggestion. >> Once I get the table list, I will copy the numbers side by side >> manually. >> >> Sincerely, >> >> Guy >> >> -----Original Message----- >> From: Rolf Turner [mailto:[hidden email]] >> Sent: September 12, 2017 3:45 PM >> To: Guy Bayegnak <[hidden email]> >> Cc: [hidden email]; [hidden email]; Ege Rubak >> <[hidden email]> >> Subject: Re: [R-sig-Geo] quadracount on multitype points >> >> >> On 13/09/17 02:11, Guy Bayegnak wrote: >> >>> Dear all, >>> >>> I am working on a multitype point pattern, and I'd like to estimate >>> how many of each type of point occurs into each quadrant. I know it is >>> possible to use the quandracount on split marks as follows using >>> spatstats: quadratcount(split(marks)). But the result produces as many >>> windows as they are marks. I am wondering is there is a way to know >>> many occurrence of each type there is per quadrant and to plot it in a >>> single grid. >>> >>> Thanks. >> >> You really should start by mentioning that you are dealing with the >> spatstat package. >> >> It's not clear to me what you are after. A minimal reproducible >> example would be helpful. I presume that by "quadrant" you mean one >> of the four equal sub-windows formed by bisecting your (rectangular) >> window vertically and horizontally. >> >> If my presumption is correct then perhaps >> >> lapply(split(X),quadratcount,nx=2) >> >> (where "X" is your point pattern) does what you want. E.g.: >> >>> lapply(split(amacrine),quadratcount,nx=2) >>> $off >>> x >>> y [0,0.801) [0.801,1.6] >>> [0.5,1] 36 36 >>> [0,0.5) 34 36 >>> >>> $on >>> x >>> y [0,0.801) [0.801,1.6] >>> [0.5,1] 35 39 >>> [0,0.5) 42 36 >> >> Is this something like what you wish to achieve? >> >> cheers, >> >> Rolf Turner >> >> -- >> Technical Editor ANZJS >> Department of Statistics >> University of Auckland >> Phone: +64-9-373-7599 ext. 88276 >> This email and any files transmitted with it are confi...{{dropped:3}} > > _______________________________________________ > R-sig-Geo mailing list > [hidden email] > https://stat.ethz.ch/mailman/listinfo/r-sig-geo > . > -- Marcelino de la Cruz Rot Depto. de Biología y Geología Física y Química Inorgánica Universidad Rey Juan Carlos Móstoles España _______________________________________________ R-sig-Geo mailing list [hidden email] https://stat.ethz.ch/mailman/listinfo/r-sig-geo |
In reply to this post by Ege Rubak
Thanks for all the suggestions. They were all very helpful. The "relrisk" function turned out to be even better than what I was trying to do.
And Ege, no worries about self promotion. I already have a copy of the "spatial point pattern " book. Sincerely, Guy -----Original Message----- From: Ege Rubak [mailto:[hidden email]] Sent: September 13, 2017 2:21 AM To: Guy Bayegnak <[hidden email]> Cc: Rolf Turner <[hidden email]>; [hidden email]; [hidden email] Subject: Re: [R-sig-Geo] quadracount on multitype points Hi Guy, Maybe your explorative analysis could also benefit from `relrisk` in case you don't know that function? It basically gives you a list of smooth images (one for each type) of the probability that a hypothetical sample at that location is of a given type. E.g. for the built-in multitype point pattern dataset `lansing` you would do: library(spatstat) prob <- relrisk(lansing, diggle=TRUE) plot(prob) This example and more (e.g. a division of the sampling area into subsets of dominant types) can be found in Chapter 14 of our "spatstat book" if you need more details (sorry about the shameless self promotion, but I don't know a better source for this :-)). Kind regards, Ege On 09/13/2017 01:08 AM, Guy Bayegnak wrote: > Thanks a lot for your response and suggestion Rolf. Yes, by "quadrant" I mean the little sub-windows. My problem is the following: > > We have collected thousands of groundwater samples across a vast area, and analysed them. Based on the analysis we are able to assign a "type" to each water sample. When plotted, there seems to be a spatial trend in water type. But a given area may have more than one water type, usually with a dominant type (most frequently occurring). What I am trying to do is identify the dominant type for each sub-region /sub-windows but show the count side by side, for example: > > x > y [0,0.801) [0.801,1.6] > [0.5,1] Off = 36 Off = 6 > On = 3 On = 39 > > [0,0.5) Off = 4 Off = 36 > On = 42 On = 6 > > I think I can achieve what I am looking for with your suggestion. Once I get the table list, I will copy the numbers side by side manually. > > Sincerely, > > Guy > > -----Original Message----- > From: Rolf Turner [mailto:[hidden email]] > Sent: September 12, 2017 3:45 PM > To: Guy Bayegnak <[hidden email]> > Cc: [hidden email]; [hidden email]; Ege Rubak > <[hidden email]> > Subject: Re: [R-sig-Geo] quadracount on multitype points > > > On 13/09/17 02:11, Guy Bayegnak wrote: > >> Dear all, >> >> I am working on a multitype point pattern, and I'd like to estimate >> how many of each type of point occurs into each quadrant. I know it >> is possible to use the quandracount on split marks as follows using >> spatstats: quadratcount(split(marks)). But the result produces as >> many windows as they are marks. I am wondering is there is a way to >> know many occurrence of each type there is per quadrant and to plot >> it in a single grid. >> >> Thanks. > > You really should start by mentioning that you are dealing with the spatstat package. > > It's not clear to me what you are after. A minimal reproducible example would be helpful. I presume that by "quadrant" you mean one of the four equal sub-windows formed by bisecting your (rectangular) window vertically and horizontally. > > If my presumption is correct then perhaps > > lapply(split(X),quadratcount,nx=2) > > (where "X" is your point pattern) does what you want. E.g.: > >> lapply(split(amacrine),quadratcount,nx=2) >> $off >> x >> y [0,0.801) [0.801,1.6] >> [0.5,1] 36 36 >> [0,0.5) 34 36 >> >> $on >> x >> y [0,0.801) [0.801,1.6] >> [0.5,1] 35 39 >> [0,0.5) 42 36 > > Is this something like what you wish to achieve? > > cheers, > > Rolf Turner > > -- > Technical Editor ANZJS > Department of Statistics > University of Auckland > Phone: +64-9-373-7599 ext. 88276 > This email and any files transmitted with it are confidential and intended solely for the use of the individual or entity to whom they are addressed. If you have received this email in error please notify the system manager. This message contains confidential information and is intended only for the individual named. If you are not the named addressee you should not disseminate, distribute or copy this e-mail. > R-sig-Geo mailing list [hidden email] https://stat.ethz.ch/mailman/listinfo/r-sig-geo |
Free forum by Nabble | Edit this page |