Is there a way to zoom in a map on an R spatial polygons object.

i.e. if I have polygons for a whole country but I want to zoom in on a specific city and just plot that area how do I do that ?

At the moment I am just plotting a chloropleth of the whole country like this:

    colours<-(brewer.pal(9, "YlGn"))
    brks<-classIntervals(poly$var1, n=9, style="quantile")
    plot(ED, col=colours[findInterval(poly$var1, brks,all.inside=TRUE)], axes=F, border=FALSE)

I wanna zoom in and plot a rectangular area around a particular city but can't figure out how.


Use xlim and ylim args to plot:

require(spdep) # for sample data 
axis(1);axis(2) # see where we are

OR if you don't know the coords get them using locator:

xy=locator(2,"p") # click two corners

OR use zoom from the raster package:

zoom(columbus) # click corners
  • Thanks!I also had the idea to subset the map using a larger scale area code - but that would not be nice and rectangular so I look your solution better! – user2498193 Aug 25 '13 at 11:45

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.