Skip to content
Prev 255663 / 398506 Next

another question on shapefiles and geom_point in ggplot2

Thank you very much Felipe,

Did you see the solution from ahmadou dicko?
He doesn?t use gpclibPermit()

I have another option but I cannot get the right fill for the id.

See attached map.

ai_biotica = readOGR(dsn="C:/ProyectosRespacial/ICE/SIG_Biotica_PHED", 
layer="AI_BIOTICA_010411_CRTM05")
str(ai_biotica)

# fortify to get the data

fortify.ai_biotica <- 
fortify.SpatialPolygonsDataFrame(ai_biotica,region='Area_Influ')
names(fortify.ai_biotica)
str(fortify.ai_biotica)
levels(fortify.ai_biotica$group)

# mapa

ggplot(fortify.ai_biotica, aes(x = long, y=lat, group =  group)) + 
geom_polygon(colour = "black", fill = NA)

geo = read.csv("riqueza_out.csv", sep = ",", header = T)
names(geo)
str(geo)
summary(geo)

# mapa con riqueza

p = ggplot(geo, aes(x, y))
p + geom_point(aes(size = ACE, colour = ACE)) + theme_bw() + 
scale_size(name = "N?mero de especies", breaks = c(2, 4, 6, 8, 10, 12, 
14, 16, 18, 20)) + scale_colour_gradientn(name = 'N?mero de especies', 
colours = heat.colors(10), breaks = c(2, 4, 6, 8, 10, 12, 14, 16, 18, 
20))+ xlab("Longitud") + ylab("Latitud") + opts(axis.text.x = 
theme_text(size = 8, vjust = 1)) + opts(axis.text.y = theme_text(size = 
8, hjust = 1)) + geom_path(aes(x=long,y=lat,group=group, 
fill=id),data=fortify.ai_biotica)

Best,

Manuel
On 03/04/2011 01:41 p.m., Felipe Carrillo wrote: