Re: [R-sig-Geo] Question on hierarchical data format 5 .h5 file format

2021-11-14 Thread Michael Sumner
see if gdal understands the coordinate arrays already, you can just churn
it through the warper, otherwise construct a vrt that specifies them, which
is a bit obscure how you do it admittedly - but this is a gdal not an R
topic.

Best



On Mon, 15 Nov 2021, 00:22 Edzer Pebesma, 
wrote:

>
> On 14/11/2021 13:59, Edzer Pebesma wrote:
> > Gabriel shared the data with me (off-list, 1Gb) and it contains two hdf5
> > datasets, one containing the raster of the longitude and latitude, the
> > other rasters with the attributres (LST) but no coordinates. I could get
> > a (rough: factor 50 downsampling) plot with stars using:
> >
> > library(stars)
> > lat =
> >
> read_stars("HDF5:ECOSTRESS_L1B_GEO_11712_012_20200730T061029_0601_01.h5://Geolocation/latitude")
>
> >
> > lon =
> >
> read_stars("HDF5:ECOSTRESS_L1B_GEO_11712_012_20200730T061029_0601_01.h5://Geolocation/longitude")
>
> >
> >
> > var =
> > "HDF5:ECOSTRESS_L2_LSTE_11712_012_20200730T061029_0601_01.h5://SDS/LST"
> > lst = read_stars(var, curvilinear = list(x = lon, y = lat))
> > plot(lst, downsample = 50, axes = TRUE, reset = FALSE)
> >
> > library(rnaturalearth)
> > ne = ne_countries(returnclass = "sf")
> > plot(st_geometry(ne), add = TRUE, border = 'yellow')
> > # california border seems to make sense
> >
> >
> > but I'm not sure how to make a regular raster (in some CRS) out of this
> > for exporting to GeoTIFF.
>
> This might be useful: https://github.com/r-spatial/stars/issues/386
> but converting to polygons will be incredibly slow and memory hungry.
>
>
> >
> > On 14/11/2021 11:00, Edzer Pebesma wrote:
> >> This might be because the grid is not regular but possibly
> >> curvilinear, having two raster layers with the lon & lat values for
> >> each pixel. Can you share a sample data set?
> >>
> >> On 14/11/2021 10:47, Gabriel Cotlier wrote:
> >>> Dear Michael,
> >>>
> >>> Following your advice I have tired :
> >>>
> >>> library(terra)
> >>> library(raster)
> >>> library(dplyr)
> >>>
> >>> r = terra::rast(file.choose())
> >>> plot(r$LST)
> >>> r_lst = r$LST
> >>> r_lst %>% raster()
> >>> plot(r_lst)
> >>>
> >>> Then I effectively get a raster layer format from the raster package
> >>> as I
> >>> wanted, but looking at the plot and the raster layer information--see
> >>> bellow-- the scene appears to need both latitude and longitude for
> >>> correct
> >>> geolocation, how can I do this procedure?
> >>>
>  r_lst %>% raster()
> >>> class  : RasterLayer
> >>> dimensions : 5632, 5400, 30412800  (nrow, ncol, ncell)
> >>> resolution : 1, 1  (x, y)
> >>> extent : 0, 5400, 0, 5632  (xmin, xmax, ymin, ymax)
> >>> crs: NA
> >>> source : LST
> >>> names  : LST
> >>> values : 0, 65535  (min, max)
> >>>
> >>> The extent and the resolution are not the correct ones.
> >>> Maybe in the same .h5  is all the data for georeferencing it although I
> >>> could not see how to get to it and apply it to the layer.
> >>> There is also another file with complementary data related to
> >>> geolocation
> >>> but how can I query it, and get the data for geolocation and apply it
> to
> >>> the raster layer?.
> >>> The objective is to save it as a GeoTIFF file to be opened in QGIS with
> >>> correct geolocation.
> >>>
> >>> What do you suggest for converting the .h5 file to a georeferenced
> >>> Raster
> >>> Layer in GeoTIFF format ?
> >>>
> >>> Thanks a lot.
> >>> Kind regards,
> >>> Gabriel
> >>>
> >>> On Sat, Nov 13, 2021 at 12:22 PM Gabriel Cotlier 
> >>> wrote:
> >>>
>  Dear Michael Summer,
>  Thanks a lot for your swift reply.
>  I will give a try to the procedure you mentioned.
>  Kind regards,
>  Gabriel
> 
> 
>  On Sat, Nov 13, 2021 at 12:14 PM Michael Sumner 
>  wrote:
> 
> > try terra::rast() or stars::read_stars() on the file, both use gdal
> to
> > interrogate and read. What you get depends on the structure of the
> > files,
> > variables interpreted as subdatasets. stars is more general but sees
> > variables as 2D arrays with bands, terra calls these bands layers.
> >
> > Alternatively try raster::raster() or RNetCDF or tidync which might
> be
> > more straightforward than rhdf5 but all are quite different to each
> > other
> > and to the gdal view.
> >
> > hth
> >
> > On Sat, 13 Nov 2021, 18:56 Gabriel Cotlier, 
> > wrote:
> >
> >> Hello,
> >>
> >> I would like to be able to visualize / plot a specific data layer
> >> within
> >> the structure a hierarchical data file format .h5  in R. I could
> >> observe
> >> the structure as follows :
> >>
> >> library(rhdf5)
> >> r= h5ls(file.choose())
> >> r
> >>
> >> and also in this way identify the Group and Name of the data to be
> >> plotted,
> >> however I've tried I could not access the data itself, nor plot it
> >> as a
> >> raster layer with its corresponding geographic coordinates.
> >> I would like to be able to s

