Skip to contents

Random position

Usage

rg_position(count = 1, bbox = NULL)

Arguments

count

(integer/numeric) number of positions. Default: 1

bbox

(integer/numeric) lat/long bounding box from which to generate positions; numeric vector of the form west (long), south (lat), east (long), north (lat). optional

Value

A list, each element is a numeric vector length two of long, lat

Examples

rg_position()
#> [[1]]
#> [1] 167.106803   5.605832
#> 
rg_position(10)
#> [[1]]
#> [1] -137.13574  -82.02758
#> 
#> [[2]]
#> [1] -179.38385  -12.58052
#> 
#> [[3]]
#> [1] -142.18634   29.80514
#> 
#> [[4]]
#> [1] -84.46293 -36.17146
#> 
#> [[5]]
#> [1] 105.48675 -30.00449
#> 
#> [[6]]
#> [1] -107.67743   45.93852
#> 
#> [[7]]
#> [1] -148.1696   81.1517
#> 
#> [[8]]
#> [1] 24.193969 -9.862538
#> 
#> [[9]]
#> [1] 178.35155  41.68739
#> 
#> [[10]]
#> [1] 170.75394 -28.20524
#> 
rg_position(100)
#> [[1]]
#> [1] -125.065197   -2.561649
#> 
#> [[2]]
#> [1]  34.60323 -58.51857
#> 
#> [[3]]
#> [1] -152.19069  -71.50264
#> 
#> [[4]]
#> [1]  7.17351 18.14212
#> 
#> [[5]]
#> [1] -162.5024  -57.8171
#> 
#> [[6]]
#> [1] -81.422679   7.961602
#> 
#> [[7]]
#> [1] 169.510084   5.190015
#> 
#> [[8]]
#> [1]  42.20367 -23.81353
#> 
#> [[9]]
#> [1] -105.69114   10.00387
#> 
#> [[10]]
#> [1] -42.50374  45.62387
#> 
#> [[11]]
#> [1] -170.90237  -23.97752
#> 
#> [[12]]
#> [1] -136.2172   57.5199
#> 
#> [[13]]
#> [1] -1.279898 49.372415
#> 
#> [[14]]
#> [1] -96.59198  50.18703
#> 
#> [[15]]
#> [1] 56.97093 64.02924
#> 
#> [[16]]
#> [1]  -7.420212 -32.540704
#> 
#> [[17]]
#> [1] 67.53200 34.25319
#> 
#> [[18]]
#> [1] 149.6568691  -0.5218817
#> 
#> [[19]]
#> [1] 168.3605 -69.2701
#> 
#> [[20]]
#> [1] -151.71127  -78.41873
#> 
#> [[21]]
#> [1] -96.68627  26.32306
#> 
#> [[22]]
#> [1] -2.071991 55.173146
#> 
#> [[23]]
#> [1] -47.61646  59.32702
#> 
#> [[24]]
#> [1] 55.41542 24.39810
#> 
#> [[25]]
#> [1] 18.07012 38.95239
#> 
#> [[26]]
#> [1]  92.29718 -51.68382
#> 
#> [[27]]
#> [1] -40.34543  28.02959
#> 
#> [[28]]
#> [1]  57.07252 -61.34812
#> 
#> [[29]]
#> [1] -176.5007  -32.4685
#> 
#> [[30]]
#> [1] -26.914955  -5.741294
#> 
#> [[31]]
#> [1] -156.37665  -78.01232
#> 
#> [[32]]
#> [1]  85.78712 -26.72738
#> 
#> [[33]]
#> [1] 117.03997  63.67815
#> 
#> [[34]]
#> [1] 131.43369 -39.15535
#> 
#> [[35]]
#> [1] -63.99822  16.38346
#> 
#> [[36]]
#> [1] 127.66082  47.27469
#> 
#> [[37]]
#> [1] 143.37672  68.89616
#> 
#> [[38]]
#> [1] 102.06638 -34.64679
#> 
#> [[39]]
#> [1] 121.38057  33.90132
#> 
#> [[40]]
#> [1] -99.86451 -19.66408
#> 
#> [[41]]
#> [1]   1.597015 -77.852785
#> 
#> [[42]]
#> [1] -1.804653 76.378392
#> 
#> [[43]]
#> [1] 53.96558 34.24631
#> 
#> [[44]]
#> [1] -137.53598   20.79321
#> 
#> [[45]]
#> [1] 53.50999 62.46279
#> 
#> [[46]]
#> [1] -19.80499 -87.45527
#> 
#> [[47]]
#> [1]  55.86689 -13.61019
#> 
#> [[48]]
#> [1] 152.0652450   0.4383146
#> 
#> [[49]]
#> [1]  67.81999 -81.87092
#> 
#> [[50]]
#> [1]  18.90009 -85.68322
#> 
#> [[51]]
#> [1] 55.42109 11.88622
#> 
#> [[52]]
#> [1] 149.63026  -4.09808
#> 
#> [[53]]
#> [1] -62.387247   9.910151
#> 
#> [[54]]
#> [1] 57.52789 42.95104
#> 
#> [[55]]
#> [1]  -6.453208 -12.144778
#> 
#> [[56]]
#> [1] -46.73084 -26.10406
#> 
#> [[57]]
#> [1] -131.02567   37.40945
#> 
#> [[58]]
#> [1] -91.25711 -21.24848
#> 
#> [[59]]
#> [1] 106.27663  67.78045
#> 
#> [[60]]
#> [1] -128.58283  -52.24336
#> 
#> [[61]]
#> [1] 113.577968  -1.177782
#> 
#> [[62]]
#> [1] 114.44878 -13.97475
#> 
#> [[63]]
#> [1]   5.225955 -83.527414
#> 
#> [[64]]
#> [1]  -1.865129 -23.399841
#> 
#> [[65]]
#> [1] 135.45437  26.15491
#> 
#> [[66]]
#> [1] 103.973083   9.136562
#> 
#> [[67]]
#> [1] -154.0183  -28.5157
#> 
#> [[68]]
#> [1] -14.28066  49.34526
#> 
#> [[69]]
#> [1]  67.96324 -37.02069
#> 
#> [[70]]
#> [1] 106.70433 -34.15132
#> 
#> [[71]]
#> [1] -58.91602  64.32028
#> 
#> [[72]]
#> [1] -54.61965  50.33528
#> 
#> [[73]]
#> [1] -106.48261  -14.88585
#> 
#> [[74]]
#> [1] 111.50246 -30.37817
#> 
#> [[75]]
#> [1] -12.43959 -53.83289
#> 
#> [[76]]
#> [1] 120.23285  15.20118
#> 
#> [[77]]
#> [1]  -4.081328 -26.262446
#> 
#> [[78]]
#> [1]   9.409734 -33.310289
#> 
#> [[79]]
#> [1] -33.13347  37.04210
#> 
#> [[80]]
#> [1] 114.939214  -8.645472
#> 
#> [[81]]
#> [1] -91.05526 -46.51595
#> 
#> [[82]]
#> [1] -159.37663   12.22296
#> 
#> [[83]]
#> [1]  38.54971 -24.32287
#> 
#> [[84]]
#> [1]  42.30089 -25.59973
#> 
#> [[85]]
#> [1] 21.908658  9.335992
#> 
#> [[86]]
#> [1]  35.18063 -27.74540
#> 
#> [[87]]
#> [1] -123.5462175    0.9512262
#> 
#> [[88]]
#> [1] 126.82239  14.26314
#> 
#> [[89]]
#> [1] -53.664865   6.576338
#> 
#> [[90]]
#> [1] -76.689017   8.007982
#> 
#> [[91]]
#> [1] -122.407202    8.788177
#> 
#> [[92]]
#> [1]  92.41483 -25.54767
#> 
#> [[93]]
#> [1] -20.29763 -39.60852
#> 
#> [[94]]
#> [1] -134.15335   30.92917
#> 
#> [[95]]
#> [1] 83.76192 43.27363
#> 
#> [[96]]
#> [1] 129.24285 -59.70072
#> 
#> [[97]]
#> [1] 36.47157 52.92052
#> 
#> [[98]]
#> [1] 129.777956  -7.061949
#> 
#> [[99]]
#> [1] 58.90786 31.82624
#> 
#> [[100]]
#> [1] 79.90090 67.51384
#> 
rg_position(bbox = c(50, 50, 60, 60))
#> [[1]]
#> [1] 59.69645 55.92442
#> 

# coerce to data.frame
stats::setNames(
  do.call("rbind.data.frame", rg_position(10)),
  c('lng', 'lat')
)
#>           lng        lat
#> 1   -16.17637  54.400085
#> 2  -132.21974  38.983742
#> 3   -86.12818 -18.392744
#> 4   152.53163  -1.164612
#> 5   -28.77728 -23.535080
#> 6   -65.72129  56.437111
#> 7   -23.66072   2.344959
#> 8   -16.43325  18.852677
#> 9   123.12719 -21.466050
#> 10   59.96623  41.954796