From 7f1f1502d46a2c4721e7f472d5d00c14462add1c Mon Sep 17 00:00:00 2001 From: Giancarlo Panichi Date: Tue, 6 Jun 2023 15:08:49 +0200 Subject: [PATCH] Added support to create zip file --- README.md | 5 +---- simpleobismapsCCP.R | 18 +++++++++++++++--- 2 files changed, 16 insertions(+), 7 deletions(-) diff --git a/README.md b/README.md index ba5dccd..cec9976 100644 --- a/README.md +++ b/README.md @@ -1,9 +1,6 @@ # SimpleOBISMaps -SimpleOBISMaps is an example written in R that allows you to create an image of the occurrences present in OBIS starting from a file that contains the scientific names and a polygon. - -As can be seen, there are 2 scripts, one to be integrated with the SAI simpleobismapsSAI.R and the other with the CCP simpleobismapsCCP.R. -The differences are few between the two scripts only that the CPP takes the parameters directly from the command line. +SimpleOBISMaps is an example written in R that allows you to create a set of maps packaged in a zip file called maps.zip. This maps describe the occurrences present in OBIS starting from a file that contains the scientific names and a polygon. Starting from this example, you can first create a docker image in which it is installed the file simpleobismapsCCP.R. diff --git a/simpleobismapsCCP.R b/simpleobismapsCCP.R index 8a2828b..bd7d98e 100644 --- a/simpleobismapsCCP.R +++ b/simpleobismapsCCP.R @@ -1,4 +1,4 @@ -# simpleobisCCP.R +# simpleobismapsCCP.R # Simple example for CCP integration # # Author: Giancarlo Panichi @@ -8,10 +8,11 @@ library(robis) library(ggplot2) library(rgeos) library(stringr) +library(utils) createplot <- function(sname,usedPolygon){ result = tryCatch({ - result=paste("/ccp_data/",sname,".png",sep="") + result=paste("/ccp_data/maps/",sname,".png",sep="") wktP <-readWKT(usedPolygon) print(wktP@bbox) @@ -45,6 +46,13 @@ readfile <- function(filename, usedPolygon) { close(con) } +checkmapsfolder <- function(){ + if (!dir.exists("/ccp_data/maps")){ + dir.create("/ccp_data/maps") + }else{ + print("maps dir exists") + } +} #url="https://data.d4science.net/Y8WK" #usedPolygon="POLYGON((-5.657713322217344 45.88175260533238,38.99072417778265 45.88175260533238,38.99072417778265 29.60135866020714,-5.657713322217344 29.60135866020714,-5.657713322217344 45.88175260533238))" @@ -60,9 +68,13 @@ main <- function(){ url=args[1] usedPolygon=args[2] - download.file(url, filename) + mapszip="maps.zip" + download.file(url, filename) + checkmapsfolder() readfile(filename,usedPolygon) + zip(zipfile = mapszip, files = "ccp_data/maps") + } main()