[R-sig-Geo] delete region from shapefile / map only certain regions

stefan lhachimi stefan.duke at gmail.com
Fri Jan 11 16:30:25 CET 2008


Hi,
it worked perfectly!
Thanks a lot and sorry for the late response.
Best,
Stefan

On Jan 6, 2008 8:15 PM, Roger Bivand <Roger.Bivand at nhh.no> wrote:
> On Sat, 5 Jan 2008, stefan lhachimi wrote:
>
> > Hello,
> > I have two qeustions about shape files:
> >
> > First, I have a shp.file for all counties in Germany. Funnily enough,
> > two counties are just lakes for which
> >    I do not have covariates. Is there a possibilty delete them, so
> > they don't show on the map and do not affect my analysis.
>
> If you use readShapePoly() in maptools, they will be read into a
> SpatialPolygonsDataFrame object. You subset it using "[" as other data
> frame objects - see the examples in ?readShapePoly, and more class
> documentation in the sp package. Create a logical vector to do the
> subsetting.
>
> >
> >
> > Second, is it possible just to plot parts of the map, given some
> > condition (say, part of a state or a larger region)?
> >
>
> Either subset in the same way (counties in a land, for example), or use
> the xlim= and ylim= arguments to the plot() or spplot() methods for the
> class, depending on what you need. For plot(), you need to set the class
> intervals for colour filling yourself, for spplot() you can set up a
> legend and class intervals automatically.
>
> Hope this helps,
>
> Roger
>
> > I hope these question are not too trivial, but I couldn't find
> > anything adequate in the mailing list.
> > Happy new Year,
> > Stefan
> >
> > _______________________________________________
> > R-sig-Geo mailing list
> > R-sig-Geo at stat.math.ethz.ch
> > https://stat.ethz.ch/mailman/listinfo/r-sig-geo
> >
>
> --
> Roger Bivand
> Economic Geography Section, Department of Economics, Norwegian School of
> Economics and Business Administration, Helleveien 30, N-5045 Bergen,
> Norway. voice: +47 55 95 93 55; fax +47 55 95 95 43
> e-mail: Roger.Bivand at nhh.no
>
>




More information about the R-sig-Geo mailing list