changes to make it run for me
This commit is contained in:
parent
a36db4e84b
commit
68bc273899
2 changed files with 54 additions and 3 deletions
|
@ -1,3 +1,47 @@
|
|||
#' DMS to Decimal
|
||||
#'
|
||||
#' Convert geocoordinates froom DMS format to decimal
|
||||
#'
|
||||
#' @param input
|
||||
#'
|
||||
#' @return
|
||||
#' @export
|
||||
#'
|
||||
#' @examples
|
||||
dms_to_decimal <- function(input) {
|
||||
if(is.na(input)) {
|
||||
return(NA)
|
||||
}
|
||||
else {
|
||||
return(sp::char2dms(input, chd="d", chm="m", chs="s") |>
|
||||
as.numeric())
|
||||
}
|
||||
}
|
||||
|
||||
#' Convert Semantic Wiki style coordinates to DMS
|
||||
#'
|
||||
#' @param dataset
|
||||
#' @param geocoordinates_variable
|
||||
#'
|
||||
#' @return
|
||||
#' @export
|
||||
#'
|
||||
#' @examples
|
||||
get_decimal_coordinates <- function(dataset, geocoordinates_variable) {
|
||||
dataset |>
|
||||
mutate(
|
||||
{{geocoordinates_variable}} := toupper({{geocoordinates_variable}}),
|
||||
{{geocoordinates_variable}} := str_replace_all({{geocoordinates_variable}}, '°', "d"),
|
||||
{{geocoordinates_variable}} := str_replace_all({{geocoordinates_variable}}, "'", "m"),
|
||||
{{geocoordinates_variable}} := str_replace_all({{geocoordinates_variable}}, '"', "s")) |>
|
||||
mutate(geo_split = stringr::str_split({{geocoordinates_variable}}, ",")) |>
|
||||
rowwise() |>
|
||||
mutate(latitude = dms_to_decimal(geo_split[1]),
|
||||
longitude = dms_to_decimal(geo_split[2])) |>
|
||||
select(-geo_split, -{{geocoordinates_variable}})
|
||||
}
|
||||
|
||||
|
||||
# Note to future developers
|
||||
#
|
||||
# We finished working on this project early due to difficulties with the project management,
|
||||
|
@ -12,11 +56,16 @@
|
|||
library(tidyverse)
|
||||
library(tidygraph)
|
||||
|
||||
wiki <- readr::read_csv("data-raw/result.csv")
|
||||
wiki_2 <- readr::read_csv("data-raw/result_2.csv")
|
||||
wiki <- readr::read_csv("data-raw/test/result.csv")
|
||||
wiki_2 <- readr::read_csv("data-raw/test/result2.csv")
|
||||
wiki_3 <- readr::read_csv("data-raw/test/result3.csv")
|
||||
wiki_4 <- readr::read_csv("data-raw/test/result4.csv")
|
||||
wiki_5 <- readr::read_csv("data-raw/test/result5.csv")
|
||||
# wiki_3 <- readr::read_csv("data-raw/result_3.csv")
|
||||
wiki <- wiki |> add_row(wiki_2)
|
||||
# |> add_row(wiki_3)
|
||||
wiki <- wiki |> add_row(wiki_3)
|
||||
wiki <- wiki |> add_row(wiki_4)
|
||||
wiki <- wiki |> add_row(wiki_5)
|
||||
# wiki <- readr::read_csv("https://www.securityvision.io/wiki/index.php/Special:Ask/format%3Dcsv/limit%3D999999/link%3Dall/headers%3Dshow/searchlabel%3DCSV/class%3Dsortable-20wikitable-20smwtable/order%3Dasc/sort%3D/offset%3D0/-5B-5BCategory:Deployments-7C-7CInstitution-7C-7CDataset-7C-7CPerson-7C-7CTechnology-5D-5D/-3FCategory/-3FClients/-3FManaged-20by/-3FUsed-20by/-3FFunded-20by/-3FProvided-20by/-3FSoftware-20Deployed/-3FDatasets-20Used/-3FRelated-20Institutions/-3FIs-20Department-20Of/-3FInvolved-20Entities/mainlabel%3D/prettyprint%3Dtrue/unescape%3Dtrue")
|
||||
|
||||
# variable names
|
||||
|
@ -64,6 +113,8 @@ wiki_edges <- wiki_edges |>
|
|||
filter(from != to) |>
|
||||
distinct()
|
||||
|
||||
load(file='data/cities.rda')
|
||||
|
||||
# nodes values
|
||||
wiki_nodes <- wiki_nodes |>
|
||||
mutate(category = if_else(category == "deployments", "deployment", category))
|
||||
|
|
BIN
data/wiki.rda
BIN
data/wiki.rda
Binary file not shown.
Loading…
Reference in a new issue