Re: [R-sig-Geo] Question on hierarchical data format 5 .h5 file format

2021-11-14 Thread Edzer Pebesma



On 14/11/2021 13:59, Edzer Pebesma wrote:
Gabriel shared the data with me (off-list, 1Gb) and it contains two hdf5 
datasets, one containing the raster of the longitude and latitude, the 
other rasters with the attributres (LST) but no coordinates. I could get 
a (rough: factor 50 downsampling) plot with stars using:


library(stars)
lat = 
read_stars("HDF5:ECOSTRESS_L1B_GEO_11712_012_20200730T061029_0601_01.h5://Geolocation/latitude") 

lon = 
read_stars("HDF5:ECOSTRESS_L1B_GEO_11712_012_20200730T061029_0601_01.h5://Geolocation/longitude") 



var = 
"HDF5:ECOSTRESS_L2_LSTE_11712_012_20200730T061029_0601_01.h5://SDS/LST"

lst = read_stars(var, curvilinear = list(x = lon, y = lat))
plot(lst, downsample = 50, axes = TRUE, reset = FALSE)

library(rnaturalearth)
ne = ne_countries(returnclass = "sf")
plot(st_geometry(ne), add = TRUE, border = 'yellow')
# california border seems to make sense


but I'm not sure how to make a regular raster (in some CRS) out of this 
for exporting to GeoTIFF.


This might be useful: https://github.com/r-spatial/stars/issues/386
but converting to polygons will be incredibly slow and memory hungry.




On 14/11/2021 11:00, Edzer Pebesma wrote:
This might be because the grid is not regular but possibly 
curvilinear, having two raster layers with the lon & lat values for 
each pixel. Can you share a sample data set?


On 14/11/2021 10:47, Gabriel Cotlier wrote:

Dear Michael,

Following your advice I have tired :

library(terra)
library(raster)
library(dplyr)

r = terra::rast(file.choose())
plot(r$LST)
r_lst = r$LST
r_lst %>% raster()
plot(r_lst)

Then I effectively get a raster layer format from the raster package 
as I

wanted, but looking at the plot and the raster layer information--see
bellow-- the scene appears to need both latitude and longitude for 
correct

geolocation, how can I do this procedure?


r_lst %>% raster()

class  : RasterLayer
dimensions : 5632, 5400, 30412800  (nrow, ncol, ncell)
resolution : 1, 1  (x, y)
extent : 0, 5400, 0, 5632  (xmin, xmax, ymin, ymax)
crs    : NA
source : LST
names  : LST
values : 0, 65535  (min, max)

The extent and the resolution are not the correct ones.
Maybe in the same .h5  is all the data for georeferencing it although I
could not see how to get to it and apply it to the layer.
There is also another file with complementary data related to 
geolocation

but how can I query it, and get the data for geolocation and apply it to
the raster layer?.
The objective is to save it as a GeoTIFF file to be opened in QGIS with
correct geolocation.

What do you suggest for converting the .h5 file to a georeferenced 
Raster

Layer in GeoTIFF format ?

Thanks a lot.
Kind regards,
Gabriel

On Sat, Nov 13, 2021 at 12:22 PM Gabriel Cotlier 
wrote:


Dear Michael Summer,
Thanks a lot for your swift reply.
I will give a try to the procedure you mentioned.
Kind regards,
Gabriel


On Sat, Nov 13, 2021 at 12:14 PM Michael Sumner 
wrote:


try terra::rast() or stars::read_stars() on the file, both use gdal to
interrogate and read. What you get depends on the structure of the 
files,

variables interpreted as subdatasets. stars is more general but sees
variables as 2D arrays with bands, terra calls these bands layers.

Alternatively try raster::raster() or RNetCDF or tidync which might be
more straightforward than rhdf5 but all are quite different to each 
other

and to the gdal view.

hth

On Sat, 13 Nov 2021, 18:56 Gabriel Cotlier,  
wrote:



Hello,

I would like to be able to visualize / plot a specific data layer 
within
the structure a hierarchical data file format .h5  in R. I could 
observe

the structure as follows :

library(rhdf5)
r= h5ls(file.choose())
r

and also in this way identify the Group and Name of the data to be
plotted,
however I've tried I could not access the data itself, nor plot it 
as a

raster layer with its corresponding geographic coordinates.
I would like to be able to select such data, plot it as a raster 
layer

and
if possible save it as GeoTIFF file format to be further processed 
with

the
raster package as a common raster layer.

If any small guidance example, reprex, of this procedure is possible
it would be appreciated.

Thanks a lot in advance
Kind regards,
Gabriel Cotlier
--
Gabriel Cotlier, PhD
Haifa Research Center for Theoretical Physics and Astrophysics 
(HCTPA)

University of Haifa
Israel

 [[alternative HTML version deleted]]

___
R-sig-Geo mailing list
R-sig-Geo@r-project.org
https://stat.ethz.ch/mailman/listinfo/r-sig-geo





[[alternative HTML version deleted]]

___
R-sig-Geo mailing list
R-sig-Geo@r-project.org
https://stat.ethz.ch/mailman/listinfo/r-sig-geo







--
Edzer Pebesma
Institute for Geoinformatics
Heisenbergstrasse 2, 48151 Muenster, Germany
Phone: +49 251 8333081

___
R-sig-Geo mailing list
R-sig-Geo@r-project.org
https://st

Re: [R-sig-Geo] Question on hierarchical data format 5 .h5 file format

2021-11-14 Thread Gabriel Cotlier
Hello Edzer,
Thanks a lot.
The scaling factor to convert to LST is 0.02
Regards,
Gabriel

On Sun, Nov 14, 2021 at 2:59 PM Edzer Pebesma 
wrote:

> Gabriel shared the data with me (off-list, 1Gb) and it contains two hdf5
> datasets, one containing the raster of the longitude and latitude, the
> other rasters with the attributres (LST) but no coordinates. I could get
> a (rough: factor 50 downsampling) plot with stars using:
>
> library(stars)
>
> lat =
>
> read_stars("HDF5:ECOSTRESS_L1B_GEO_11712_012_20200730T061029_0601_01.h5://Geolocation/latitude")
> lon =
>
> read_stars("HDF5:ECOSTRESS_L1B_GEO_11712_012_20200730T061029_0601_01.h5://Geolocation/longitude")
>
> var =
> "HDF5:ECOSTRESS_L2_LSTE_11712_012_20200730T061029_0601_01.h5://SDS/LST"
>
> lst = read_stars(var, curvilinear = list(x = lon, y = lat))
>
> plot(lst, downsample = 50, axes = TRUE, reset = FALSE)
>
> library(rnaturalearth)
> ne = ne_countries(returnclass = "sf")
>
> plot(st_geometry(ne), add = TRUE, border = 'yellow')
> # california border seems to make sense
>
>
> but I'm not sure how to make a regular raster (in some CRS) out of this
> for exporting to GeoTIFF.
>
> On 14/11/2021 11:00, Edzer Pebesma wrote:
> > This might be because the grid is not regular but possibly curvilinear,
> > having two raster layers with the lon & lat values for each pixel. Can
> > you share a sample data set?
> >
> > On 14/11/2021 10:47, Gabriel Cotlier wrote:
> >> Dear Michael,
> >>
> >> Following your advice I have tired :
> >>
> >> library(terra)
> >> library(raster)
> >> library(dplyr)
> >>
> >> r = terra::rast(file.choose())
> >> plot(r$LST)
> >> r_lst = r$LST
> >> r_lst %>% raster()
> >> plot(r_lst)
> >>
> >> Then I effectively get a raster layer format from the raster package as
> I
> >> wanted, but looking at the plot and the raster layer information--see
> >> bellow-- the scene appears to need both latitude and longitude for
> >> correct
> >> geolocation, how can I do this procedure?
> >>
> >>> r_lst %>% raster()
> >> class  : RasterLayer
> >> dimensions : 5632, 5400, 30412800  (nrow, ncol, ncell)
> >> resolution : 1, 1  (x, y)
> >> extent : 0, 5400, 0, 5632  (xmin, xmax, ymin, ymax)
> >> crs: NA
> >> source : LST
> >> names  : LST
> >> values : 0, 65535  (min, max)
> >>
> >> The extent and the resolution are not the correct ones.
> >> Maybe in the same .h5  is all the data for georeferencing it although I
> >> could not see how to get to it and apply it to the layer.
> >> There is also another file with complementary data related to
> geolocation
> >> but how can I query it, and get the data for geolocation and apply it to
> >> the raster layer?.
> >> The objective is to save it as a GeoTIFF file to be opened in QGIS with
> >> correct geolocation.
> >>
> >> What do you suggest for converting the .h5 file to a georeferenced
> Raster
> >> Layer in GeoTIFF format ?
> >>
> >> Thanks a lot.
> >> Kind regards,
> >> Gabriel
> >>
> >> On Sat, Nov 13, 2021 at 12:22 PM Gabriel Cotlier 
> >> wrote:
> >>
> >>> Dear Michael Summer,
> >>> Thanks a lot for your swift reply.
> >>> I will give a try to the procedure you mentioned.
> >>> Kind regards,
> >>> Gabriel
> >>>
> >>>
> >>> On Sat, Nov 13, 2021 at 12:14 PM Michael Sumner 
> >>> wrote:
> >>>
>  try terra::rast() or stars::read_stars() on the file, both use gdal to
>  interrogate and read. What you get depends on the structure of the
>  files,
>  variables interpreted as subdatasets. stars is more general but sees
>  variables as 2D arrays with bands, terra calls these bands layers.
> 
>  Alternatively try raster::raster() or RNetCDF or tidync which might be
>  more straightforward than rhdf5 but all are quite different to each
>  other
>  and to the gdal view.
> 
>  hth
> 
>  On Sat, 13 Nov 2021, 18:56 Gabriel Cotlier, 
>  wrote:
> 
> > Hello,
> >
> > I would like to be able to visualize / plot a specific data layer
> > within
> > the structure a hierarchical data file format .h5  in R. I could
> > observe
> > the structure as follows :
> >
> > library(rhdf5)
> > r= h5ls(file.choose())
> > r
> >
> > and also in this way identify the Group and Name of the data to be
> > plotted,
> > however I've tried I could not access the data itself, nor plot it
> > as a
> > raster layer with its corresponding geographic coordinates.
> > I would like to be able to select such data, plot it as a raster
> layer
> > and
> > if possible save it as GeoTIFF file format to be further processed
> > with
> > the
> > raster package as a common raster layer.
> >
> > If any small guidance example, reprex, of this procedure is possible
> > it would be appreciated.
> >
> > Thanks a lot in advance
> > Kind regards,
> > Gabriel Cotlier
> > --
> > Gabriel Cotlier, PhD
> > Haifa Research Center for Theoretical Physics and As

Re: [R-sig-Geo] Question on hierarchical data format 5 .h5 file format

2021-11-14 Thread Edzer Pebesma
Gabriel shared the data with me (off-list, 1Gb) and it contains two hdf5 
datasets, one containing the raster of the longitude and latitude, the 
other rasters with the attributres (LST) but no coordinates. I could get 
a (rough: factor 50 downsampling) plot with stars using:


library(stars) 

lat = 
read_stars("HDF5:ECOSTRESS_L1B_GEO_11712_012_20200730T061029_0601_01.h5://Geolocation/latitude")
lon = 
read_stars("HDF5:ECOSTRESS_L1B_GEO_11712_012_20200730T061029_0601_01.h5://Geolocation/longitude")


var = 
"HDF5:ECOSTRESS_L2_LSTE_11712_012_20200730T061029_0601_01.h5://SDS/LST" 

