Skip to content

another question on shapefiles and geom_point in ggplot2

6 messages · Manuel Spínola, Felipe Carrillo, Pierre Roudier +1 more

#
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:

  
    
#
Hi all,

2011/4/4 Felipe Carrillo <mazatlanmexico at yahoo.com>:
On that specific point, Colin Arundel and Roger Bivant released the
rgeos package on CRAN a few days [1]. This is a great achievement as
it brings bindings to the GEOS C++ lib [2] - long story short, it
makes the job the non-free [3] gpclib used to do.

In its later release, maptools has an option to check if rgeos if
present - if it is the case it is used instead of gpclib:
Loading required package: foreign
Loading required package: sp
Loading required package: lattice

        Note: polygon geometry computations in maptools
        depend on the package gpclib, which has a
        restricted licence. It is disabled by default;
        to enable gpclib, type gpclibPermit()

Checking rgeos availability as gpclib substitute:
TRUE
Pierre

[1] http://cran.r-project.org/web/packages/rgeos/
[2] http://trac.osgeo.org/geos/
[3] https://stat.ethz.ch/pipermail/r-sig-geo/2010-January/007400.html