Pointcluster: Cluster nearby points

View source: R/Pointcluster.R

PointclusterR Documentation

Cluster nearby points

Description

Cluster points within a given distance of one another

Usage

Pointcluster(
  Points,
  Distance,
  In_water_distance = FALSE,
  Latitude_column,
  Longitude_column,
  PointID_column,
  Points_crs = 4326,
  Calculation_crs = 32610,
  Water_map = NULL,
  Water_map_transitioned = NULL,
  Grid_size = 75,
  Expand = TRUE
)

Arguments

Points

A dataframe of points with latitude and longitude

Distance

Clustering distance in meters.

In_water_distance

Should clustering be based on in-water distance? If yes, in-water distances will be calculated with Waterdist and this function will be slower. NOTE: For in-water distances, any points outside the Water_map shapefile polygons will be moved inside before distances are calculated for clustering. The parameters Water_map, Water_map_transitioned and Grid_size will be ignored unless In_water_distance = TRUE.

Latitude_column

The unquoted name of the column in the Points dataframe representing Latitude.

Longitude_column

The unquoted name of the column in the Points dataframe representing Longitude.

PointID_column

The unquoted name of the column in the Points dataframe with the unique identifier of each point.

Points_crs

Coordinate reference system for your Points dataframe. Integer with the EPSG code or character with proj4string.

Calculation_crs

Coordinate reference system used for the calculation. If a latitude/longitude system are used, errors may be returned since some calculations assume a planar surface. Defaults to Calculation_crs = 32610.

Water_map

Object of class sf representing a map of all waterways in your region of interest

Water_map_transitioned

A rasterized, transitioned, and geo-corrected version of the water map. This is optional to save time if you will be running this function frequently with the same base map.

Grid_size

Grid size (in meters) used to rasterize the map. Defaults to 75.

Expand

Should data be expanded at the end? If TRUE (the default), the result will be expanded so there is 1 row per unique value of the PointID_column. If FALSE , the returned object will have 1 row per cluster and a list column with the names of each PointID_column value contained in each cluster.

Details

The parameters Water_map, Water_map_transitioned and Grid_size will be ignored unless In_water_distance = TRUE.

Value

A tibble relating each point to its assigned cluster. The returned Latitude and Longitude values represent the mean values across all points in each cluster.

Examples

library(tibble)
Points <- tibble(Latitude = c(38.07194, 38.09306, 38.11722,
                              38.11528, 38.07020, 38.09383,
                              38.11783, 38.06481, 38.11400,
                              38.06750, 38.11556),
                 Longitude = c(-122.0961, -122.0692, -122.0472,
                               -122.0519, -122.0941, -122.0697,
                               -122.0418, -122.0978, -122.0462,
                               -122.0956, -122.0424),
                 ID = c("EMP NZ022", "EMP NZ024", "EMP NZ028",
                        "EMP NZ030", "FMWT 416", "FMWT 418",
                        "FMWT 602", "TNS 418", "TNS 602",
                        "twentymm 418", "twentymm 602"))
Points_clust<-Pointcluster(Points, 1000, FALSE, Latitude, Longitude, ID, Expand=TRUE)

sbashevkin/spacetools documentation built on Feb. 2, 2024, 9:15 p.m.