comparison crea_carte_G.R @ 0:e3cd588fd14a draft

planemo upload for repository https://github.com/galaxyecology/tools-ecology/tree/master/tools/Ecoregionalization_workflow commit 2a2ae892fa2dbc1eff9c6a59c3ad8f3c27c1c78d
author ecology
date Wed, 18 Oct 2023 09:58:17 +0000
parents
children 9dc992f80c25
comparison
equal deleted inserted replaced
-1:000000000000 0:e3cd588fd14a
1 #Author : Seguineau Pauline
2
3
4 #Create a map from cluster
5
6 library(sf)
7 library(tmap)
8 library(dplyr)
9
10 args = commandArgs(trailingOnly=TRUE)
11 if (length(args)==0)
12 {
13 stop("This tool needs at least one argument")
14 }else{
15 data <- args[1]
16 }
17
18 clus <- read.table(data, header=TRUE, na.strings = "na")
19
20 #tmap method
21
22 sf_data <- st_as_sf(clus, coords = c("long", "lat"), crs =4326)
23
24 grouped_data <- sf_data %>%
25 group_by(cluster) %>%
26 summarize()
27
28 map <- tm_shape(grouped_data) +
29 tm_dots(col = "cluster", palette = "Accent", size = 0.1, title = "écorégions")+
30 tm_scale_bar(position = c("right","top"))+
31 tm_compass(position = c("right","top"))+
32 tm_layout(frame = FALSE,legend.position = c("left","bottom"))+
33 tm_xlab("Longitude")+
34 tm_ylab("Latitude")+
35 tm_grid(alpha = 0.2)
36
37 #Save the map
38 tmap_save(map, "ecoregions.png")