injunjane: (Default)
[personal profile] injunjane
Some R code for mapping collection points from the table of coordinates:


install.packages("maps")
library(maps)

locations <- read.csv("locations.csv", header=TRUE)
View(locations)


world_map <- map_data("world")

#Creat a base plot with gpplot2
p <- ggplot() + coord_fixed() +
xlab("") + ylab("")

p


#Add map to base plot
base_world_messy <- p + geom_polygon(data=world_map, aes(x=long, y=lat, group=group),
colour="darkgray", fill="gray")

base_world_messy

#Strip the map down so it looks super clean (and beautiful!)
cleanup <-
theme(panel.grid.major = element_blank(), panel.grid.minor = element_blank(),
panel.background = element_rect(fill = 'white', colour = 'white'),
axis.line = element_line(colour = "white"), legend.position="none",
axis.ticks=element_blank(), axis.text.x=element_blank(),
axis.text.y=element_blank())

base_world <- base_world_messy + cleanup

base_world

map_data <-
base_world +
geom_point(data=locations,
aes(x=decimalLongitude, y=decimalLatitude), colour="black",
fill="lightblue",pch=21, size=2, alpha=I(0.7))

map_data

This account has disabled anonymous posting.
If you don't have an account you can create one now.
HTML doesn't work in the subject.
More info about formatting

Profile

injunjane: (Default)
injunjane

July 2025

S M T W T F S
  1 2345
6789101112
13141516171819
20212223242526
2728293031  

Most Popular Tags

Style Credit

Expand Cut Tags

No cut tags
Page generated Jul. 18th, 2025 11:58 pm
Powered by Dreamwidth Studios