lst = read_stars(var, curvilinear = list(x = lon, y = lat)) 


plot(lst, downsample = 50, axes = TRUE, reset = FALSE)

library(rnaturalearth)
ne = ne_countries(returnclass = "sf") 


plot(st_geometry(ne), add = TRUE, border = 'yellow')
# california border seems to make sense


but I'm not sure how to make a regular raster (in some CRS) out of this 
for exporting to GeoTIFF.


On 14/11/2021 11:00, Edzer Pebesma wrote:
This might be because the grid is not regular but possibly curvilinear, 
having two raster layers with the lon & lat values for each pixel. Can 
you share a sample data set?


On 14/11/2021 10:47, Gabriel Cotlier wrote:

Dear Michael,

Following your advice I have tired :

library(terra)
library(raster)
library(dplyr)

r = terra::rast(file.choose())
plot(r$LST)
r_lst = r$LST
r_lst %>% raster()
plot(r_lst)

Then I effectively get a raster layer format from the raster package as I
wanted, but looking at the plot and the raster layer information--see
bellow-- the scene appears to need both latitude and longitude for 
correct

geolocation, how can I do this procedure?


r_lst %>% raster()

class  : RasterLayer
dimensions : 5632, 5400, 30412800  (nrow, ncol, ncell)
resolution : 1, 1  (x, y)
extent : 0, 5400, 0, 5632  (xmin, xmax, ymin, ymax)
crs    : NA
source : LST
names  : LST
values : 0, 65535  (min, max)

The extent and the resolution are not the correct ones.
Maybe in the same .h5  is all the data for georeferencing it although I
could not see how to get to it and apply it to the layer.
There is also another file with complementary data related to geolocation
but how can I query it, and get the data for geolocation and apply it to
the raster layer?.
The objective is to save it as a GeoTIFF file to be opened in QGIS with
correct geolocation.

What do you suggest for converting the .h5 file to a georeferenced Raster
Layer in GeoTIFF format ?

Thanks a lot.
Kind regards,
Gabriel

On Sat, Nov 13, 2021 at 12:22 PM Gabriel Cotlier 
wrote:


Dear Michael Summer,
Thanks a lot for your swift reply.
I will give a try to the procedure you mentioned.
Kind regards,
Gabriel


On Sat, Nov 13, 2021 at 12:14 PM Michael Sumner 
wrote:


try terra::rast() or stars::read_stars() on the file, both use gdal to
interrogate and read. What you get depends on the structure of the 
files,

variables interpreted as subdatasets. stars is more general but sees
variables as 2D arrays with bands, terra calls these bands layers.

Alternatively try raster::raster() or RNetCDF or tidync which might be
more straightforward than rhdf5 but all are quite different to each 
other

and to the gdal view.

hth

On Sat, 13 Nov 2021, 18:56 Gabriel Cotlier,  
wrote:



Hello,

I would like to be able to visualize / plot a specific data layer 
within
the structure a hierarchical data file format .h5  in R. I could 
observe

the structure as follows :

library(rhdf5)
r= h5ls(file.choose())
r

and also in this way identify the Group and Name of the data to be
plotted,
however I've tried I could not access the data itself, nor plot it 
as a

raster layer with its corresponding geographic coordinates.
I would like to be able to select such data, plot it as a raster layer
and
if possible save it as GeoTIFF file format to be further processed 
with

the
raster package as a common raster layer.

If any small guidance example, reprex, of this procedure is possible
it would be appreciated.

Thanks a lot in advance
Kind regards,
Gabriel Cotlier
--
Gabriel Cotlier, PhD
Haifa Research Center for Theoretical Physics and Astrophysics (HCTPA)
University of Haifa
Israel

 [[alternative HTML version deleted]]

___
R-sig-Geo mailing list
R-sig-Geo@r-project.org
https://stat.ethz.ch/mailman/listinfo/r-sig-geo





[[alternative HTML version deleted]]

___
R-sig-Geo mailing list
R-sig-Geo@r-project.org
https://stat.ethz.ch/mailman/listinfo/r-sig-geo





--
Edzer Pebesma
Institute for Geoinformatics
Heisenbergstrasse 2, 48151 Muenster, Germany
Phone: +49 251 8333081

___
R-sig-Geo mailing list
R-sig-Geo@r-project.org
https://stat.ethz.ch/mailman/listinfo/r-sig-geo


