How to extract part of Map object using maptools

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
4 messages Options
Reply | Threaded
Open this post in threaded view
|

How to extract part of Map object using maptools

hi_ono2001
Hi.

 Rmap can extract parts of Map object as follows.

 columbus<- shapefile("columbus.shp") " load shapefile

 plot(columbus[columbus$CRIME > mean(columbus$CRIME)]) # filter by attribute
& plot

 But I don't know how to do this by maptools.

 Regards.



Reply | Threaded
Open this post in threaded view
|

How to extract part of Map object using maptools

Roger Bivand
Administrator
On Thu, 20 Nov 2003, Hisaji Ono wrote:

> Hi.
>
>  Rmap can extract parts of Map object as follows.

Rmap has a nice "proxy" view of the data file, which is not read in until
needed. So it implements subsetting during the read action (shapefile()
just checks that the file exists and can be opened by the declared
driver).

>
>  columbus<- shapefile("columbus.shp") " load shapefile
>
>  plot(columbus[columbus$CRIME > mean(columbus$CRIME)]) # filter by attribute
> & plot
>
>  But I don't know how to do this by maptools.
>

In maptools it could be implemented by writing a subset tool for either
Map or polylist objects, but just running subset() on a polylist will not
work directly, because the new list does not have the correct class. But
it isn't difficult, I'll add it to the next maptools release. How should
the bounding box be handled, should it be left as is, or reduced to suit
the subset?

Roger

>  Regards.
>
> _______________________________________________
> R-sig-Geo mailing list
> R-sig-Geo at stat.math.ethz.ch
> https://www.stat.math.ethz.ch/mailman/listinfo/r-sig-geo
>

--
Roger Bivand
Economic Geography Section, Department of Economics, Norwegian School of
Economics and Business Administration, Breiviksveien 40, N-5045 Bergen,
Norway. voice: +47 55 95 93 55; fax +47 55 95 93 93
e-mail: Roger.Bivand at nhh.no



Roger Bivand
Department of Economics
Norwegian School of Economics
Helleveien 30
N-5045 Bergen, Norway
Reply | Threaded
Open this post in threaded view
|

How to extract part of Map object using maptools

Edzer J. Pebesma
Roger Bivand wrote:

>How should
>the bounding box be handled, should it be left as is, or reduced to suit
>the subset?
>
This is (more or less) a question about interfacing. I'd suggest to modify
the bounding box such that it suits the subset. First I thought about a
way to expand it, as in

bbox(europe) <- bbox(world)

but the more I think about it, the less I like it: expanded bounding boxes
do not describe the data in the object, and probably are only of use to
extend the plotting area -- a trick. For that purpose we'd better pass a
bbox to generic plotting functions, as in

plot(europe, bbox=bbox(world))
--
Edzer



Reply | Threaded
Open this post in threaded view
|

How to extract part of Map object using maptools

Barry Rowlingson
Edzer J. Pebesma wrote:


> but the more I think about it, the less I like it: expanded bounding boxes
> do not describe the data in the object, and probably are only of use to
> extend the plotting area -- a trick. For that purpose we'd better pass a
> bbox to generic plotting functions, as in
>
> plot(europe, bbox=bbox(world))

   plot((1:10)[1:5]) doesn't give you a bounds from 1 to 10, so I dont
see why the bounds of a subsetted map should be those of the parent.

  A subset of a map object is a map in its own right, and if that means
recalculating its bounding box, then you better recalculate it!

Baz