diff --git a/NEWS.md b/NEWS.md index de88af4..d4e9acd 100644 --- a/NEWS.md +++ b/NEWS.md @@ -2,6 +2,8 @@ * Added `table_initializeExisting()` for fast conversion of an existing table of spatial metadata into a standardized "known location" table. +* Added `table_findOverlappingLocations()` to help choose an appropriate radius +when initializing frorm an existing metadata table. * Added `addressService` argument to `table_addLocation()`, `table_addSingleLocation() and `location_initialize()` to skip the address step that requires web services. diff --git a/docs/articles/MazamaLocationUtils.html b/docs/articles/MazamaLocationUtils.html index ecdad50..451b22e 100644 --- a/docs/articles/MazamaLocationUtils.html +++ b/docs/articles/MazamaLocationUtils.html @@ -213,7 +213,9 @@
## [1] NA NA NA NA NA NA NA NA NA NA NA NA NA
+## [1] "Chelan" NA NA NA NA "Wellpinit"
+## [7] NA NA NA NA NA NA
+## [13] NA
# Any known locations within 500 meters
table_getNearestLocation(
wa_monitors_500,
@@ -221,10 +223,11 @@
latitude = lats,
radius = 500
) %>% dplyr::pull(city)
## [1] NA NA NA "Sunnyside"
-## [5] "Inchelium" "Wellpinit" "Lake Forest Park" "Okanogan County"
-## [9] NA "Okanogan County" "Ritzville" "Darrington"
-## [13] "Tukwila"
+## [1] "Chelan" "La Crosse" NA
+## [4] NA "Inchelium" "Wellpinit"
+## [7] NA NA "Limestone Junction"
+## [10] NA NA NA
+## [13] NA
# How about 5000 meters?
table_getNearestLocation(
wa_monitors_500,
diff --git a/docs/news/index.html b/docs/news/index.html
index 71c48f0..1baa3f2 100644
--- a/docs/news/index.html
+++ b/docs/news/index.html
@@ -119,6 +119,7 @@
- Added
table_initializeExisting()
for fast conversion of an existing table of spatial metadata into a standardized “known location” table.
+- Added
table_findOverlappingLocations()
to help choose an appropriate radius when initializing frorm an existing metadata table.
- Added
addressService
argument to table_addLocation()
, table_addSingleLocation() and
location_initialize()` to skip the address step that requires web services.
Finds overlapping locations in a known locations table.
Name of spatial dataset to use for determining state
Name of the elevation service to use for determining +the elevation. Default: NULL. Accepted values: "usgs".
Name of the address service to use for determining -the street address. Default: NA. Accepted values: "photon".
Name of spatial dataset to use for determining state codes, Default: 'NaturalEarthAdm1'
Name of the elevation service to use for determining +the elevation. Default: NULL. Accepted values: "usgs".
Name of the address service to use for determining -the street address. Default: NA. Accepted values: "photon".
Name of spatial dataset to use for determining state codes, Default: 'NaturalEarthAdm1'
Name of the elevation service to use for determining +the elevation. Default: NULL. Accepted values: "usgs".
Name of the address service to use for determining -the street address. Default: NA. Accepted values: "photon".
R/table_findOverlappingLocations.R
+ table_findOverlappingLocations.Rd
Calculates distances between all locations within a known +locations table and returns a tibble with the row indices and separation +distances of those records with overlapping locations.
+It is useful when working with new metadata tables to identify overlapping
+locations early on so that decisions can be made about the apporpriateness
+of the specified radius
.
table_findOverlappingLocations(tbl = NULL, radius = NULL)+ +
tbl | +Tibble with |
+
---|---|
radius | +Radius in meters. |
+
Tibble of row indices and distances for those locations which overlap.
+ ++library(MazamaLocationUtils) + +meta <- wa_airfire_meta + +# Anything locations closer than 2 km? (diameter = 2*radius) +table_findOverlappingLocations(meta, radius = 1000)#> # A tibble: 0 x 3 +#> # … with 3 variables: row1 <dbl>, row2 <dbl>, distance <dbl>+# How about 4 km? +table_findOverlappingLocations(meta, radius = 2000)#> # A tibble: 3 x 3 +#> row1 row2 distance +#> <int> <int> <dbl> +#> 1 2 34 2500. +#> 2 12 34 3328. +#> 3 2 9 3762.+# Let's look at those locations + +tooCloseTbl <- table_findOverlappingLocations(meta, radius = 2000) + +for ( i in seq_len(nrow(tooCloseTbl)) ) { + rows <- as.numeric(tooCloseTbl[i, 1:2]) + cat(sprintf("\n%5.1f meters apart:\n", tooCloseTbl$distance[i])) + print(meta[rows, c('longitude', 'latitude', 'siteName')]) +}#> +#> 2500.2 meters apart: +#> longitude latitude siteName +#> 530330057_01 -122.3405 47.56200 Seattle-Duwamish +#> 530330080_01 -122.3086 47.56824 Seattle-Beacon Hill +#> +#> 3328.1 meters apart: +#> longitude latitude siteName +#> 530330030_01 -122.3197 47.59722 Seattle-10th & Weller +#> 530330080_01 -122.3086 47.56824 Seattle-Beacon Hill +#> +#> 3761.7 meters apart: +#> longitude latitude siteName +#> 530330057_01 -122.3405 47.5620 Seattle-Duwamish +#> 530331011_01 -122.3208 47.5309 Seattle-South Park+ +
Vector of country codes used to optimize spatial searching. (See ?MazamaSpatialUtils::getStateCode())
Radius in meters, Default: NULL
Logical controlling the generation of progress messages.
Known location tibble with the specified metadata columns.
+Known location tibble with the specified metadata columns. Any
+locations whose circles (as defined by radius
) overlap will generate
+warning messages.
It is incumbent upon the user to address these issue by one of:
+reduce the radius until no overlaps occur
assign one of the overlapping locations to the other location