Skip to content

delete region from shapefile / map only certain regions

5 messages · stefan lhachimi, Rainer Hurling, Roger Bivand

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


Second, is it possible just to plot parts of the map, given some
condition (say, part of a state or a larger region)?

I hope these question are not too trivial, but I couldn't find
anything adequate in the mailing list.
Happy new Year,
Stefan
#
Hello Stefan,

answering only to your first question.
On 05.01.2008 22:38 (UTC+1), stefan lhachimi wrote:
I am not sure what you mean with 'lakes'. Is it possible, that this 
polygons describe the mini counties (~ cities with municipal laws like 
counties) 'Hamburg' and 'Bremen' both in the northern part of Germany? 
If so, I would suggest to not delete them.

Hope this helps,
Rainer
#
Thanks for your email. But according to official Germany kartography
standards (that is where I have the files from). The Bodensee is split
into to separate counties (and really just he Bodensee, not the part
of the Bodensee and part of a neighbouring landmass). For the
statistical analyis I have in mind (mortality), these observations do
not make sense and distort the analysis.
Best,
Stefan
On Jan 6, 2008 11:35 AM, Rainer Hurling <rhurlin at gwdg.de> wrote:
#
On Sat, 5 Jan 2008, stefan lhachimi wrote:

            
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.
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

  
    
4 days later
#
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: