| geom_within_gs | R Documentation |
Test if geometry of a resource, example heritage place (HP) is within a Grid Square (gs). If so, return ID of Grid Square.
geom_within_gs( resource.wkt = NA, gs.path = paste0(system.file(package = "eamenaR"), "/extdata/grid_squares.geojson"), verbose = TRUE )
resource.wkt |
WKT geometry of resource, as character format. This WKT geometry can come from a bulk upload sheet (ex: "POINT(0.9 35.8)"). |
gs.path |
path to GeoJSON file, default to the example 'grid_squares.geojson' This GeoJSON is an EAMENA output of Grids as a GeoJSON URL. Name of grids can be calculated with geom_bbox function. GeoJSON is read and convert to 'sf' object. |
verbose |
if TRUE (default): verbose. |
This function must be nested in a loop when called for a database.
the ID of Grid Square for each WKT geometries.
# test on a couple of coordinates
geom_within_gs(resource.wkt = "POINT(0.9 35.8)")
# run on an XLSX sheet, and print the result in the console (~ BU)
df <- readxl::read_excel("C:/Users/Thomas Huet/Desktop/temp_xlsx/Potential sites-Western Desert Simi-Kenawi.xlsx")
values <- c()
for(i in seq(1, nrow(df))){
wkt <- as.character(df[i, "Geometric Place Expression"])
grid.id <- geom_within_gs(resource.wkt = wkt,
gs.path = "C:/Users/Thomas Huet/Desktop/temp_xlsx/gs.geojson",
verbose = FALSE)
values <- c(values, grid.id)
}
is.na(values) <- ""
cat(values, sep = "\n")