view crea_carte_G.R @ 4:cf7aefee9977 draft default tip

planemo upload for repository https://github.com/galaxyecology/tools-ecology/tree/master/tools/Ecoregionalization_workflow commit c41939f1cdc03331ec021d47495576a6b0c5fd14
author ecology
date Wed, 16 Oct 2024 11:45:55 +0000
parents e94a25eed489
children
line wrap: on
line source

#Author : Seguineau Pauline


#Create a map from cluster

library(sf)
library(tmap)
library(dplyr)

args = commandArgs(trailingOnly=TRUE) 
if (length(args)==0)
{
    stop("This tool needs at least one argument")
}else{
    data <- args[1]
}

clus <- read.table(data, sep="\t" ,header=TRUE, na.strings = "na")

#tmap method

sf_data <- st_as_sf(clus, coords = c("long", "lat"), crs =4326)

grouped_data <- sf_data %>%
  group_by(cluster) %>%
  summarize()

map <- tm_shape(grouped_data) + 
  tm_dots(col = "cluster", palette = "Accent", n=256, size = 0.1, title = "ecoregions")+
  tm_scale_bar(position = c("right","top"))+
  tm_compass(position = c("right","top"))+
  tm_layout(frame = FALSE,legend.position = c("left","bottom"))+
  tm_xlab("Longitude")+
  tm_ylab("Latitude")+
  tm_grid(alpha = 0.2)

#Save the map 
tmap_save(map, "ecoregions.png")