Nielson Pasqualotto
2018-Oct-17 14:07 UTC
[R] Random selection of points in SpatialPointsDataFrame with distance constraint
I'm trying to select points randomly (without replacement) from a SpatialPointsDataFrame (input object) with a minimum distance of 3,000 meters between them. I want to get random 50% of all points and create a vector object with lines index as result. I tried to use sample() function but I still did not realised how to set the geographical constraint. I'll appreciate any help.> inputclass : SpatialPointsDataFrame features : 205 extent : 203294.5, 259880.6, 7600123, 7668676 (xmin, xmax, ymin, ymax) coord. ref. : +proj=utm +zone=23 +south +ellps=GRS80 +units=m +no_defs variables : 3 names : Sites, Long_X, Lat_Y min values : CPF - 050, 203295, 7600120 max values : JES - S94, 259881, 7668680> head(input)Sites Long_X Lat_Y1 CPF - 050 235441 76171502 CPF - 052 234106 76157403 CPF - 054 232683 76142804 CPF - 056 233863 76144205 CPF - 058 234012 76128906 CPF - 062 236929 7612850 rdm_input <- sample(x= nrow(input), size=(0.5*205), replace= FALSE)[1] 167 189 79 80 126 129 144 100 4 109 170 72 123 73 132 93 169 5 134 176 196 158 152 183 23 136 180[28] 130 12 142 179 11 13 66 22 2 96 29 54 137 120 171 184 36 113 3 81 115 30 85 61 162 98 102[55] 103 181 90 133 56 174 76 201 150 197 14 86 118 121 28 97 160 178 1 186 141 163 172 32 65 168 74[82] 114 182 128 131 67 70 165 187 185 69 17 194 16 154 119 192 156 106 25 101 198 105 108 151 125 190 10[109] 84 38 51 161 40 94 45 19 145 75 42 122 117 49 87 MSc. Nielson Pasqualotto Doutorando pelo Programa de P?s-Gradua??o em Ecologia Aplicada (ESALQ/CENA/USP) Bi?logo e Mestre em Ci?ncias pela Universidade de S?o Paulo (USP). Laborat?rio de Ecologia e Conserva??o (LAEC). Av. Bandeirantes, 3900. Bairro Monte Alegre, Ribeir?o Preto, S?o Paulo, Brasil. [[alternative HTML version deleted]]