convert Map shapes to logical matrices - for setoperations

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

convert Map shapes to logical matrices - for setoperations

Roger Bivand
On Tue, 7 Dec 2004, James Muller wrote:

> Hi, I have a little problem.  (and sorry for the cross-post of this)
> I'm trying to do the following:
>  Convert  _projected_ shapes from a Map object into logical matrices.
> That is, rasterize a shape into a logical "in-the-shape" and
> "out-of-the-shape" matrix.
> What I'm trying to do is get an 'equal-area' estimate of the area of
> intersection between two overlapping shapes, without any concern about
> there being holes in the shapes. I know owin can deal with most of this,
> but for sure it doesn't support geographic projections, which will allow
> the 'equal-area' estimate to be equal.
> An idea I had was to pipe the output of the maptools Map plotting
> function map into the matrix. But I really have no idea how to do that
> at this point in my R education.

Do you have Shapes from the Map object in lat-long or projected
coordinates? If they are in projected coordinates, you can generate a grid
with the standard function expand.grid() and then use a point-in-polygon
function, such as inside.owin() or similar, on each of the grid points. If
your shape polygons are in geographical coordinates, then consider
projecting them, see for open source
projection software. You would then be looking for grid points in A, and
among those, grid points in B, I think. I don't think I'd want to have to
generate equal area grid points in lat-long, though you could do that
using proj inversely.


> Any suggestions are extremely welcome.
> Cheers,
> James
> _______________________________________________
> R-sig-Geo mailing list
> R-sig-Geo at

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

Roger Bivand
Department of Economics
Norwegian School of Economics
Helleveien 30
N-5045 Bergen, Norway