I am trying to get coordinates of various cities with R and the osmdata package. My code looks like this
cities<-c("Name1","Name2")
for (city in cities){
city <-getbb(
city,
format_out = "matrix",
base_url = "https://nominatim.openstreetmap.org",
featuretype = "settlement",
limit = 10,
)
}
I would like the coordinates to be attributed to the actual name of the city in the loop e.g. for the first iteracy of the loop
Name1<- getbb("Name1")
and so on, but I cannot find a way to index the output of the getbb() function inside the loop with the name of the variable inside the getbb() function.
I do not want to use a number to index the coordinates as I have many cities.
How can I do it ?