[R-sig-Geo] Aggregate data to lower resolution

Miluji Sb milujisb at gmail.com
Fri Jul 22 10:08:33 CEST 2016


Dear Loic,

Thank you for your reply. When I run this code on the whole data set (that
has all the countries in the world) - I get mostly NAs. The attributes are:

class       : RasterLayer
dimensions  : 135, 359, 48465  (nrow, ncol, ncell)
resolution  : 1, 1  (x, y)
extent      : -178.5, 180.5, -55.5, 79.5  (xmin, xmax, ymin, ymax)
coord. ref. : NA
data source : in memory
names       : GDP
values      : 0, 750.533  (min, max)

Do I need to get rid of the NAs? Or is there something wrong? Thanks again.

Sincerely,

Milu

On Thu, Jul 21, 2016 at 11:28 PM, Loïc Dutrieux <loic.dutrieux at wur.nl>
wrote:

> Hi Milu,
>
> The code you provided works perfectly on my computer. What doesn't work in
> your case? Do you get an error message?
>
> Cheers,
> Loïc
>
>
> On 21/07/2016 22:57, Miluji Sb wrote:
>
>> Dear all,
>>
>> I have the following GDP data by latitude and longitude at 0.5 degree by
>> 0.5 degree.
>>
>> temp <- dput(head(ptsDF,10))
>> structure(list(longitude = c(-68.25, -67.75, -67.25, -68.25,
>> -67.75, -67.25, -71.25, -70.75, -69.25, -68.75), latitude = c(-54.75,
>> -54.75, -54.75, -54.25, -54.25, -54.25, -53.75, -53.75, -53.75,
>> -53.75), GDP = c(1.683046, 0.3212307, 0.0486207, 0.1223268, 0.0171909,
>> 0.0062104, 0.22379, 0.1406729, 0.0030038, 0.0057422)), .Names =
>> c("longitude",
>> "latitude", "GDP"), row.names = c(4L, 17L, 30L, 43L, 56L, 69L,
>> 82L, 95L, 108L, 121L), class = "data.frame")
>>
>> I would like to aggregate the data 1 degree by 1 degree. I understand that
>> the first step is to convert to raster. I have tried:
>>
>> rasterDF <- rasterFromXYZ(temp)
>> r <- aggregate(rasterDF,fact=2, fun=sum)
>>
>> But this does not seem to work. Could anyone help me out please? Thank you
>> in advance.
>>
>> Sincerely,
>>
>> Milu
>>
>>         [[alternative HTML version deleted]]
>>
>> _______________________________________________
>> R-sig-Geo mailing list
>> R-sig-Geo at r-project.org
>> https://stat.ethz.ch/mailman/listinfo/r-sig-geo
>>
>>
> _______________________________________________
> R-sig-Geo mailing list
> R-sig-Geo at r-project.org
> https://stat.ethz.ch/mailman/listinfo/r-sig-geo
>

	[[alternative HTML version deleted]]



More information about the R-sig-Geo mailing list