Extract coordinates from rasterbrick

classic Classic list List threaded Threaded
4 messages Options
Reply | Threaded
Open this post in threaded view
|

Extract coordinates from rasterbrick

Miluji Sb
Dear all,

I have the following rasterbrick (x);

class       : RasterBrick
dimensions  : 112, 272, 30464, 7305  (nrow, ncol, ncell, nlayers)
resolution  : 0.25, 0.25  (x, y)
extent      : -132, -64, 24, 52  (xmin, xmax, ymin, ymax)
coord. ref. : +proj=longlat +datum=WGS84 +ellps=WGS84 +towgs84=0,0,0
data source : /projectnb/climpct/TEX_1986_2005.nc
names       : X1986.01.01, X1986.01.02, X1986.01.03, X1986.01.04,
X1986.01.05, X1986.01.06, X1986.01.07, X1986.01.08, X1986.01.09,
X1986.01.10, X1986.01.11, X1986.01.12, X1986.01.13, X1986.01.14,
X1986.01.15, ...
Date        : 1986-01-01, 2005-12-31 (min, max)
varname     : tex


I can obtain the values by;

as.data.frame(getValues(x))

However, I would like to extract the values by all coordinates in the file
in the form of a dataframe. Is it possible to do so? Any help will be
greatly appreciated. Thank you.

Sincerely,

Milu

        [[alternative HTML version deleted]]

_______________________________________________
R-sig-Geo mailing list
[hidden email]
https://stat.ethz.ch/mailman/listinfo/r-sig-geo
Reply | Threaded
Open this post in threaded view
|

Re: Extract coordinates from rasterbrick

Bede-Fazekas Ákos
Dear Milu,

I think that you are looking for as.data.frame(x, xy = TRUE).

HTH,
Ákos Bede-Fazekas
Hungarian Academy of Sciences


2018.08.14. 17:03 keltezéssel, Miluji Sb írta:

> Dear all,
>
> I have the following rasterbrick (x);
>
> class       : RasterBrick
> dimensions  : 112, 272, 30464, 7305  (nrow, ncol, ncell, nlayers)
> resolution  : 0.25, 0.25  (x, y)
> extent      : -132, -64, 24, 52  (xmin, xmax, ymin, ymax)
> coord. ref. : +proj=longlat +datum=WGS84 +ellps=WGS84 +towgs84=0,0,0
> data source : /projectnb/climpct/TEX_1986_2005.nc
> names       : X1986.01.01, X1986.01.02, X1986.01.03, X1986.01.04,
> X1986.01.05, X1986.01.06, X1986.01.07, X1986.01.08, X1986.01.09,
> X1986.01.10, X1986.01.11, X1986.01.12, X1986.01.13, X1986.01.14,
> X1986.01.15, ...
> Date        : 1986-01-01, 2005-12-31 (min, max)
> varname     : tex
>
>
> I can obtain the values by;
>
> as.data.frame(getValues(x))
>
> However, I would like to extract the values by all coordinates in the file
> in the form of a dataframe. Is it possible to do so? Any help will be
> greatly appreciated. Thank you.
>
> Sincerely,
>
> Milu
>
> [[alternative HTML version deleted]]
>
> _______________________________________________
> R-sig-Geo mailing list
> [hidden email]
> https://stat.ethz.ch/mailman/listinfo/r-sig-geo
>

_______________________________________________
R-sig-Geo mailing list
[hidden email]
https://stat.ethz.ch/mailman/listinfo/r-sig-geo
Reply | Threaded
Open this post in threaded view
|

Re: Extract coordinates from rasterbrick

Vijay Lulla
And if you need coordinates as part of your data frame just do
cbind(coordinates(x), as.data.frame(x, xy = TRUE))

On Tue, Aug 14, 2018 at 11:50 AM Bede-Fazekas Ákos <[hidden email]>
wrote:

