Mercurial > repos > ecology > ecoregion_geonearestneighbor
comparison crea_carte_G.R @ 0:5cde56683579 draft default tip
planemo upload for repository https://github.com/galaxyecology/tools-ecology/tree/master/tools/Ecoregionalization_workflow commit 5d48df67919fbc9d77b98a8243d438c397f61a0e
author | ecology |
---|---|
date | Thu, 21 Mar 2024 14:05:01 +0000 |
parents | |
children |
comparison
equal
deleted
inserted
replaced
-1:000000000000 | 0:5cde56683579 |
---|---|
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, sep="\t" ,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", n=256, size = 0.1, title = "ecoregions")+ | |
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") |