Re: [R-sig-Geo] Question on hierarchical data format 5 .h5 file format

2021-11-14 Thread Edzer Pebesma
This might be because the grid is not regular but possibly curvilinear, 
having two raster layers with the lon & lat values for each pixel. Can 
you share a sample data set?


On 14/11/2021 10:47, Gabriel Cotlier wrote:

Dear Michael,

Following your advice I have tired :

library(terra)
library(raster)
library(dplyr)

r = terra::rast(file.choose())
plot(r$LST)
r_lst = r$LST
r_lst %>% raster()
plot(r_lst)

Then I effectively get a raster layer format from the raster package as I
wanted, but looking at the plot and the raster layer information--see
bellow-- the scene appears to need both latitude and longitude for correct
geolocation, how can I do this procedure?


r_lst %>% raster()

class  : RasterLayer
dimensions : 5632, 5400, 30412800  (nrow, ncol, ncell)
resolution : 1, 1  (x, y)
extent : 0, 5400, 0, 5632  (xmin, xmax, ymin, ymax)
crs: NA
source : LST
names  : LST
values : 0, 65535  (min, max)

The extent and the resolution are not the correct ones.
Maybe in the same .h5  is all the data for georeferencing it although I
could not see how to get to it and apply it to the layer.
There is also another file with complementary data related to geolocation
but how can I query it, and get the data for geolocation and apply it to
the raster layer?.
The objective is to save it as a GeoTIFF file to be opened in QGIS with
correct geolocation.

What do you suggest for converting the .h5 file to a georeferenced Raster
Layer in GeoTIFF format ?

Thanks a lot.
Kind regards,
Gabriel

On Sat, Nov 13, 2021 at 12:22 PM Gabriel Cotlier 
wrote:


Dear Michael Summer,
Thanks a lot for your swift reply.
I will give a try to the procedure you mentioned.
Kind regards,
Gabriel


On Sat, Nov 13, 2021 at 12:14 PM Michael Sumner 
wrote:


try terra::rast() or stars::read_stars() on the file, both use gdal to
interrogate and read. What you get depends on the structure of the files,
variables interpreted as subdatasets. stars is more general but sees
variables as 2D arrays with bands, terra calls these bands layers.

Alternatively try raster::raster() or RNetCDF or tidync which might be
more straightforward than rhdf5 but all are quite different to each other
and to the gdal view.

hth

On Sat, 13 Nov 2021, 18:56 Gabriel Cotlier,  wrote:


Hello,

I would like to be able to visualize / plot a specific data layer within
the structure a hierarchical data file format .h5  in R. I could observe
the structure as follows :

library(rhdf5)
r= h5ls(file.choose())
r

and also in this way identify the Group and Name of the data to be
plotted,
however I've tried I could not access the data itself, nor plot it as a
raster layer with its corresponding geographic coordinates.
I would like to be able to select such data, plot it as a raster layer
and
if possible save it as GeoTIFF file format to be further processed with
the
raster package as a common raster layer.

If any small guidance example, reprex, of this procedure is possible
it would be appreciated.

Thanks a lot in advance
Kind regards,
Gabriel Cotlier
--
Gabriel Cotlier, PhD
Haifa Research Center for Theoretical Physics and Astrophysics (HCTPA)
University of Haifa
Israel

 [[alternative HTML version deleted]]

___
R-sig-Geo mailing list
R-sig-Geo@r-project.org
https://stat.ethz.ch/mailman/listinfo/r-sig-geo





[[alternative HTML version deleted]]

___
R-sig-Geo mailing list
R-sig-Geo@r-project.org
https://stat.ethz.ch/mailman/listinfo/r-sig-geo



--
Edzer Pebesma
Institute for Geoinformatics
Heisenbergstrasse 2, 48151 Muenster, Germany
Phone: +49 251 8333081

___
R-sig-Geo mailing list
R-sig-Geo@r-project.org
https://stat.ethz.ch/mailman/listinfo/r-sig-geo


Re: [R-sig-Geo] Question on hierarchical data format 5 .h5 file format

2021-11-14 Thread Gabriel Cotlier
Dear Michael,

Following your advice I have tired :

library(terra)
library(raster)
library(dplyr)

r = terra::rast(file.choose())
plot(r$LST)
r_lst = r$LST
r_lst %>% raster()
plot(r_lst)

