diff --git a/DESCRIPTION b/DESCRIPTION index f5c8e59..1ea0731 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -1,6 +1,6 @@ Type: Package Package: MazamaLocationUtils -Version: 0.4.3 +Version: 0.4.4 Title: Manage Spatial Metadata for Known Locations Authors@R: c( person("Jonathan", "Callahan", email="jonathan.s.callahan@gmail.com", role=c("aut","cre")), diff --git a/NEWS.md b/NEWS.md index fdfab02..55819bf 100644 --- a/NEWS.md +++ b/NEWS.md @@ -1,3 +1,8 @@ +# MazamaLocationUtils 0.4.4 + +* Fixed bug in `clusterByDistance()` which could fail when incoming tibbles +had very few rows. + # MazamaLocationUtils 0.4.3 * Updated `location_getSingleElevation_USGS()` to use new USGS API. diff --git a/R/clusterByDistance.R b/R/clusterByDistance.R index e14c299..3f22a19 100644 --- a/R/clusterByDistance.R +++ b/R/clusterByDistance.R @@ -128,10 +128,14 @@ clusterByDistance <- function( # Perform clustering for ( clusterCount in 1:maxClusters ) { - if ( nrow(tbl) < 2000 ) { - clusterObj <- cluster::pam(tbl[,c(lonVar,latVar)],clusterCount) + + if ( nrow(tbl) <= clusterCount ) { + # NOTE: k = positive integer specifying the number of clusters, less than the number of observations. + clusterObj <- cluster::pam(tbl[,c(lonVar,latVar)], nrow(tbl) - 1) + } else if ( nrow(tbl) < 2000 ) { + clusterObj <- cluster::pam(tbl[,c(lonVar,latVar)], clusterCount) } else { - clusterObj <- cluster::clara(tbl[,c(lonVar,latVar)],clusterCount, samples = 50) + clusterObj <- cluster::clara(tbl[,c(lonVar,latVar)], clusterCount, samples = 50) } clusterLats <- clusterObj$medoids[,latVar] diameters <- 2 * clusterObj$clusinfo[,'max_diss'] # decimal degrees @@ -141,6 +145,19 @@ clusterByDistance <- function( radianClusterLats <- clusterLats * pi/180 meters <- diameters * (1 + cos(radianClusterLats))/2 * 111320 if ( max(meters) < clusterDiameter ) break + + } + + # NOTE: If we only had a very small table with widely separate locations, + # NOTE: we can end up never satisfying max(meters) < clusterDiameter. In this + # NOTE: case, every location represents a separate cluster + if ( nrow(tbl) <= clusterCount ) { + for ( i in 1:seq_len(nrow(tbl)) ) { + tbl$clusterLon <- as.numeric(tbl[[lonVar]][i]) + tbl$clusterLat <- as.numeric(tbl[[latVar]][i]) + tbl$clusterID <- i + } + return(tbl) } # Create the vector of deployment identifiers diff --git a/docs/404.html b/docs/404.html index a619d86..9563bf2 100644 --- a/docs/404.html +++ b/docs/404.html @@ -32,7 +32,7 @@ MazamaLocationUtils - 0.4.3 + 0.4.4 diff --git a/docs/LICENSE-text.html b/docs/LICENSE-text.html index aad5712..54ef4c9 100644 --- a/docs/LICENSE-text.html +++ b/docs/LICENSE-text.html @@ -17,7 +17,7 @@ MazamaLocationUtils - 0.4.3 + 0.4.4 diff --git a/docs/articles/Developer_Style_Guide.html b/docs/articles/Developer_Style_Guide.html index 8b33173..2f1b2d1 100644 --- a/docs/articles/Developer_Style_Guide.html +++ b/docs/articles/Developer_Style_Guide.html @@ -33,7 +33,7 @@ MazamaLocationUtils - 0.4.3 + 0.4.4 diff --git a/docs/articles/MazamaLocationUtils.html b/docs/articles/MazamaLocationUtils.html index 94d90fc..810a2ab 100644 --- a/docs/articles/MazamaLocationUtils.html +++ b/docs/articles/MazamaLocationUtils.html @@ -33,7 +33,7 @@ MazamaLocationUtils - 0.4.3 + 0.4.4 @@ -312,8 +312,8 @@

Finding known locations latitude = lats, distanceThreshold = 250 ) %>% dplyr::pull(city) -
##  [1] "Burbank"      "Newport"      "Soap Lake"    "Shelton"      NA            
-##  [6] NA             "Cle Elum"     "Longview"     NA             "Wenatchee"   
+
##  [1] "Burbank"      "Newport"      NA             "Shelton"      "Winthrop"    
+##  [6] NA             NA             "Longview"     "Enumclaw"     "Wenatchee"   
 ## [11] "Mount Vernon" NA             "LaCrosse"
 # How about 5000 meters?
