# [R] Convert arc-second to degree

Ben Tupper btupper at bigelow.org
Wed Nov 30 00:09:31 CET 2016

```Hello,

I haven't downloaded the data, but a mock-up of your steps below does as you ask. You can see the resolution of y is 1 x 1 and each is filled with the sum of 120 x 120 original cells each of which had a value of 1.

In this case, the raster package faithfully interprets the fractional degree spatial units from the get-go.  So you needn't worry about the arc-second to degree issue.

Ben

P.S.  This question is about spatial data; your best results will be had by subscribing to and posting to the spatial mailing list for R.  https://stat.ethz.ch/mailman/listinfo/r-sig-geo

library(raster)
x <- raster(
nrows = 17400, ncols = 43200,
xmn = -180, xmx = 180, ymn = -60, ymx = 85,
crs = '+proj=longlat +datum=WGS84 +no_defs +ellps=WGS84 +towgs84=0,0,0')
x[] <- 1
x
class       : RasterLayer
dimensions  : 17400, 43200, 751680000  (nrow, ncol, ncell)
resolution  : 0.008333333, 0.008333333  (x, y)
extent      : -180, 180, -60, 85  (xmin, xmax, ymin, ymax)
coord. ref. : +proj=longlat +datum=WGS84 +no_defs +ellps=WGS84 +towgs84=0,0,0
data source : in memory
names       : layer
values      : 1, 1  (min, max)

y <- aggregate(x, fact = 120, fun = sum)
y
class       : RasterLayer
dimensions  : 145, 360, 52200  (nrow, ncol, ncell)
resolution  : 1, 1  (x, y)
extent      : -180, 180, -60, 85  (xmin, xmax, ymin, ymax)
coord. ref. : +proj=longlat +datum=WGS84 +no_defs +ellps=WGS84 +towgs84=0,0,0
data source : /private/var/folders/xx/nnm6q33102z059rfg4rh2y900000gn/T/RtmpgsByoE/raster/r_tmp_2016-11-29_180022_89972_05480.grd
names       : layer
values      : 14400, 14400  (min, max)

> On Nov 29, 2016, at 5:45 PM, Miluji Sb <milujisb at gmail.com> wrote:
>
> Dear all,
>
> I am using the Gridded Population of the World (v4) for the year 2010. The
> data is in GeoTiFF format.
>
> Source:
>
> I imported the data using:
>
> library(raster)
> library(maptools)
> library(ncdf4)
> library(rgdal)
>
> population <-
> population1 <- stack(population )
> extent(population1 ) <- c(-180, 180,-58,85)
>
> ### Information
> class       : RasterStack
> dimensions  : 17400, 43200, 751680000, 1  (nrow, ncol, ncell, nlayers)
> resolution  : 0.008333333, 0.008333333  (x, y)
> extent      : -180, 180, -60, 85  (xmin, xmax, ymin, ymax)
> coord. ref. : +proj=longlat +datum=WGS84 +no_defs +ellps=WGS84
> +towgs84=0,0,0
> names       :
> min values  :
>   0
> max values  :
> 141715.3
> ###
>
> I need to extract population by a set of coordinates which are at 1° x 1°,
> how can I convert from arc-second to degree in R? The information also
> shows that resolution is 0.008333333° x 0.008333333°, is it enough to do
> something like this?
>
> pop_agg <- aggregate(population1 , fact=120, fun=sum)
>
> Thank you very much.
>
> Sincerely,
>
> Milu
>
> 	[[alternative HTML version deleted]]
>
> ______________________________________________
> R-help at r-project.org mailing list -- To UNSUBSCRIBE and more, see
> https://stat.ethz.ch/mailman/listinfo/r-help
> and provide commented, minimal, self-contained, reproducible code.

Ben Tupper
Bigelow Laboratory for Ocean Sciences
60 Bigelow Drive, P.O. Box 380
East Boothbay, Maine 04544
http://www.bigelow.org

```