Dear list,

I was given a ESRI shape file from the South African government, so with
little knowledge of the underlaying metadata. The shape file represents the
subdivision of the entire Northern Cape district in commercial plots (farms)

What I have been trying to do is to plot the farm boundaries over an object
previously produced with ggmap(). It appears to me that those lines
(boundaries) that are not comletely within the extent defined by the
binding box are flipped back into the produced map and I have been
struggling to find a solution to this.

Any inputs to solve this problem are highly appreciated

The data, together with the plot of the farms, can be found here:
https://www.dropbox.com/home/geolist


### read in data

farm.district <- readOGR(“.", "Farm_boundaries")


### crop the entire district to the extent of GPS tagged animals

ext <- extent(c(21.72048 , 21.90001, -27.04536, -26.94074))    # extent of
the GPS tagged animals

farm <- crop(farm.district, ext+0.1)
       # add 0.1 degrees to the extent of the animals
class (farm)

plot(farm)         # returns the correct boundaries -> see “boundary.pdf”
in the dropbox


### plot over a ggmap object
library(ggmap)
library(mapproj)

ef<-bbox(extent(farm))

m <- get_map(ef, zoom=11, source="google", maptype="satellite”)

ggmap(m)+
geom_polygon(data=fortify(farm), aes(x=long, y=lat), colour="black",
fill="#00000000", lwd=0.2, linetype=1)



Best

-- 
Gabriele Cozzi
Postdoctoral Research Associate
Population Ecology Research Group
http://www.popecol.org

Zurich University
Institute of Evolutionary Biology and Environmental Studies
Winterthurerstr. 190
8057 Zurich - Switzerland
E-mail: gabriele.cozzi@uzh.ch
Phone: +41(0)44 635 49 12
Fax: +41(0)16355711
http://www.ieu.uzh.ch

	[[alternative HTML version deleted]]

