[R-sig-Geo] Creating an attribute table from 3 different files

Roger Bivand Roger.Bivand at nhh.no
Wed Jul 22 15:03:35 CEST 2009


On Mon, 20 Jul 2009, Mehdi Khan wrote:

> I figured out the first problem by first coercing the attribute vector into
> a data frame and then using the spatialpointsdataframe command to merge it
> with the coordinate matrix.

If you haven't yet tried the overlay() methods in the sp package, you may 
find that they let you find the placings of different geometric 
representations when in sp classes.

Roger

>
> On Sun, Jul 19, 2009 at 7:59 PM, Mehdi Khan <mwkhan at ucdavis.edu> wrote:
>
>>
>> Greetings,
>>
>> I have a shape file, a tiff file, and an excel table.  Each of these files
>> is a different length, and contain a coordinate table (in UTM units) as well
>> as an attribute table along with other superfluous columns.  What I would
>> like to do is combine all three into one table so that I can compare the
>> attributes that each file has.  The caveat is that I need to match up the
>> attribute with the coordinates.  Naturally there will be empty values in
>> this table/matrix since the lengths are all different.  The attribute
>> columns from each table are either numbers or letters.
>>
>> For the shape file, I am able to isolate the coordinates thusly:
>>
>> calirobincoords <- coordinates(calirobin)
>>
>> and the soil type thusly:
>>
>> calirobindata <-as(calirobin, "data.frame")
>> soiltype<-calirobindata[ , 8]
>>
>> When I try to merge the two, i get an error: Error: cannot allocate vector
>> of size 297.6 Mb
>>
>> The coordinate matrix from the excel file and the attributes I am able to
>> easily extract (the matrix i have called ptsrobin)
>>
>> Now for the tif file, I am also able to successfully isolate the
>> coordinates and attribute table, no problem there..
>>
>> CRS11<- readGDAL("california1.tif")
>> proj4string(CRS11)
>>
>> tifdataframe<-as(CRS11,"data.frame")
>> coordinates(tifdataframe)<-c("x", "y")
>>
>> So the problem I face now is this:
>>
>> 1) How can I combine the coordinates within the shape file and the
>> attribute column?
>>
>> 2) How would I combine all three matrices into one once (1) is resolved, in
>> which the combination takes in to account placing values within the correct
>> coordinate row?
>>
>> Help is much appreciated, and due apologies for the lengthy email!  Thank
>> you all!
>>
>> Mehdi Khan
>>
>>
>>
>>
>>
>
> 	[[alternative HTML version deleted]]
>
> _______________________________________________
> 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