[R-sig-Geo] Large Data Sets

Roger Bivand Roger.Bivand at nhh.no
Tue Sep 4 14:27:09 CEST 2007


On Tue, 4 Sep 2007, Caroline Keef wrote:

> I am having trouble manipulating a large data set to change a spatial
> polygons data frame
>
> I have read in an ESRI polygon shapefile using rgdal and readOGR that
> contains 18804 polygons.  I am trying to add two variables into the
> spatial data frame but it's not working.  I'm doing this using
>
> cbind(SpatialPolygonsDataFrame,new variable,rank(new variable)).

If we call your SpatialPolygonsDataFrame "x", then why not do:

x$nv <- new_variable
x$rnv <- rank(new_variable)

cbind is an S3 generic function, but no methods are defined for the 
SpatialPolygonsDataFrame class.

You can use the spCbind() method in the maptools package, but first you 
need to put your new variables into a data frame, and make sure that the 
set of row names of the data frame in the data slot of the 
SpatialPolygonsDataFrame object and the new data frame agree. You can use 
spCbind on a single vector:

x1 <- spCbind(x, new_variable)

but

x$nv <- new_variable

seems easier.

cbind methods do exist for SpatialGridDataFrame objects, but are for 
cbind'ing two SpatialGridDataFrame objects together, rather than for 
arguments of arbitrary classes; it stops you if the GridTopologies are 
not identical.

Hope this helps,

Roger

>
> Before I killed R Task Manager said it was using more than 1,050,000K
> virtual memory, which given my whole computer ground to a halt I'm
> guessing is the limit!

The default cbind method had got completely lost in the input object.

>
> I regularly handle larger data frames than this using R without any
> problem so I don't think the problem is R in general.
>
> Does anyone have any suggestions as to either the size of the data set
> that it is possible to handle as a spatial data frame or a better way of
> combining spatial data frames?
>
> Thank you
>
> Caroline
>
> JBA Consulting - Engineers and Scientists
> South Barn, Broughton Hall, Skipton, North Yorkshire, BD23 3AE, UK
> t: +44 (0)1756 799919   f: +44 (0)1756 799449
>
> JBA is a Carbon Neutral Company.  Please don't print this e-mail unless you really need to.
> This email is covered by JBA Consulting's email disclaimer at www.jbaconsulting.co.uk/emaildisclaimer
>
> _______________________________________________
> 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