1

I have a simple map and like to export the used coordinates of latitude/longitude into an external CSV file. Is this possible?

library('maps')
map(database='world',regions='germany')
rcs
3,8941 gold badge30 silver badges31 bronze badges
asked May 16, 2020 at 9:58

1 Answer 1

1

The (invisible) return value of map is a list with x, y, range, and names components (See Value section in the manual page, i.e. ?map):

dat <- map(database="world",regions = "germany", plot = FALSE)
str(dat)
# List of 4
# $ x : num [1:596] 14.2 14.2 14 13.9 13.9 ...
# $ y : num [1:596] 53.9 53.9 53.9 53.9 53.9 ...
# $ range: num [1:4] 5.86 15.02 47.28 55.06
# $ names: chr [1:7] "Germany:Usedom" "Germany:Fehmarn" "Germany:Rugen" "Germany:4" ...
# - attr(*, "class")= chr "map"
write.table(data.frame(x = dat$x, y = dat$y), "germany.csv")
answered May 16, 2020 at 11:06

Your Answer

Draft saved
Draft discarded

Sign up or log in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

Post as a guest

Required, but never shown

By clicking "Post Your Answer", you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.