> Dear Milu,
>
> I think that you are looking for as.data.frame(x, xy = TRUE).
>
> HTH,
> Ákos Bede-Fazekas
> Hungarian Academy of Sciences
>
>
> 2018.08.14. 17:03 keltezéssel, Miluji Sb írta:
> > Dear all,
> >
> > I have the following rasterbrick (x);
> >
> > class       : RasterBrick
> > dimensions  : 112, 272, 30464, 7305  (nrow, ncol, ncell, nlayers)
> > resolution  : 0.25, 0.25  (x, y)
> > extent      : -132, -64, 24, 52  (xmin, xmax, ymin, ymax)
> > coord. ref. : +proj=longlat +datum=WGS84 +ellps=WGS84 +towgs84=0,0,0
> > data source : /projectnb/climpct/TEX_1986_2005.nc
> > names       : X1986.01.01, X1986.01.02, X1986.01.03, X1986.01.04,
> > X1986.01.05, X1986.01.06, X1986.01.07, X1986.01.08, X1986.01.09,
> > X1986.01.10, X1986.01.11, X1986.01.12, X1986.01.13, X1986.01.14,
> > X1986.01.15, ...
> > Date        : 1986-01-01, 2005-12-31 (min, max)
> > varname     : tex
> >
> >
> > I can obtain the values by;
> >
> > as.data.frame(getValues(x))
> >
> > However, I would like to extract the values by all coordinates in the
> file
> > in the form of a dataframe. Is it possible to do so? Any help will be
> > greatly appreciated. Thank you.
> >
> > Sincerely,
> >
> > Milu
> >
> >       [[alternative HTML version deleted]]
> >
> > _______________________________________________
> > R-sig-Geo mailing list
> > [hidden email]
> > https://stat.ethz.ch/mailman/listinfo/r-sig-geo
> >
>
> _______________________________________________
> R-sig-Geo mailing list
> [hidden email]
> https://stat.ethz.ch/mailman/listinfo/r-sig-geo
>

        [[alternative HTML version deleted]]

_______________________________________________
R-sig-Geo mailing list
[hidden email]
https://stat.ethz.ch/mailman/listinfo/r-sig-geo
Reply | Threaded
Open this post in threaded view
|

Re: Extract coordinates from rasterbrick

Miluji Sb
Dear Ákos and Vijay,

Thank you very much for the solutions. They work perfectly!

Sincerely,

Milu

On Tue, Aug 14, 2018 at 6:12 PM, Vijay Lulla <[hidden email]> wrote:

> And if you need coordinates as part of your data frame just do
> cbind(coordinates(x), as.data.frame(x, xy = TRUE))
>
> On Tue, Aug 14, 2018 at 11:50 AM Bede-Fazekas Ákos <[hidden email]>
> wrote:
>
> > Dear Milu,
> >
> > I think that you are looking for as.data.frame(x, xy = TRUE).
> >
> > HTH,
> > Ákos Bede-Fazekas
> > Hungarian Academy of Sciences
> >
> >
> > 2018.08.14. 17:03 keltezéssel, Miluji Sb írta:
> > > Dear all,
> > >
> > > I have the following rasterbrick (x);
> > >
> > > class       : RasterBrick
> > > dimensions  : 112, 272, 30464, 7305  (nrow, ncol, ncell, nlayers)
> > > resolution  : 0.25, 0.25  (x, y)
> > > extent      : -132, -64, 24, 52  (xmin, xmax, ymin, ymax)
> > > coord. ref. : +proj=longlat +datum=WGS84 +ellps=WGS84 +towgs84=0,0,0
> > > data source : /projectnb/climpct/TEX_1986_2005.nc
> > > names       : X1986.01.01, X1986.01.02, X1986.01.03, X1986.01.04,
> > > X1986.01.05, X1986.01.06, X1986.01.07, X1986.01.08, X1986.01.09,
> > > X1986.01.10, X1986.01.11, X1986.01.12, X1986.01.13, X1986.01.14,
> > > X1986.01.15, ...
> > > Date        : 1986-01-01, 2005-12-31 (min, max)
> > > varname     : tex
> > >
> > >
> > > I can obtain the values by;
> > >
> > > as.data.frame(getValues(x))
> > >
> > > However, I would like to extract the values by all coordinates in the
> > file
> > > in the form of a dataframe. Is it possible to do so? Any help will be
> > > greatly appreciated. Thank you.
> > >
> > > Sincerely,
> > >
> > > Milu
> > >
> > >       [[alternative HTML version deleted]]
> > >
> > > _______________________________________________
> > > R-sig-Geo mailing list
> > > [hidden email]
> > > https://stat.ethz.ch/mailman/listinfo/r-sig-geo
> > >
> >
> > _______________________________________________
> > R-sig-Geo mailing list
> > [hidden email]
> > https://stat.ethz.ch/mailman/listinfo/r-sig-geo
> >
>
>         [[alternative HTML version deleted]]
>
> _______________________________________________
> R-sig-Geo mailing list
> [hidden email]
> https://stat.ethz.ch/mailman/listinfo/r-sig-geo
>

        [[alternative HTML version deleted]]

_______________________________________________
R-sig-Geo mailing list
[hidden email]
https://stat.ethz.ch/mailman/listinfo/r-sig-geo