diff --git a/docs/articles/index.html b/docs/articles/index.html
index c740d1d..12846b2 100644
--- a/docs/articles/index.html
+++ b/docs/articles/index.html
@@ -17,7 +17,7 @@
       
       
         MazamaLocationUtils
-        0.4.3
+        0.4.4
       
     
diff --git a/docs/authors.html b/docs/authors.html index c862118..5ebcae8 100644 --- a/docs/authors.html +++ b/docs/authors.html @@ -17,7 +17,7 @@ MazamaLocationUtils - 0.4.3 + 0.4.4 @@ -84,13 +84,13 @@

Citation

Callahan J (2024). MazamaLocationUtils: Manage Spatial Metadata for Known Locations. -R package version 0.4.3, https://github.com/MazamaScience/MazamaLocationUtils. +R package version 0.4.4, https://github.com/MazamaScience/MazamaLocationUtils.

@Manual{,
   title = {MazamaLocationUtils: Manage Spatial Metadata for Known Locations},
   author = {Jonathan Callahan},
   year = {2024},
-  note = {R package version 0.4.3},
+  note = {R package version 0.4.4},
   url = {https://github.com/MazamaScience/MazamaLocationUtils},
 }
diff --git a/docs/index.html b/docs/index.html index a51a45b..155ab0d 100644 --- a/docs/index.html +++ b/docs/index.html @@ -36,7 +36,7 @@ MazamaLocationUtils - 0.4.3 + 0.4.4 diff --git a/docs/news/index.html b/docs/news/index.html index d9f3a97..c1a433b 100644 --- a/docs/news/index.html +++ b/docs/news/index.html @@ -17,7 +17,7 @@ MazamaLocationUtils - 0.4.3 + 0.4.4 @@ -61,8 +61,12 @@

Changelog

- -
+
+ +
diff --git a/docs/pkgdown.yml b/docs/pkgdown.yml index 2f36865..f9b9544 100644 --- a/docs/pkgdown.yml +++ b/docs/pkgdown.yml @@ -1,8 +1,8 @@ -pandoc: 3.1.2 +pandoc: 3.1.1 pkgdown: 2.0.7 pkgdown_sha: ~ articles: Developer_Style_Guide: Developer_Style_Guide.html MazamaLocationUtils: MazamaLocationUtils.html -last_built: 2024-01-23T19:14Z +last_built: 2024-08-15T02:46Z diff --git a/docs/reference/LocationDataDir.html b/docs/reference/LocationDataDir.html index 6df155b..6f2d955 100644 --- a/docs/reference/LocationDataDir.html +++ b/docs/reference/LocationDataDir.html @@ -20,7 +20,7 @@ MazamaLocationUtils - 0.4.3 + 0.4.4
diff --git a/docs/reference/MazamaLocationUtils.html b/docs/reference/MazamaLocationUtils.html index 8f2ca91..691de3c 100644 --- a/docs/reference/MazamaLocationUtils.html +++ b/docs/reference/MazamaLocationUtils.html @@ -22,7 +22,7 @@ MazamaLocationUtils - 0.4.3 + 0.4.4 diff --git a/docs/reference/apiKeys.html b/docs/reference/apiKeys.html index 8fe78bd..34e7f2c 100644 --- a/docs/reference/apiKeys.html +++ b/docs/reference/apiKeys.html @@ -21,7 +21,7 @@ MazamaLocationUtils - 0.4.3 + 0.4.4 diff --git a/docs/reference/clusterByDistance-1.png b/docs/reference/clusterByDistance-1.png index 3926a69..39f84ac 100644 Binary files a/docs/reference/clusterByDistance-1.png and b/docs/reference/clusterByDistance-1.png differ diff --git a/docs/reference/clusterByDistance.html b/docs/reference/clusterByDistance.html index 473cc31..8299965 100644 --- a/docs/reference/clusterByDistance.html +++ b/docs/reference/clusterByDistance.html @@ -25,7 +25,7 @@ MazamaLocationUtils - 0.4.3 + 0.4.4 diff --git a/docs/reference/coreMetadataNames.html b/docs/reference/coreMetadataNames.html index 7aa65bf..a737528 100644 --- a/docs/reference/coreMetadataNames.html +++ b/docs/reference/coreMetadataNames.html @@ -36,7 +36,7 @@ MazamaLocationUtils - 0.4.3 + 0.4.4 diff --git a/docs/reference/getLocationDataDir.html b/docs/reference/getLocationDataDir.html index 71a5847..aa663c2 100644 --- a/docs/reference/getLocationDataDir.html +++ b/docs/reference/getLocationDataDir.html @@ -17,7 +17,7 @@ MazamaLocationUtils - 0.4.3 + 0.4.4 diff --git a/docs/reference/id_monitors_500.html b/docs/reference/id_monitors_500.html index fa0585f..e1efe38 100644 --- a/docs/reference/id_monitors_500.html +++ b/docs/reference/id_monitors_500.html @@ -40,7 +40,7 @@ MazamaLocationUtils - 0.4.3 + 0.4.4 @@ -95,7 +95,7 @@

Idaho monitor locations dataset

initializeMazamaSpatialUtils() setLocationDataDir("./data") -monitor <- monitor_loadLatest() %>% monitor_filter(stateCode == "ID") +monitor <- monitor_loadLatest() %>% monitor_filter(stateCode == "ID") lons <- monitor$meta$longitude lats <- monitor$meta$latitude diff --git a/docs/reference/index.html b/docs/reference/index.html index 70b13f7..85ae77b 100644 --- a/docs/reference/index.html +++ b/docs/reference/index.html @@ -17,7 +17,7 @@ MazamaLocationUtils - 0.4.3 + 0.4.4 diff --git a/docs/reference/initializeMazamaSpatialUtils.html b/docs/reference/initializeMazamaSpatialUtils.html index 81dd2e9..69ce03e 100644 --- a/docs/reference/initializeMazamaSpatialUtils.html +++ b/docs/reference/initializeMazamaSpatialUtils.html @@ -27,7 +27,7 @@ MazamaLocationUtils - 0.4.3 + 0.4.4 diff --git a/docs/reference/location_createID.html b/docs/reference/location_createID.html index 8085ead..401edc8 100644 --- a/docs/reference/location_createID.html +++ b/docs/reference/location_createID.html @@ -24,7 +24,7 @@ MazamaLocationUtils - 0.4.3 + 0.4.4 diff --git a/docs/reference/location_getCensusBlock.html b/docs/reference/location_getCensusBlock.html index 494c3ce..8672441 100644 --- a/docs/reference/location_getCensusBlock.html +++ b/docs/reference/location_getCensusBlock.html @@ -24,7 +24,7 @@ MazamaLocationUtils - 0.4.3 + 0.4.4 diff --git a/docs/reference/location_getOpenCageInfo.html b/docs/reference/location_getOpenCageInfo.html index d9c614d..15862ca 100644 --- a/docs/reference/location_getOpenCageInfo.html +++ b/docs/reference/location_getOpenCageInfo.html @@ -20,7 +20,7 @@ MazamaLocationUtils - 0.4.3 + 0.4.4 diff --git a/docs/reference/location_getSingleAddress_Photon.html b/docs/reference/location_getSingleAddress_Photon.html index 313738b..948166d 100644 --- a/docs/reference/location_getSingleAddress_Photon.html +++ b/docs/reference/location_getSingleAddress_Photon.html @@ -34,7 +34,7 @@ MazamaLocationUtils - 0.4.3 + 0.4.4 diff --git a/docs/reference/location_getSingleAddress_TexasAM.html b/docs/reference/location_getSingleAddress_TexasAM.html index 1efbbde..43b1ca8 100644 --- a/docs/reference/location_getSingleAddress_TexasAM.html +++ b/docs/reference/location_getSingleAddress_TexasAM.html @@ -18,7 +18,7 @@ MazamaLocationUtils - 0.4.3 + 0.4.4 diff --git a/docs/reference/location_getSingleElevation_USGS.html b/docs/reference/location_getSingleElevation_USGS.html index b01978a..b2a37e3 100644 --- a/docs/reference/location_getSingleElevation_USGS.html +++ b/docs/reference/location_getSingleElevation_USGS.html @@ -19,7 +19,7 @@ MazamaLocationUtils - 0.4.3 + 0.4.4 diff --git a/docs/reference/location_initialize.html b/docs/reference/location_initialize.html index 3854943..2de6040 100644 --- a/docs/reference/location_initialize.html +++ b/docs/reference/location_initialize.html @@ -33,7 +33,7 @@ MazamaLocationUtils - 0.4.3 + 0.4.4 diff --git a/docs/reference/or_monitors_500.html b/docs/reference/or_monitors_500.html index cb0b58b..2c679b6 100644 --- a/docs/reference/or_monitors_500.html +++ b/docs/reference/or_monitors_500.html @@ -40,7 +40,7 @@ MazamaLocationUtils - 0.4.3 + 0.4.4 @@ -95,7 +95,7 @@

Oregon monitor locations dataset

initializeMazamaSpatialUtils() setLocationDataDir("./data") -monitor <- monitor_loadLatest() %>% monitor_filter(stateCode == "OR") +monitor <- monitor_loadLatest() %>% monitor_filter(stateCode == "OR") lons <- monitor$meta$longitude lats <- monitor$meta$latitude diff --git a/docs/reference/pipe.html b/docs/reference/pipe.html index 2837759..09ce081 100644 --- a/docs/reference/pipe.html +++ b/docs/reference/pipe.html @@ -17,7 +17,7 @@ MazamaLocationUtils - 0.4.3 + 0.4.4 diff --git a/docs/reference/setLocationDataDir.html b/docs/reference/setLocationDataDir.html index a66d500..d249be9 100644 --- a/docs/reference/setLocationDataDir.html +++ b/docs/reference/setLocationDataDir.html @@ -18,7 +18,7 @@ MazamaLocationUtils - 0.4.3 + 0.4.4 diff --git a/docs/reference/table_addClustering-1.png b/docs/reference/table_addClustering-1.png index 29e9095..9315fe3 100644 Binary files a/docs/reference/table_addClustering-1.png and b/docs/reference/table_addClustering-1.png differ diff --git a/docs/reference/table_addClustering.html b/docs/reference/table_addClustering.html index 7e20740..f50a88e 100644 --- a/docs/reference/table_addClustering.html +++ b/docs/reference/table_addClustering.html @@ -28,7 +28,7 @@ MazamaLocationUtils - 0.4.3 + 0.4.4 diff --git a/docs/reference/table_addColumn.html b/docs/reference/table_addColumn.html index ba393f7..d17892b 100644 --- a/docs/reference/table_addColumn.html +++ b/docs/reference/table_addColumn.html @@ -19,7 +19,7 @@ MazamaLocationUtils - 0.4.3 + 0.4.4 diff --git a/docs/reference/table_addCoreMetadata.html b/docs/reference/table_addCoreMetadata.html index 8a1f773..d0cd0ab 100644 --- a/docs/reference/table_addCoreMetadata.html +++ b/docs/reference/table_addCoreMetadata.html @@ -43,7 +43,7 @@ MazamaLocationUtils - 0.4.3 + 0.4.4 diff --git a/docs/reference/table_addLocation.html b/docs/reference/table_addLocation.html index aea2e23..24523fc 100644 --- a/docs/reference/table_addLocation.html +++ b/docs/reference/table_addLocation.html @@ -20,7 +20,7 @@ MazamaLocationUtils - 0.4.3 + 0.4.4 diff --git a/docs/reference/table_addOpenCageInfo.html b/docs/reference/table_addOpenCageInfo.html index 0104b39..dbed244 100644 --- a/docs/reference/table_addOpenCageInfo.html +++ b/docs/reference/table_addOpenCageInfo.html @@ -37,7 +37,7 @@ MazamaLocationUtils - 0.4.3 + 0.4.4 diff --git a/docs/reference/table_addSingleLocation.html b/docs/reference/table_addSingleLocation.html index cfe35b5..66e4cf7 100644 --- a/docs/reference/table_addSingleLocation.html +++ b/docs/reference/table_addSingleLocation.html @@ -20,7 +20,7 @@ MazamaLocationUtils - 0.4.3 + 0.4.4 diff --git a/docs/reference/table_filterByDistance.html b/docs/reference/table_filterByDistance.html index 2e1fee5..f8efb06 100644 --- a/docs/reference/table_filterByDistance.html +++ b/docs/reference/table_filterByDistance.html @@ -19,7 +19,7 @@ MazamaLocationUtils - 0.4.3 + 0.4.4 diff --git a/docs/reference/table_findAdjacentDistances.html b/docs/reference/table_findAdjacentDistances.html index af44b6c..be4d5a8 100644 --- a/docs/reference/table_findAdjacentDistances.html +++ b/docs/reference/table_findAdjacentDistances.html @@ -23,7 +23,7 @@ MazamaLocationUtils - 0.4.3 + 0.4.4 diff --git a/docs/reference/table_findAdjacentLocations.html b/docs/reference/table_findAdjacentLocations.html index 9fcca5d..0168e19 100644 --- a/docs/reference/table_findAdjacentLocations.html +++ b/docs/reference/table_findAdjacentLocations.html @@ -23,7 +23,7 @@ MazamaLocationUtils - 0.4.3 + 0.4.4 diff --git a/docs/reference/table_getDistanceFromTarget.html b/docs/reference/table_getDistanceFromTarget.html index 3dcaf3b..64ba293 100644 --- a/docs/reference/table_getDistanceFromTarget.html +++ b/docs/reference/table_getDistanceFromTarget.html @@ -20,7 +20,7 @@ MazamaLocationUtils - 0.4.3 + 0.4.4 diff --git a/docs/reference/table_getLocationID.html b/docs/reference/table_getLocationID.html index 4ca185b..2bbc847 100644 --- a/docs/reference/table_getLocationID.html +++ b/docs/reference/table_getLocationID.html @@ -21,7 +21,7 @@ MazamaLocationUtils - 0.4.3 + 0.4.4 diff --git a/docs/reference/table_getNearestDistance.html b/docs/reference/table_getNearestDistance.html index f5950e0..95b432a 100644 --- a/docs/reference/table_getNearestDistance.html +++ b/docs/reference/table_getNearestDistance.html @@ -24,7 +24,7 @@ MazamaLocationUtils - 0.4.3 + 0.4.4 diff --git a/docs/reference/table_getNearestLocation.html b/docs/reference/table_getNearestLocation.html index fc6b0d9..e8aa533 100644 --- a/docs/reference/table_getNearestLocation.html +++ b/docs/reference/table_getNearestLocation.html @@ -21,7 +21,7 @@ MazamaLocationUtils - 0.4.3 + 0.4.4 diff --git a/docs/reference/table_getRecordIndex.html b/docs/reference/table_getRecordIndex.html index ea00470..eeee3b7 100644 --- a/docs/reference/table_getRecordIndex.html +++ b/docs/reference/table_getRecordIndex.html @@ -18,7 +18,7 @@ MazamaLocationUtils - 0.4.3 + 0.4.4 diff --git a/docs/reference/table_initialize.html b/docs/reference/table_initialize.html index 2183f8c..3a56878 100644 --- a/docs/reference/table_initialize.html +++ b/docs/reference/table_initialize.html @@ -34,7 +34,7 @@ MazamaLocationUtils - 0.4.3 + 0.4.4 diff --git a/docs/reference/table_initializeExisting.html b/docs/reference/table_initializeExisting.html index c2e94d3..9e36082 100644 --- a/docs/reference/table_initializeExisting.html +++ b/docs/reference/table_initializeExisting.html @@ -47,7 +47,7 @@ MazamaLocationUtils - 0.4.3 + 0.4.4 diff --git a/docs/reference/table_leaflet.html b/docs/reference/table_leaflet.html index a80adf7..7fd9794 100644 --- a/docs/reference/table_leaflet.html +++ b/docs/reference/table_leaflet.html @@ -20,7 +20,7 @@ MazamaLocationUtils - 0.4.3 + 0.4.4 diff --git a/docs/reference/table_leafletAdd.html b/docs/reference/table_leafletAdd.html index 6c7e8d4..430274b 100644 --- a/docs/reference/table_leafletAdd.html +++ b/docs/reference/table_leafletAdd.html @@ -20,7 +20,7 @@ MazamaLocationUtils - 0.4.3 + 0.4.4 @@ -103,7 +103,7 @@

Arguments

...
-

Additional arguments passed to leaflet::addCircleMarkers().

+

Additional arguments passed to leaflet::addCircleMarkers().

diff --git a/docs/reference/table_load.html b/docs/reference/table_load.html index 08d6aa1..1da63cc 100644 --- a/docs/reference/table_load.html +++ b/docs/reference/table_load.html @@ -21,7 +21,7 @@ MazamaLocationUtils - 0.4.3 + 0.4.4
diff --git a/docs/reference/table_removeColumn.html b/docs/reference/table_removeColumn.html index 723e5c0..039c2c7 100644 --- a/docs/reference/table_removeColumn.html +++ b/docs/reference/table_removeColumn.html @@ -18,7 +18,7 @@ MazamaLocationUtils - 0.4.3 + 0.4.4 diff --git a/docs/reference/table_removeRecord.html b/docs/reference/table_removeRecord.html index c88e2b7..51534ee 100644 --- a/docs/reference/table_removeRecord.html +++ b/docs/reference/table_removeRecord.html @@ -18,7 +18,7 @@ MazamaLocationUtils - 0.4.3 + 0.4.4 diff --git a/docs/reference/table_save.html b/docs/reference/table_save.html index b7aac87..9ca447c 100644 --- a/docs/reference/table_save.html +++ b/docs/reference/table_save.html @@ -19,7 +19,7 @@ MazamaLocationUtils - 0.4.3 + 0.4.4 @@ -130,7 +130,7 @@

Examples

# Check the locationDataDir list.files(getLocationDataDir(), pattern = "table_save_example") -#> [1] "table_save_example.2024-01-23T11:15:12.rda" +#> [1] "table_save_example.2024-08-14T19:48:13.rda" #> [2] "table_save_example.rda"
diff --git a/docs/reference/table_updateColumn.html b/docs/reference/table_updateColumn.html index 06f0783..9d1273a 100644 --- a/docs/reference/table_updateColumn.html +++ b/docs/reference/table_updateColumn.html @@ -23,7 +23,7 @@ MazamaLocationUtils - 0.4.3 + 0.4.4 diff --git a/docs/reference/table_updateSingleRecord.html b/docs/reference/table_updateSingleRecord.html index 9dd1ee2..c22b796 100644 --- a/docs/reference/table_updateSingleRecord.html +++ b/docs/reference/table_updateSingleRecord.html @@ -21,7 +21,7 @@ MazamaLocationUtils - 0.4.3 + 0.4.4 diff --git a/docs/reference/validateLocationTbl.html b/docs/reference/validateLocationTbl.html index 9321fca..ec74994 100644 --- a/docs/reference/validateLocationTbl.html +++ b/docs/reference/validateLocationTbl.html @@ -18,7 +18,7 @@ MazamaLocationUtils - 0.4.3 + 0.4.4 diff --git a/docs/reference/validateLonLat.html b/docs/reference/validateLonLat.html index fbe3524..25cf3eb 100644 --- a/docs/reference/validateLonLat.html +++ b/docs/reference/validateLonLat.html @@ -17,7 +17,7 @@ MazamaLocationUtils - 0.4.3 + 0.4.4 diff --git a/docs/reference/validateLonsLats.html b/docs/reference/validateLonsLats.html index d3566a9..af57468 100644 --- a/docs/reference/validateLonsLats.html +++ b/docs/reference/validateLonsLats.html @@ -17,7 +17,7 @@ MazamaLocationUtils - 0.4.3 + 0.4.4 diff --git a/docs/reference/validateMazamaSpatialUtils.html b/docs/reference/validateMazamaSpatialUtils.html index 8236281..c4f6427 100644 --- a/docs/reference/validateMazamaSpatialUtils.html +++ b/docs/reference/validateMazamaSpatialUtils.html @@ -19,7 +19,7 @@ MazamaLocationUtils - 0.4.3 + 0.4.4 diff --git a/docs/reference/wa_airfire_meta.html b/docs/reference/wa_airfire_meta.html index df93307..9e9e2a7 100644 --- a/docs/reference/wa_airfire_meta.html +++ b/docs/reference/wa_airfire_meta.html @@ -34,7 +34,7 @@ MazamaLocationUtils - 0.4.3 + 0.4.4 @@ -86,9 +86,9 @@

Washington monitor metadata dataset

library(AirMonitor) wa_airfire_meta <- - airnow_loadLatest() %>% - monitor_filter(stateCode == "WA") %>% - monitor_getMeta() %>% + airnow_loadLatest() %>% + monitor_filter(stateCode == "WA") %>% + monitor_getMeta() %>% # On 2023-10-24, this metdata still uses zip instead of postalCode dplyr::rename(postalCode = zip) %>% # Remove internal fields diff --git a/docs/reference/wa_monitors_500.html b/docs/reference/wa_monitors_500.html index 7fe1d07..a4d1ba2 100644 --- a/docs/reference/wa_monitors_500.html +++ b/docs/reference/wa_monitors_500.html @@ -40,7 +40,7 @@ MazamaLocationUtils - 0.4.3 + 0.4.4 @@ -95,7 +95,7 @@

Wshington monitor locations dataset

initializeMazamaSpatialUtils() setLocationDataDir("./data") -monitor <- monitor_loadLatest() %>% monitor_filter(stateCode == "WA") +monitor <- monitor_loadLatest() %>% monitor_filter(stateCode == "WA") lons <- monitor$meta$longitude lats <- monitor$meta$latitude diff --git a/tests/testthat/test-clusterByDistance.R b/tests/testthat/test-clusterByDistance.R new file mode 100644 index 0000000..1070ed1 --- /dev/null +++ b/tests/testthat/test-clusterByDistance.R @@ -0,0 +1,22 @@ +context("clusterByDistance") + +test_that("clustering works for small tables", { + + # ?cluster::pam says: + # maxClusters = positive integer specifying the number of clusters, less than the number of observations. + + # Table with only 2 rows + tbl <- dplyr::tibble(longitude = c(-127.1, -127.3, -127.5), latitude = c(45.1, 45.3, 45.5)) + + expect_no_error({ + clusteredTbl <- + clusterByDistance( + tbl, + clusterDiameter = 1000, + lonVar = "longitude", + latVar = "latitude", + maxClusters = 50 + ) + }) + +})