SpatialPolygonDataFrame plotting using ggplot
I am having a shape file for the greater London area. I use the
readShapePoly function from the maptools package to load it in R as a
SpatialPolygonDataFrame .
I want to the plot those polygons .. Which I have already done by using
the basic of plot function in R. The output looks as shown in this image:
Now, I am trying to plot the same shape file using ggplot2 but it doesn't
work with me. I am getting some weird lines in the graph as shown blew:
The code I used was :
london.wards <- readShapePoly("~/TD/london_wards2013/london_wards2013.shp"
, proj4string=CRS(projString))
wards.count <- nrow(london.wards@data)
# assign id for each lsoa
london.wards@data$id <- 1:wards.count
wards.fort <- fortify(london.wards, region='id')
ggplot(wards.fort, aes(long, lat)) + geom_polygon(colour='black',
fill='white')
where projString is the projection string describing the projection used
for the input shape file.
No comments:
Post a Comment