Here is the script as far as it goes, until I receive the error-code. If you could make out the problem, that would be really helpful.
library(osmdata)
library(sf)
library(sp)
library(rgdal)
# Reading Data
LostLetterFairtrade0221<-readRDS("~/Documents/Forschungsseminar/LostLetterFairtrade0221.rds")
# Funktion to Convert from wgs84 to UTM
WGS.to.UTM<-function(long, lat, utm.zone){
utm.zone=as.character(utm.zone)
if(length(utm.zone)==1){utm.zone=rep(utm.zone, length(long))}
coords=data.frame(long, lat)
names(coords)=c("long","lat")
#prepare map for conversion to UTM:
coordinates(coords)<-c("long","lat")
coords@proj4string=CRS("+proj=longlat +datum=WGS84")
#deterine parameters of the transformation:
#browser()
transf.param=unlist(lapply(utm.zone, function(x){
CRS(paste("+proj=utm +zone=", x ," +datum=WGS84", sep=""))
}))
#... and transform it to UTM
new.coords=lapply(1:length(coords), function(x){
spTransform(coords[x,], transf.param[[x]])@coords
})
new.coords=as.data.frame(matrix(unlist(new.coords), ncol=2, byrow=T))
names(new.coords)=c("long", "lat")
#new.coords$lat[new.coords$lat<0]=10000000-new.coords$lat[new.coords$lat<0]
return(new.coords)
}
#### UTM-Koordinaten for the letters
utm33n_llocs=WGS.to.UTM(long=LostLetterFairtrade0221$long, lat=LostLetterFairtrade0221$lat, utm.zone="33N")
LostLetterFairtrade0221$long_utm33n=utm33n_llocs$long
LostLetterFairtrade0221$lat_utm33n=utm33n_llocs$lat
api_list <- c('https://overpass.kumi.systems/api/interpreter')
api_to_use <- sample(1:length(api_list), 1)
set_overpass_url(api_list[api_to_use])
#### Waldflächen ziehen
forest <- opq(bbox = "bb") %>%
add_osm_feature(key = 'landuse', value = "forest") %>%
osmdata_sf () %>%
trim_osmdata ("bb")
forest_points=forest$osm_points[1]