[R] How to create gridded data

S Ellison S@Elli@on @ending from LGCGroup@com
Tue Nov 13 14:37:22 CET 2018


You might take a look at the reshape package, which switches from 'long' to 'wide' formats and vice versa in a fairly flexible way.

S Ellison

> -----Original Message-----
> From: R-help [mailto:r-help-bounces using r-project.org] On Behalf Of lily li
> Sent: 13 November 2018 07:22
> To: R mailing list
> Subject: [R] How to create gridded data
> 
> Hi R users,
> 
> I have a question about manipulating data. For example, I have DF1 as the
> following, how to transform it to a gridded dataset DF2? In DF2, each value
> Precip is an attribute of the corresponding grid cell. So DF2 is like a
> spatial surface, and can be imported to ArcGIS. Thanks for your help.
> 
> DF1
> latitude   longitude   Precip
> 45.5           110.5         3.2
> 45.5           111            5.0
> 45.5           111.5         1.8
> 45.5           112            2.0
> 46              110.5         6.1
> 46              111            4.5
> 46              111.5         7.8
> 46              112            5.5
> ...
> 
> 
> DF2
> 6.1   4.5   7.8   5.5
> 3.2   5.0   1.8   2.0
> ...
> 
> 	[[alternative HTML version deleted]]
> 
> ______________________________________________
> R-help using r-project.org mailing list -- To UNSUBSCRIBE and more, see
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide http://www.R-project.org/posting-
> guide.html
> and provide commented, minimal, self-contained, reproducible code.


*******************************************************************
This email and any attachments are confidential. Any use...{{dropped:8}}



More information about the R-help mailing list