-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathTileLayerPlugin_Renamer.R
More file actions
36 lines (29 loc) · 1.12 KB
/
Copy pathTileLayerPlugin_Renamer.R
File metadata and controls
36 lines (29 loc) · 1.12 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
rm(list=ls(all=TRUE)) # clear memory
packages<- c("tools", "foreign","png","jpeg") # list the packages that you'll need
lapply(packages, require, character.only=T) # load the packages, if they don't load you might need to install them first
# setwd("C:/Temp/Tiles")
setwd("/home/matthew/Documents/HUE")
stub <- "ArcStreet"
all.jpeg.tiles <- list.files(path = stub,pattern="\\.jpeg$")
out.folder <- paste(stub,"_Processed",sep="")
#pattern = FOLDER-FILE-ZOOM
for (each.jpeg.tile in all.jpeg.tiles){
each.all <- file_path_sans_ext(each.jpeg.tile)
print(each.all)
parts <- strsplit(each.all, "-")[[1]]
zoomy <- parts[3]
foldery <- parts[1]
filey <- parts[2]
if (!file.exists(out.folder)){
dir.create(out.folder)
}
if (!file.exists(paste(out.folder,zoomy,sep="/"))){
dir.create(paste(out.folder,zoomy,sep="/"))
}
if (!file.exists(paste(out.folder,zoomy,foldery,sep="/"))){
dir.create(paste(out.folder,zoomy,foldery,sep="/"))
}
each.path <- paste(out.folder,"/",zoomy,"/",foldery,"/",filey,".png",sep = "")
each.jpg <- readJPEG(paste(stub,"/",each.jpeg.tile,sep=""))
writePNG(each.jpg,each.path)
}