Search code examples
rspatstat

Merging levels such that n in window is equal to the number of levels


In relation to this question

The answer does solve the problem, but the plot is very messy as seen below. enter image description here What I wanted was a single big window with all these points inside that window. But as you can see the plot shows each point with its own window because of 131 levels. I think this can be resolved by merging the levels such that n = 131 in window. For reference the sf_object looks like this:

Simple feature collection with 131 features and 3 fields
geometry type:  MULTIPOINT
dimension:      XY
bbox:           xmin: -1932934 ymin: 4958872 xmax: -1439558 ymax: 5861173
projected CRS:  NAD83(2011) / UTM zone 16N
# A tibble: 131 x 4
# Groups:   COOPID [131]
   COOPID STATION_NA                         geometry Annual_Precipitation
 *  <dbl> <chr>                      <MULTIPOINT [m]>                <dbl>
 1      0 Ontario                ((-1899685 5335073))                 9.24
 2 100010 ABERDEEN EXPERIMNT STN ((-1610453 5091311))                12.4 
 3 100227 AMERICAN FALLS 3 NW    ((-1623401 5075011))                20.4 
 4 100282 ANDERSON DAM           ((-1807106 5212322))                16.3 
 5 100347 ARBON 2 NW             ((-1606302 5034484))                10.2 
 6 100375 ARCO                   ((-1622855 5179969))                19.5 
 7 100448 ARROWROCK DAM          ((-1834338 5254236))                20.1 
 8 100470 ASHTON                 ((-1458491 5179214))                37.5 
 9 100528 AVERY RS #2            ((-1678382 5654084))                25.3 
10 100667 BAYVIEW MODEL BASIN    ((-1691954 5753129))                 9.69

The ppp object with types can be seen in the image below. How can I merge levels into one big window such that n in window = 131 (all station points) and x = all of their coordinates in a list and same for y? I think that would solve the problem of plotting 131 points in a one big window (whole area of interest). I hope this makes sense. enter image description here


Solution

  • The generic split operation divides the data into several sets of data. See help(split).

    The method split.ppp in the spatstat package divides a point pattern into a list of point patterns. For example if you had a point pattern X representing the locations of trees in a forest, with marks indicating the species of each tree, then split(X) would produce a list of point patterns, each containing the locations of trees of one species.

    It seems that you did not want to split your point pattern as you had asked in the previous three questions. Rather, it seems that you probably wanted to produce a single point pattern with factor-valued marks, where the mark value identifies the grouping/classification. You've already done this in the previous question, by doing marks(X) <- factor(.....), so just plot that point pattern X.