Then I effectively get a raster layer format from the raster package as I
wanted, but looking at the plot and the raster layer information--see
bellow-- the scene appears to need both latitude and longitude for correct
geolocation, how can I do this procedure?

> r_lst %>% raster()
class  : RasterLayer
dimensions : 5632, 5400, 30412800  (nrow, ncol, ncell)
resolution : 1, 1  (x, y)
extent : 0, 5400, 0, 5632  (xmin, xmax, ymin, ymax)
crs: NA
source : LST
names  : LST
values : 0, 65535  (min, max)

The extent and the resolution are not the correct ones.
Maybe in the same .h5  is all the data for georeferencing it although I
could not see how to get to it and apply it to the layer.
There is also another file with complementary data related to geolocation
but how can I query it, and get the data for geolocation and apply it to
the raster layer?.
The objective is to save it as a GeoTIFF file to be opened in QGIS with
correct geolocation.

What do you suggest for converting the .h5 file to a georeferenced Raster
Layer in GeoTIFF format ?

Thanks a lot.
Kind regards,
Gabriel

On Sat, Nov 13, 2021 at 12:22 PM Gabriel Cotlier 
wrote:

> Dear Michael Summer,
> Thanks a lot for your swift reply.
> I will give a try to the procedure you mentioned.
> Kind regards,
> Gabriel
>
>
> On Sat, Nov 13, 2021 at 12:14 PM Michael Sumner 
> wrote:
>
>> try terra::rast() or stars::read_stars() on the file, both use gdal to
>> interrogate and read. What you get depends on the structure of the files,
>> variables interpreted as subdatasets. stars is more general but sees
>> variables as 2D arrays with bands, terra calls these bands layers.
>>
>> Alternatively try raster::raster() or RNetCDF or tidync which might be
>> more straightforward than rhdf5 but all are quite different to each other
>> and to the gdal view.
>>
>> hth
>>
>> On Sat, 13 Nov 2021, 18:56 Gabriel Cotlier,  wrote:
>>
>>> Hello,
>>>
>>> I would like to be able to visualize / plot a specific data layer within
>>> the structure a hierarchical data file format .h5  in R. I could observe
>>> the structure as follows :
>>>
>>> library(rhdf5)
>>> r= h5ls(file.choose())
>>> r
>>>
>>> and also in this way identify the Group and Name of the data to be
>>> plotted,
>>> however I've tried I could not access the data itself, nor plot it as a
>>> raster layer with its corresponding geographic coordinates.
>>> I would like to be able to select such data, plot it as a raster layer
>>> and
>>> if possible save it as GeoTIFF file format to be further processed with
>>> the
>>> raster package as a common raster layer.
>>>
>>> If any small guidance example, reprex, of this procedure is possible
>>> it would be appreciated.
>>>
>>> Thanks a lot in advance
>>> Kind regards,
>>> Gabriel Cotlier
>>> --
>>> Gabriel Cotlier, PhD
>>> Haifa Research Center for Theoretical Physics and Astrophysics (HCTPA)
>>> University of Haifa
>>> Israel
>>>
>>> [[alternative HTML version deleted]]
>>>
>>> ___
>>> R-sig-Geo mailing list
>>> R-sig-Geo@r-project.org
>>> https://stat.ethz.ch/mailman/listinfo/r-sig-geo
>>>
>>

[[alternative HTML version deleted]]

___
R-sig-Geo mailing list
R-sig-Geo@r-project.org
https://stat.ethz.ch/mailman/listinfo/r-sig-geo


Re: [R-sig-Geo] Question on hierarchical data format 5 .h5 file format

2021-11-13 Thread Gabriel Cotlier
Dear Michael Summer,
Thanks a lot for your swift reply.
I will give a try to the procedure you mentioned.
Kind regards,
Gabriel


On Sat, Nov 13, 2021 at 12:14 PM Michael Sumner  wrote:

> try terra::rast() or stars::read_stars() on the file, both use gdal to
> interrogate and read. What you get depends on the structure of the files,
> variables interpreted as subdatasets. stars is more general but sees
> variables as 2D arrays with bands, terra calls these bands layers.
>
> Alternatively try raster::raster() or RNetCDF or tidync which might be
> more straightforward than rhdf5 but all are quite different to each other
> and to the gdal view.
>
> hth
>
> On Sat, 13 Nov 2021, 18:56 Gabriel Cotlier,  wrote:
>
>> Hello,
>>
>> I would like to be able to visualize / plot a specific data layer within
>> the structure a hierarchical data file format .h5  in R. I could observe
>> the structure as follows :
>>
>> library(rhdf5)
>> r= h5ls(file.choose())
>> r
>>
>> and also in this way identify the Group and Name of the data to be
>> plotted,
>> however I've tried I could not access the data itself, nor plot it as a
>> raster layer with its corresponding geographic coordinates.
>> I would like to be able to select such data, plot it as a raster layer and
>> if possible save it as GeoTIFF file format to be further processed with
>> the
>> raster package as a common raster layer.
>>
>> If any small guidance example, reprex, of this procedure is possible
>> it would be appreciated.
>>
>> Thanks a lot in advance
>> Kind regards,
>> Gabriel Cotlier
>> --
>> Gabriel Cotlier, PhD
>> Haifa Research Center for Theoretical Physics and Astrophysics (HCTPA)
>> University of Haifa
>> Israel
>>
>> [[alternative HTML version deleted]]
>>
>> ___
>> R-sig-Geo mailing list
>> R-sig-Geo@r-project.org
>> https://stat.ethz.ch/mailman/listinfo/r-sig-geo
>>
>

[[alternative HTML version deleted]]

___
R-sig-Geo mailing list
R-sig-Geo@r-project.org
https://stat.ethz.ch/mailman/listinfo/r-sig-geo


Re: [R-sig-Geo] Question on hierarchical data format 5 .h5 file format

2021-11-13 Thread Michael Sumner
try terra::rast() or stars::read_stars() on the file, both use gdal to
interrogate and read. What you get depends on the structure of the files,
variables interpreted as subdatasets. stars is more general but sees
variables as 2D arrays with bands, terra calls these bands layers.

Alternatively try raster::raster() or RNetCDF or tidync which might be more
straightforward than rhdf5 but all are quite different to each other and to
the gdal view.

hth

On Sat, 13 Nov 2021, 18:56 Gabriel Cotlier,  wrote:

> Hello,
>
> I would like to be able to visualize / plot a specific data layer within
> the structure a hierarchical data file format .h5  in R. I could observe
> the structure as follows :
>
> library(rhdf5)
> r= h5ls(file.choose())
> r
>
> and also in this way identify the Group and Name of the data to be plotted,
> however I've tried I could not access the data itself, nor plot it as a
> raster layer with its corresponding geographic coordinates.
> I would like to be able to select such data, plot it as a raster layer and
> if possible save it as GeoTIFF file format to be further processed with the
> raster package as a common raster layer.
>
> If any small guidance example, reprex, of this procedure is possible
> it would be appreciated.
>
> Thanks a lot in advance
> Kind regards,
> Gabriel Cotlier
> --
> Gabriel Cotlier, PhD
> Haifa Research Center for Theoretical Physics and Astrophysics (HCTPA)
> University of Haifa
> Israel
>
> [[alternative HTML version deleted]]
>
> ___
> R-sig-Geo mailing list
> R-sig-Geo@r-project.org
> https://stat.ethz.ch/mailman/listinfo/r-sig-geo
>

[[alternative HTML version deleted]]

___
R-sig-Geo mailing list
R-sig-Geo@r-project.org
https://stat.ethz.ch/mailman/listinfo/r-sig-geo


[R-sig-Geo] Question on hierarchical data format 5 .h5 file format

2021-11-12 Thread Gabriel Cotlier
Hello,

I would like to be able to visualize / plot a specific data layer within
the structure a hierarchical data file format .h5  in R. I could observe
the structure as follows :

library(rhdf5)
r= h5ls(file.choose())
r

and also in this way identify the Group and Name of the data to be plotted,
however I've tried I could not access the data itself, nor plot it as a
raster layer with its corresponding geographic coordinates.
I would like to be able to select such data, plot it as a raster layer and
if possible save it as GeoTIFF file format to be further processed with the
raster package as a common raster layer.

If any small guidance example, reprex, of this procedure is possible
it would be appreciated.

Thanks a lot in advance
Kind regards,
Gabriel Cotlier
-- 
Gabriel Cotlier, PhD
Haifa Research Center for Theoretical Physics and Astrophysics (HCTPA)
University of Haifa
Israel

[[alternative HTML version deleted]]

___
R-sig-Geo mailing list
R-sig-Geo@r-project.org
https://stat.ethz.ch/mailman/listinfo/r-sig-geo