[R-sig-Geo] One-to-many table relationship to shapefile polygon in spplot / plot - possible?

Barry Rowlingson b.rowlingson at lancaster.ac.uk
Wed Jan 6 10:23:02 CET 2010


On Wed, Jan 6, 2010 at 6:16 AM, Noli Sicad <nsicad at gmail.com> wrote:
> Hi,
>
> I have problem transposing my database table which is to be merged /
> joined with the shapefile file (*.dbf) inorder to have one-to-one
> relationship with shapefile polygon. As we know that inorder for the
> polygon to be rendered in GIS, it has to have one-to-ope relationship.

 Depends on your GIS! Shapefiles only have a 1-1 relationship, but
that's because they are a bit rubbish. If you use a proper spatial
database then you can do one-many. This is an application for a
PostGIS or Spatialite database, and if your GIS can read that (Qgis
for example) then you are sorted.

> One to many table:
>
> Poly_ID Period Age
> 01           1       32
> 01           2       34
> 02           1       30
> 03           2       21
>
>
> One to one table
>
> Poly_ID Period1 Period2 Period3
> 01            32           34
> 02             30
> 03                           21
> 04                                    35
>
> Now,  is it possible to use one-to-many table for mapping using spplot / plot?
>
> The result data I am trying to map using spplot has 1 to 70 years
> periods. I want to produce maps per period, for 10 years or more for
> forest management regimes in forest stand.

 I wouldn't reshape the data in R to create a possibly sparse matrix,
and then have to code in column names with expressions (e.g.
data[,paste("Year",y,sep="")], which I think is icky). I would just
create a spatial polygons/points data set with just an ID column, and
put your ID/Period/Age data in a non-spatial data frame. Then when you
want to plot a particular thing, just match up the data with the
spatial data and plot (using the 'match' function).

Barry



More information about the R-sig-Geo mailing list