Interpolating snowfall values on a Digital Elevation Model

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

Interpolating snowfall values on a Digital Elevation Model

Stefano Sofia
Dear list users,
I have to produce rainfall maps. I know how to create a (bi-dimensional) grid and interpolate rainfall values (from automatic rain gauges) on that grid using Kriging:

myinterpolation <- autoKrige(myrainfall_cumulate ~ 1, rain_data_UTM, mygrid)

In reality I am dealing with snowfall values on mountain regions, and in this case altitude is an important factor, the use of a Digital Elevation Model might make the difference.
Looking in the web I found some important material about accessing elevation data in R with the "elevatr" package (by J.W.Hollister), I am reading it.
My concern would then be to interpolate snowfall values on a Digital Elevation Model. Did somebody already use R for these kinds of calculations? Could somebody share with me some useful hints?

Thank you for your attention
Stefano Sofia


         (oo)
--oOO--( )--OOo----------------
Stefano Sofia PhD
Area Meteorologica e  Area nivologica - Centro Funzionale
Servizio Protezione Civile - Regione Marche
Via del Colle Ameno 5
60126 Torrette di Ancona, Ancona
Uff: 071 806 7743
E-mail: [hidden email]
---Oo---------oO----------------

________________________________

AVVISO IMPORTANTE: Questo messaggio di posta elettronica può contenere informazioni confidenziali, pertanto è destinato solo a persone autorizzate alla ricezione. I messaggi di posta elettronica per i client di Regione Marche possono contenere informazioni confidenziali e con privilegi legali. Se non si è il destinatario specificato, non leggere, copiare, inoltrare o archiviare questo messaggio. Se si è ricevuto questo messaggio per errore, inoltrarlo al mittente ed eliminarlo completamente dal sistema del proprio computer. Ai sensi dell’art. 6 della DGR n. 1394/2008 si segnala che, in caso di necessità ed urgenza, la risposta al presente messaggio di posta elettronica può essere visionata da persone estranee al destinatario.
IMPORTANT NOTICE: This e-mail message is intended to be received only by persons entitled to receive the confidential information it may contain. E-mail messages to clients of Regione Marche may contain information that is confidential and legally privileged. Please do not read, copy, forward, or store this message unless you are an intended recipient of it. If you have received this message in error, please forward it to the sender and delete it completely from your computer system.

--
This message was scanned by Libra ESVA and is believed to be clean.


        [[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: Interpolating snowfall values on a Digital Elevation Model

Daniel Knitter
Hi Stefano,

assuming you have a DEM (downloaded e.g. from https://earthexplorer.usgs.gov/ or using the getData function from the raster package) as SpatialGridDataFrame loaded via readGDAL from the rgdal package you can use

autoKrige(YourMeasurements ~ DEM, YourMeasurementLocations, TargetGrid)

Futher information on "Regression Kriging" or "Kriging with external drift" can be found in the book of Hengl: http://spatial-analyst.net/book/ToC

Best,
Daniel

On Mon, 12 Feb 2018 08:03:41 +0000
Stefano Sofia <[hidden email]> wrote:

> Dear list users,
> I have to produce rainfall maps. I know how to create a (bi-dimensional) grid and interpolate rainfall values (from automatic rain gauges) on that grid using Kriging:
>
> myinterpolation <- autoKrige(myrainfall_cumulate ~ 1, rain_data_UTM, mygrid)
>
> In reality I am dealing with snowfall values on mountain regions, and in this case altitude is an important factor, the use of a Digital Elevation Model might make the difference.
> Looking in the web I found some important material about accessing elevation data in R with the "elevatr" package (by J.W.Hollister), I am reading it.
> My concern would then be to interpolate snowfall values on a Digital Elevation Model. Did somebody already use R for these kinds of calculations? Could somebody share with me some useful hints?
>
> Thank you for your attention
> Stefano Sofia
>
>
>          (oo)
> --oOO--( )--OOo----------------
> Stefano Sofia PhD
> Area Meteorologica e  Area nivologica - Centro Funzionale
> Servizio Protezione Civile - Regione Marche
> Via del Colle Ameno 5
> 60126 Torrette di Ancona, Ancona
> Uff: 071 806 7743
> E-mail: [hidden email]
> ---Oo---------oO----------------
>
> ________________________________
>
> AVVISO IMPORTANTE: Questo messaggio di posta elettronica può contenere informazioni confidenziali, pertanto è destinato solo a persone autorizzate alla ricezione. I messaggi di posta elettronica per i client di Regione Marche possono contenere informazioni confidenziali e con privilegi legali. Se non si è il destinatario specificato, non leggere, copiare, inoltrare o archiviare questo messaggio. Se si è ricevuto questo messaggio per errore, inoltrarlo al mittente ed eliminarlo completamente dal sistema del proprio computer. Ai sensi dell’art. 6 della DGR n. 1394/2008 si segnala che, in caso di necessità ed urgenza, la risposta al presente messaggio di posta elettronica può essere visionata da persone estranee al destinatario.
> IMPORTANT NOTICE: This e-mail message is intended to be received only by persons entitled to receive the confidential information it may contain. E-mail messages to clients of Regione Marche may contain information that is confidential and legally privileged. Please do not read, copy, forward, or store this message unless you are an intended recipient of it. If you have received this message in error, please forward it to the sender and delete it completely from your computer system.
>
> --
> This message was scanned by Libra ESVA and is believed to be clean.
>
>
> [[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

attachment0 (836 bytes) Download Attachment
Reply | Threaded
Open this post in threaded view
|

Re: Interpolating snowfall values on a Digital Elevation Model

Daniel Knitter
In reply to this post by Stefano Sofia
...sorry, I missed one step: you need to extract the elevation values to your points via extract function from the raster package:

YourPoints$YourExtractedElevationValues <- extract(x = DEM, y = YourPoints)

autoKrige(YourMeasurements ~ YourExtractedElevationValues, YourMeasurementLocations, TargetGrid)


Sorry for spamming.

Best,
Daniel

On Mon, 12 Feb 2018 08:03:41 +0000
Stefano Sofia <[hidden email]> wrote:

> Dear list users,
> I have to produce rainfall maps. I know how to create a (bi-dimensional) grid and interpolate rainfall values (from automatic rain gauges) on that grid using Kriging:
>
> myinterpolation <- autoKrige(myrainfall_cumulate ~ 1, rain_data_UTM, mygrid)
>
> In reality I am dealing with snowfall values on mountain regions, and in this case altitude is an important factor, the use of a Digital Elevation Model might make the difference.
> Looking in the web I found some important material about accessing elevation data in R with the "elevatr" package (by J.W.Hollister), I am reading it.
> My concern would then be to interpolate snowfall values on a Digital Elevation Model. Did somebody already use R for these kinds of calculations? Could somebody share with me some useful hints?
>
> Thank you for your attention
> Stefano Sofia
>
>
>          (oo)
> --oOO--( )--OOo----------------
> Stefano Sofia PhD
> Area Meteorologica e  Area nivologica - Centro Funzionale
> Servizio Protezione Civile - Regione Marche
> Via del Colle Ameno 5
> 60126 Torrette di Ancona, Ancona
> Uff: 071 806 7743
> E-mail: [hidden email]
> ---Oo---------oO----------------
>
> ________________________________
>
> AVVISO IMPORTANTE: Questo messaggio di posta elettronica può contenere informazioni confidenziali, pertanto è destinato solo a persone autorizzate alla ricezione. I messaggi di posta elettronica per i client di Regione Marche possono contenere informazioni confidenziali e con privilegi legali. Se non si è il destinatario specificato, non leggere, copiare, inoltrare o archiviare questo messaggio. Se si è ricevuto questo messaggio per errore, inoltrarlo al mittente ed eliminarlo completamente dal sistema del proprio computer. Ai sensi dell’art. 6 della DGR n. 1394/2008 si segnala che, in caso di necessità ed urgenza, la risposta al presente messaggio di posta elettronica può essere visionata da persone estranee al destinatario.
> IMPORTANT NOTICE: This e-mail message is intended to be received only by persons entitled to receive the confidential information it may contain. E-mail messages to clients of Regione Marche may contain information that is confidential and legally privileged. Please do not read, copy, forward, or store this message unless you are an intended recipient of it. If you have received this message in error, please forward it to the sender and delete it completely from your computer system.
>
> --
> This message was scanned by Libra ESVA and is believed to be clean.
>
>
> [[alternative HTML version deleted]]
>
> _______________________________________________
> R-sig-Geo mailing list
> [hidden email]
> https://stat.ethz.ch/mailman/listinfo/r-sig-geo

--

Dr. Daniel Knitter
CRC1266 -- Scales of Transformation
Project A2 "Integrative Modeling of Socio-Environmental Dynamics"

Christian-Albrechts-Universität zu Kiel
Department of Geography
Physical Geography -- Landscape Ecology and Geoinformation
Ludewig-Meyn-Str. 14, room 109
D - 24118 Kiel, Germany

Phone: +49 431 880 2941
Email: [hidden email]

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

attachment0 (836 bytes) Download Attachment
Reply | Threaded
Open this post in threaded view
|

Re: Interpolating snowfall values on a Digital Elevation Model

Stefano Sofia
Dear Daniel and list users,
I tried to follow the instructions but I encountered two kinds of errors.
This is a reproducibile code:

---------------------------------------------------------------------------------------------------------------
library(automap)
library(ggplot2)
library(gstat)
library(raster)
library(rasterVis)
library(rgdal)
library(maptools)

## LOADING DEM
ita_DEM <- getData('alt', country='ITA', mask=TRUE)
crs(ita_DEM) <- "+init=epsg:4326 +proj=longlat +datum=WGS84 +no_defs +ellps=WGS84 +towgs84=0,0,0"
#ita_DEM <- as(ita_DEM, "SpatialGridDataFrame")
str(ita_DEM)

## LOADING RAINFALL DATA
rain_data <- data.frame(Cumulata=c(11.8, 9.0, 8.0, 36.6, 9.4), Long_Cent=c(12.61874, 12.78690, 12.96756, 13.15599, 13.28157), Lat_Cent=c(43.79447, 43.85185, 43.76267, 43.03470, 43.08003), Altitude=c(112.20, 42.93, 36.14, 747, 465))

stations <- data.frame(rain_data$Long_Cent, rain_data$Lat_Cent)
rain_data <- SpatialPointsDataFrame(stations, rain_data, proj4string=CRS("+init=epsg:4326"))
stations <- SpatialPoints(stations, proj4string=CRS("+init=epsg:4326"))

## EXTRACT THE ELEVATION VALUES TO MY POINTS
rain_data$ExtractedElevationValues <- extract(x=ita_DEM, y=stations)

## CREATE GRID FOR KRIGING OUTPUT
minx <-  rain_data@bbox[1,1]
maxx <- rain_data@bbox[1,2]
miny <- rain_data@bbox[2,1]
maxy <- rain_data@bbox[2,2]
pixel <- 0.01
grd <- expand.grid(x=seq(minx, maxx, by=pixel), y=seq(miny, maxy, by=pixel))
coordinates(grd) <- ~x+y
gridded(grd) <- TRUE
proj4string(grd) <- CRS("+init=epsg:4326")

## KRIGING: autoKrige(YourMeasurements ~ YourExtractedElevationValues, YourMeasurementLocations, TargetGrid)
OK_snow <- autoKrige(Cumulata ~ rain_data$ExtractedElevationValues, rain_data, grd)
-------------------------------------------------------------------------------------------------------------------------------

The error I get is:
Error in autoKrige(Cumulata ~ rain_data$ExtractedElevationValues, rain_data,  :
  Either input_data or new_data is in LongLat, please reproject.
   input_data:  +init=epsg:4326 +proj=longlat +datum=WGS84 +no_defs +ellps=WGS84 +towgs84=0,0,0
   new_data:    +init=epsg:4326 +proj=longlat +datum=WGS84 +no_defs +ellps=WGS84 +towgs84=0,0,0

but I did pay attention to have the same reference system in rain_data, drg and the Digital Elevation Model.

Moreover, if I impose the class of the DEM to SpatialGridDataFrame when I extraxt the elevation points from the DEM I get the following error:
Error in (function (classes, fdef, mtable)  :
  unable to find an inherited method for function ‘extract’ for signature ‘"SpatialGridDataFrame", "SpatialPoints"’
Calls: extract -> <Anonymous>


Would you please somebody help to show me where is my mistake?

Thank you for all your attention
Stefano

         (oo)
--oOO--( )--OOo----------------
Stefano Sofia PhD
Area Meteorologica e  Area nivologica - Centro Funzionale
Servizio Protezione Civile - Regione Marche
Via del Colle Ameno 5
60126 Torrette di Ancona, Ancona
Uff: 071 806 7743
E-mail: [hidden email]
---Oo---------oO----------------
________________________________________
Da: R-sig-Geo [[hidden email]] per conto di Daniel Knitter [[hidden email]]
Inviato: lunedì 12 febbraio 2018 9.16
A: [hidden email]
Oggetto: Re: [R-sig-Geo]  Interpolating snowfall values on a Digital Elevation Model

...sorry, I missed one step: you need to extract the elevation values to your points via extract function from the raster package:

YourPoints$YourExtractedElevationValues <- extract(x = DEM, y = YourPoints)

autoKrige(YourMeasurements ~ YourExtractedElevationValues, YourMeasurementLocations, TargetGrid)


Sorry for spamming.

Best,
Daniel

On Mon, 12 Feb 2018 08:03:41 +0000
Stefano Sofia <[hidden email]> wrote:

> Dear list users,
> I have to produce rainfall maps. I know how to create a (bi-dimensional) grid and interpolate rainfall values (from automatic rain gauges) on that grid using Kriging:
>
> myinterpolation <- autoKrige(myrainfall_cumulate ~ 1, rain_data_UTM, mygrid)
>
> In reality I am dealing with snowfall values on mountain regions, and in this case altitude is an important factor, the use of a Digital Elevation Model might make the difference.
> Looking in the web I found some important material about accessing elevation data in R with the "elevatr" package (by J.W.Hollister), I am reading it.
> My concern would then be to interpolate snowfall values on a Digital Elevation Model. Did somebody already use R for these kinds of calculations? Could somebody share with me some useful hints?
>
> Thank you for your attention
> Stefano Sofia
>
>
>          (oo)
> --oOO--( )--OOo----------------
> Stefano Sofia PhD
> Area Meteorologica e  Area nivologica - Centro Funzionale
> Servizio Protezione Civile - Regione Marche
> Via del Colle Ameno 5
> 60126 Torrette di Ancona, Ancona
> Uff: 071 806 7743
> E-mail: [hidden email]
> ---Oo---------oO----------------
>
> ________________________________
>
> AVVISO IMPORTANTE: Questo messaggio di posta elettronica può contenere informazioni confidenziali, pertanto è destinato solo a persone autorizzate alla ricezione. I messaggi di posta elettronica per i client di Regione Marche possono contenere informazioni confidenziali e con privilegi legali. Se non si è il destinatario specificato, non leggere, copiare, inoltrare o archiviare questo messaggio. Se si è ricevuto questo messaggio per errore, inoltrarlo al mittente ed eliminarlo completamente dal sistema del proprio computer. Ai sensi dell’art. 6 della DGR n. 1394/2008 si segnala che, in caso di necessità ed urgenza, la risposta al presente messaggio di posta elettronica può essere visionata da persone estranee al destinatario.
> IMPORTANT NOTICE: This e-mail message is intended to be received only by persons entitled to receive the confidential information it may contain. E-mail messages to clients of Regione Marche may contain information that is confidential and legally privileged. Please do not read, copy, forward, or store this message unless you are an intended recipient of it. If you have received this message in error, please forward it to the sender and delete it completely from your computer system.
>
> --
> This message was scanned by Libra ESVA and is believed to be clean.
>
>
>       [[alternative HTML version deleted]]
>
> _______________________________________________
> R-sig-Geo mailing list
> [hidden email]
> https://urlsand.esvalabs.com/?u=https%3A%2F%2Fstat.ethz.ch%2Fmailman%2Flistinfo%2Fr-sig-geo&e=52342f8a&h=f7d4a649&f=y&p=y


--

Dr. Daniel Knitter
CRC1266 -- Scales of Transformation
Project A2 "Integrative Modeling of Socio-Environmental Dynamics"

Christian-Albrechts-Universität zu Kiel
Department of Geography
Physical Geography -- Landscape Ecology and Geoinformation
Ludewig-Meyn-Str. 14, room 109
D - 24118 Kiel, Germany

Phone: +49 431 880 2941
Email: [hidden email]

________________________________

AVVISO IMPORTANTE: Questo messaggio di posta elettronica può contenere informazioni confidenziali, pertanto è destinato solo a persone autorizzate alla ricezione. I messaggi di posta elettronica per i client di Regione Marche possono contenere informazioni confidenziali e con privilegi legali. Se non si è il destinatario specificato, non leggere, copiare, inoltrare o archiviare questo messaggio. Se si è ricevuto questo messaggio per errore, inoltrarlo al mittente ed eliminarlo completamente dal sistema del proprio computer. Ai sensi dell’art. 6 della DGR n. 1394/2008 si segnala che, in caso di necessità ed urgenza, la risposta al presente messaggio di posta elettronica può essere visionata da persone estranee al destinatario.
IMPORTANT NOTICE: This e-mail message is intended to be received only by persons entitled to receive the confidential information it may contain. E-mail messages to clients of Regione Marche may contain information that is confidential and legally privileged. Please do not read, copy, forward, or store this message unless you are an intended recipient of it. If you have received this message in error, please forward it to the sender and delete it completely from your computer system.

--
This message was scanned by Libra ESVA and is believed to be clean.

_______________________________________________
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: Interpolating snowfall values on a Digital Elevation Model

Dominik Schneider
You can't use a lat/long coordinate system when kriging because the concept
of distance is ambiguous. Convert all your data a UTM grid like you had in
your first post and it should work.

Another note, It looks like you are working at 0.01 deg which is on the
order of 1km resolution so you may find  other covariates such as aspect,
slope, and wind sheltering/exposure, terrain roughness for estimating snow
on the ground useful. see some of the earliest papers by Carroll, Cressie,
and Elder.

Carroll, S. S., and N. Cressie (1996), A comparison of geostatistical
methodologies used to estimate snow water equivalent, *JAWRA Journal of the
American Water Resources Association*, *32*(2), 267–278,
doi:10.1111/j.1752-1688.1996.tb03450.x.

Carroll, S. S., and N. Cressie (1997), Spatial modeling of snow water
equivalent using covariances estimated from spatial and geomorphic
attributes, *Journal of Hydrology*, *190*(1-2), 42–59.

Balk, B., and K. Elder (2000), Combining binary decision tree and
geostatistical methods to estimate snow distribution in a mountain
watershed, *Water Resources Research*, *36*(1), 13–26,
doi:10.1029/1999WR900251.

Erxleben, J., K. Elder, and R. Davis (2002), Comparison of spatial
interpolation methods for estimating snow distribution in the Colorado
Rocky Mountains, *Hydrological Processes*, *16*(18), 3627–3649,
doi:10.1002/hyp.1239.

Erickson, T. A., M. W. Williams, and A. Winstral (2005), Persistence of
topographic controls on the spatial distribution of snow in rugged mountain
terrain, Colorado, United States, *Water Resour. Res.*, *41*(4), W04014,
doi:10.1029/2003WR002973.


On Tue, Feb 13, 2018 at 3:45 AM, Stefano Sofia <
[hidden email]> wrote:

> Dear Daniel and list users,
> I tried to follow the instructions but I encountered two kinds of errors.
> This is a reproducibile code:
>
> ------------------------------------------------------------
> ---------------------------------------------------
> library(automap)
> library(ggplot2)
> library(gstat)
> library(raster)
> library(rasterVis)
> library(rgdal)
> library(maptools)
>
> ## LOADING DEM
> ita_DEM <- getData('alt', country='ITA', mask=TRUE)
> crs(ita_DEM) <- "+init=epsg:4326 +proj=longlat +datum=WGS84 +no_defs
> +ellps=WGS84 +towgs84=0,0,0"
> #ita_DEM <- as(ita_DEM, "SpatialGridDataFrame")
> str(ita_DEM)
>
> ## LOADING RAINFALL DATA
> rain_data <- data.frame(Cumulata=c(11.8, 9.0, 8.0, 36.6, 9.4),
> Long_Cent=c(12.61874, 12.78690, 12.96756, 13.15599, 13.28157),
> Lat_Cent=c(43.79447, 43.85185, 43.76267, 43.03470, 43.08003),
> Altitude=c(112.20, 42.93, 36.14, 747, 465))
>
> stations <- data.frame(rain_data$Long_Cent, rain_data$Lat_Cent)
> rain_data <- SpatialPointsDataFrame(stations, rain_data,
> proj4string=CRS("+init=epsg:4326"))
> stations <- SpatialPoints(stations, proj4string=CRS("+init=epsg:4326"))
>
> ## EXTRACT THE ELEVATION VALUES TO MY POINTS
> rain_data$ExtractedElevationValues <- extract(x=ita_DEM, y=stations)
>
> ## CREATE GRID FOR KRIGING OUTPUT
> minx <-  rain_data@bbox[1,1]
> maxx <- rain_data@bbox[1,2]
> miny <- rain_data@bbox[2,1]
> maxy <- rain_data@bbox[2,2]
> pixel <- 0.01
> grd <- expand.grid(x=seq(minx, maxx, by=pixel), y=seq(miny, maxy,
> by=pixel))
> coordinates(grd) <- ~x+y
> gridded(grd) <- TRUE
> proj4string(grd) <- CRS("+init=epsg:4326")
>
> ## KRIGING: autoKrige(YourMeasurements ~ YourExtractedElevationValues,
> YourMeasurementLocations, TargetGrid)
> OK_snow <- autoKrige(Cumulata ~ rain_data$ExtractedElevationValues,
> rain_data, grd)
> ------------------------------------------------------------
> -------------------------------------------------------------------
>
> The error I get is:
> Error in autoKrige(Cumulata ~ rain_data$ExtractedElevationValues,
> rain_data,  :
>   Either input_data or new_data is in LongLat, please reproject.
>    input_data:  +init=epsg:4326 +proj=longlat +datum=WGS84 +no_defs
> +ellps=WGS84 +towgs84=0,0,0
>    new_data:    +init=epsg:4326 +proj=longlat +datum=WGS84 +no_defs
> +ellps=WGS84 +towgs84=0,0,0
>
> but I did pay attention to have the same reference system in rain_data,
> drg and the Digital Elevation Model.
>
> Moreover, if I impose the class of the DEM to SpatialGridDataFrame when I
> extraxt the elevation points from the DEM I get the following error:
> Error in (function (classes, fdef, mtable)  :
>   unable to find an inherited method for function ‘extract’ for signature
> ‘"SpatialGridDataFrame", "SpatialPoints"’
> Calls: extract -> <Anonymous>
>
>
> Would you please somebody help to show me where is my mistake?
>
> Thank you for all your attention
> Stefano
>
>          (oo)
> --oOO--( )--OOo----------------
> Stefano Sofia PhD
> Area Meteorologica e  Area nivologica - Centro Funzionale
> Servizio Protezione Civile - Regione Marche
> Via del Colle Ameno 5
> 60126 Torrette di Ancona, Ancona
> Uff: 071 806 7743
> E-mail: [hidden email]
> ---Oo---------oO----------------
> ________________________________________
> Da: R-sig-Geo [[hidden email]] per conto di Daniel
> Knitter [[hidden email]]
> Inviato: lunedì 12 febbraio 2018 9.16
> A: [hidden email]
> Oggetto: Re: [R-sig-Geo]  Interpolating snowfall values on a Digital
> Elevation Model
>
> ...sorry, I missed one step: you need to extract the elevation values to
> your points via extract function from the raster package:
>
> YourPoints$YourExtractedElevationValues <- extract(x = DEM, y =
> YourPoints)
>
> autoKrige(YourMeasurements ~ YourExtractedElevationValues,
> YourMeasurementLocations, TargetGrid)
>
>
> Sorry for spamming.
>
> Best,
> Daniel
>
> On Mon, 12 Feb 2018 08:03:41 +0000
> Stefano Sofia <[hidden email]> wrote:
>
> > Dear list users,
> > I have to produce rainfall maps. I know how to create a (bi-dimensional)
> grid and interpolate rainfall values (from automatic rain gauges) on that
> grid using Kriging:
> >
> > myinterpolation <- autoKrige(myrainfall_cumulate ~ 1, rain_data_UTM,
> mygrid)
> >
> > In reality I am dealing with snowfall values on mountain regions, and in
> this case altitude is an important factor, the use of a Digital Elevation
> Model might make the difference.
> > Looking in the web I found some important material about accessing
> elevation data in R with the "elevatr" package (by J.W.Hollister), I am
> reading it.
> > My concern would then be to interpolate snowfall values on a Digital
> Elevation Model. Did somebody already use R for these kinds of
> calculations? Could somebody share with me some useful hints?
> >
> > Thank you for your attention
> > Stefano Sofia
> >
> >
> >          (oo)
> > --oOO--( )--OOo----------------
> > Stefano Sofia PhD
> > Area Meteorologica e  Area nivologica - Centro Funzionale
> > Servizio Protezione Civile - Regione Marche
> > Via del Colle Ameno 5
> > 60126 Torrette di Ancona, Ancona
> > Uff: 071 806 7743
> > E-mail: [hidden email]
> > ---Oo---------oO----------------
> >
> > ________________________________
> >
> > AVVISO IMPORTANTE: Questo messaggio di posta elettronica può contenere
> informazioni confidenziali, pertanto è destinato solo a persone autorizzate
> alla ricezione. I messaggi di posta elettronica per i client di Regione
> Marche possono contenere informazioni confidenziali e con privilegi legali.
> Se non si è il destinatario specificato, non leggere, copiare, inoltrare o
> archiviare questo messaggio. Se si è ricevuto questo messaggio per errore,
> inoltrarlo al mittente ed eliminarlo completamente dal sistema del proprio
> computer. Ai sensi dell’art. 6 della DGR n. 1394/2008 si segnala che, in
> caso di necessità ed urgenza, la risposta al presente messaggio di posta
> elettronica può essere visionata da persone estranee al destinatario.
> > IMPORTANT NOTICE: This e-mail message is intended to be received only by
> persons entitled to receive the confidential information it may contain.
> E-mail messages to clients of Regione Marche may contain information that
> is confidential and legally privileged. Please do not read, copy, forward,
> or store this message unless you are an intended recipient of it. If you
> have received this message in error, please forward it to the sender and
> delete it completely from your computer system.
> >
> > --
> > This message was scanned by Libra ESVA and is believed to be clean.
> >
> >
> >       [[alternative HTML version deleted]]
> >
> > _______________________________________________
> > R-sig-Geo mailing list
> > [hidden email]
> > <a href="https://urlsand.esvalabs.com/?u=https%3A%2F%2Fstat.ethz.ch%">https://urlsand.esvalabs.com/?u=https%3A%2F%2Fstat.ethz.ch%
> 2Fmailman%2Flistinfo%2Fr-sig-geo&e=52342f8a&h=f7d4a649&f=y&p=y
>
>
> --
>
> Dr. Daniel Knitter
> CRC1266 -- Scales of Transformation
> Project A2 "Integrative Modeling of Socio-Environmental Dynamics"
>
> Christian-Albrechts-Universität zu Kiel
> Department of Geography
> Physical Geography -- Landscape Ecology and Geoinformation
> Ludewig-Meyn-Str. 14, room 109
> D - 24118 Kiel, Germany
>
> Phone: +49 431 880 2941
> Email: [hidden email]
>
> ________________________________
>
> AVVISO IMPORTANTE: Questo messaggio di posta elettronica può contenere
> informazioni confidenziali, pertanto è destinato solo a persone autorizzate
> alla ricezione. I messaggi di posta elettronica per i client di Regione
> Marche possono contenere informazioni confidenziali e con privilegi legali.
> Se non si è il destinatario specificato, non leggere, copiare, inoltrare o
> archiviare questo messaggio. Se si è ricevuto questo messaggio per errore,
> inoltrarlo al mittente ed eliminarlo completamente dal sistema del proprio
> computer. Ai sensi dell’art. 6 della DGR n. 1394/2008 si segnala che, in
> caso di necessità ed urgenza, la risposta al presente messaggio di posta
> elettronica può essere visionata da persone estranee al destinatario.
> IMPORTANT NOTICE: This e-mail message is intended to be received only by
> persons entitled to receive the confidential information it may contain.
> E-mail messages to clients of Regione Marche may contain information that
> is confidential and legally privileged. Please do not read, copy, forward,
> or store this message unless you are an intended recipient of it. If you
> have received this message in error, please forward it to the sender and
> delete it completely from your computer system.
>
> --
> This message was scanned by Libra ESVA and is believed to be clean.
>
> _______________________________________________
> 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: Interpolating snowfall values on a Digital Elevation Model

Stefano Sofia
Yes, thank you for all your observations.
I realized that I needed projected coordinates, I changed it and now it works.
I will read the suggested papers as soon as I can.

Thank you
Stefano

         (oo)
--oOO--( )--OOo----------------
Stefano Sofia PhD
Area Meteorologica e  Area nivologica - Centro Funzionale
Servizio Protezione Civile - Regione Marche
Via del Colle Ameno 5
60126 Torrette di Ancona, Ancona
Uff: 071 806 7743
E-mail: [hidden email]
---Oo---------oO----------------
________________________________
Da: Dominik Schneider [[hidden email]]
Inviato: marted� 13 febbraio 2018 17.21
A: Stefano Sofia
Cc: Daniel Knitter; [hidden email]
Oggetto: Re: [R-sig-Geo] Interpolating snowfall values on a Digital Elevation Model

You can't use a lat/long coordinate system when kriging because the concept of distance is ambiguous. Convert all your data a UTM grid like you had in your first post and it should work.

Another note, It looks like you are working at 0.01 deg which is on the order of 1km resolution so you may find  other covariates such as aspect, slope, and wind sheltering/exposure, terrain roughness for estimating snow on the ground useful. see some of the earliest papers by Carroll, Cressie, and Elder.

Carroll, S. S., and N. Cressie (1996), A comparison of geostatistical methodologies used to estimate snow water equivalent, JAWRA Journal of the American Water Resources Association, 32(2), 267�278, doi:10.1111/j.1752-1688.1996.tb03450.x.

Carroll, S. S., and N. Cressie (1997), Spatial modeling of snow water equivalent using covariances estimated from spatial and geomorphic attributes, Journal of Hydrology, 190(1-2), 42�59.

Balk, B., and K. Elder (2000), Combining binary decision tree and geostatistical methods to estimate snow distribution in a mountain watershed, Water Resources Research, 36(1), 13�26, doi:10.1029/1999WR900251.

Erxleben, J., K. Elder, and R. Davis (2002), Comparison of spatial interpolation methods for estimating snow distribution in the Colorado Rocky Mountains, Hydrological Processes, 16(18), 3627�3649, doi:10.1002/hyp.1239.

Erickson, T. A., M. W. Williams, and A. Winstral (2005), Persistence of topographic controls on the spatial distribution of snow in rugged mountain terrain, Colorado, United States, Water Resour. Res., 41(4), W04014, doi:10.1029/2003WR002973.


On Tue, Feb 13, 2018 at 3:45 AM, Stefano Sofia <[hidden email]<mailto:[hidden email]>> wrote:
Dear Daniel and list users,
I tried to follow the instructions but I encountered two kinds of errors.
This is a reproducibile code:

---------------------------------------------------------------------------------------------------------------
library(automap)
library(ggplot2)
library(gstat)
library(raster)
library(rasterVis)
library(rgdal)
library(maptools)

## LOADING DEM
ita_DEM <- getData('alt', country='ITA', mask=TRUE)
crs(ita_DEM) <- "+init=epsg:4326 +proj=longlat +datum=WGS84 +no_defs +ellps=WGS84 +towgs84=0,0,0"
#ita_DEM <- as(ita_DEM, "SpatialGridDataFrame")
str(ita_DEM)

## LOADING RAINFALL DATA
rain_data <- data.frame(Cumulata=c(11.8, 9.0, 8.0, 36.6, 9.4), Long_Cent=c(12.61874, 12.78690, 12.96756, 13.15599, 13.28157), Lat_Cent=c(43.79447, 43.85185, 43.76267, 43.03470, 43.08003), Altitude=c(112.20, 42.93, 36.14, 747, 465))

stations <- data.frame(rain_data$Long_Cent, rain_data$Lat_Cent)
rain_data <- SpatialPointsDataFrame(stations, rain_data, proj4string=CRS("+init=epsg:4326"))
stations <- SpatialPoints(stations, proj4string=CRS("+init=epsg:4326"))

## EXTRACT THE ELEVATION VALUES TO MY POINTS
rain_data$ExtractedElevationValues <- extract(x=ita_DEM, y=stations)

## CREATE GRID FOR KRIGING OUTPUT
minx <-  rain_data@bbox[1,1]
maxx <- rain_data@bbox[1,2]
miny <- rain_data@bbox[2,1]
maxy <- rain_data@bbox[2,2]
pixel <- 0.01
grd <- expand.grid(x=seq(minx, maxx, by=pixel), y=seq(miny, maxy, by=pixel))
coordinates(grd) <- ~x+y
gridded(grd) <- TRUE
proj4string(grd) <- CRS("+init=epsg:4326")

## KRIGING: autoKrige(YourMeasurements ~ YourExtractedElevationValues, YourMeasurementLocations, TargetGrid)
OK_snow <- autoKrige(Cumulata ~ rain_data$ExtractedElevationValues, rain_data, grd)
-------------------------------------------------------------------------------------------------------------------------------

The error I get is:
Error in autoKrige(Cumulata ~ rain_data$ExtractedElevationValues, rain_data,  :
  Either input_data or new_data is in LongLat, please reproject.
   input_data:  +init=epsg:4326 +proj=longlat +datum=WGS84 +no_defs +ellps=WGS84 +towgs84=0,0,0
   new_data:    +init=epsg:4326 +proj=longlat +datum=WGS84 +no_defs +ellps=WGS84 +towgs84=0,0,0

but I did pay attention to have the same reference system in rain_data, drg and the Digital Elevation Model.

Moreover, if I impose the class of the DEM to SpatialGridDataFrame when I extraxt the elevation points from the DEM I get the following error:
Error in (function (classes, fdef, mtable)  :
  unable to find an inherited method for function �extract� for signature �"SpatialGridDataFrame", "SpatialPoints"�
Calls: extract -> <Anonymous>


Would you please somebody help to show me where is my mistake?

Thank you for all your attention
Stefano

         (oo)
--oOO--( )--OOo----------------
Stefano Sofia PhD
Area Meteorologica e  Area nivologica - Centro Funzionale
Servizio Protezione Civile - Regione Marche
Via del Colle Ameno 5
60126 Torrette di Ancona, Ancona
Uff: 071 806 7743
E-mail: [hidden email]<mailto:[hidden email]>
---Oo---------oO----------------
________________________________________
Da: R-sig-Geo [[hidden email]<mailto:[hidden email]>] per conto di Daniel Knitter [[hidden email]<mailto:[hidden email]>]
Inviato: luned� 12 febbraio 2018 9.16
A: [hidden email]<mailto:[hidden email]>
Oggetto: Re: [R-sig-Geo]  Interpolating snowfall values on a Digital Elevation Model

...sorry, I missed one step: you need to extract the elevation values to your points via extract function from the raster package:

YourPoints$YourExtractedElevationValues <- extract(x = DEM, y = YourPoints)

autoKrige(YourMeasurements ~ YourExtractedElevationValues, YourMeasurementLocations, TargetGrid)


Sorry for spamming.

Best,
Daniel

On Mon, 12 Feb 2018 08:03:41 +0000
Stefano Sofia <[hidden email]<mailto:[hidden email]>> wrote:

> Dear list users,
> I have to produce rainfall maps. I know how to create a (bi-dimensional) grid and interpolate rainfall values (from automatic rain gauges) on that grid using Kriging:
>
> myinterpolation <- autoKrige(myrainfall_cumulate ~ 1, rain_data_UTM, mygrid)
>
> In reality I am dealing with snowfall values on mountain regions, and in this case altitude is an important factor, the use of a Digital Elevation Model might make the difference.
> Looking in the web I found some important material about accessing elevation data in R with the "elevatr" package (by J.W.Hollister), I am reading it.
> My concern would then be to interpolate snowfall values on a Digital Elevation Model. Did somebody already use R for these kinds of calculations? Could somebody share with me some useful hints?
>
> Thank you for your attention
> Stefano Sofia
>
>
>          (oo)
> --oOO--( )--OOo----------------
> Stefano Sofia PhD
> Area Meteorologica e  Area nivologica - Centro Funzionale
> Servizio Protezione Civile - Regione Marche
> Via del Colle Ameno 5
> 60126 Torrette di Ancona, Ancona
> Uff: 071 806 7743
> E-mail: [hidden email]<mailto:[hidden email]>
> ---Oo---------oO----------------
>
> ________________________________
>
> AVVISO IMPORTANTE: Questo messaggio di posta elettronica pu� contenere informazioni confidenziali, pertanto � destinato solo a persone autorizzate alla ricezione. I messaggi di posta elettronica per i client di Regione Marche possono contenere informazioni confidenziali e con privilegi legali. Se non si � il destinatario specificato, non leggere, copiare, inoltrare o archiviare questo messaggio. Se si � ricevuto questo messaggio per errore, inoltrarlo al mittente ed eliminarlo completamente dal sistema del proprio computer. Ai sensi dell�art. 6 della DGR n. 1394/2008 si segnala che, in caso di necessit� ed urgenza, la risposta al presente messaggio di posta elettronica pu� essere visionata da persone estranee al destinatario.
> IMPORTANT NOTICE: This e-mail message is intended to be received only by persons entitled to receive the confidential information it may contain. E-mail messages to clients of Regione Marche may contain information that is confidential and legally privileged. Please do not read, copy, forward, or store this message unless you are an intended recipient of it. If you have received this message in error, please forward it to the sender and delete it completely from your computer system.
>
> --
> This message was scanned by Libra ESVA and is believed to be clean.
>
>
>       [[alternative HTML version deleted]]
>
> _______________________________________________
> R-sig-Geo mailing list
> [hidden email]<mailto:[hidden email]>
> https://urlsand.esvalabs.com/?u=https%3A%2F%2Fstat.ethz.ch%2Fmailman%2Flistinfo%2Fr-sig-geo&e=52342f8a&h=f7d4a649&f=y&p=y

--

Dr. Daniel Knitter
CRC1266 -- Scales of Transformation
Project A2 "Integrative Modeling of Socio-Environmental Dynamics"

Christian-Albrechts-Universit�t zu Kiel
Department of Geography
Physical Geography -- Landscape Ecology and Geoinformation
Ludewig-Meyn-Str. 14, room 109
D - 24118 Kiel, Germany

Phone: +49 431 880 2941<tel:%2B49%20431%20880%202941>
Email: [hidden email]<mailto:[hidden email]>

________________________________

AVVISO IMPORTANTE: Questo messaggio di posta elettronica pu� contenere informazioni confidenziali, pertanto � destinato solo a persone autorizzate alla ricezione. I messaggi di posta elettronica per i client di Regione Marche possono contenere informazioni confidenziali e con privilegi legali. Se non si � il destinatario specificato, non leggere, copiare, inoltrare o archiviare questo messaggio. Se si � ricevuto questo messaggio per errore, inoltrarlo al mittente ed eliminarlo completamente dal sistema del proprio computer. Ai sensi dell�art. 6 della DGR n. 1394/2008 si segnala che, in caso di necessit� ed urgenza, la risposta al presente messaggio di posta elettronica pu� essere visionata da persone estranee al destinatario.
IMPORTANT NOTICE: This e-mail message is intended to be received only by persons entitled to receive the confidential information it may contain. E-mail messages to clients of Regione Marche may contain information that is confidential and legally privileged. Please do not read, copy, forward, or store this message unless you are an intended recipient of it. If you have received this message in error, please forward it to the sender and delete it completely from your computer system.

--
This message was scanned by Libra ESVA and is believed to be clean.

_______________________________________________
R-sig-Geo mailing list
[hidden email]<mailto:[hidden email]>
https://stat.ethz.ch/mailman/listinfo/r-sig-geo<https://urlsand.esvalabs.com/?u=https%3A%2F%2Fstat.ethz.ch%2Fmailman%2Flistinfo%2Fr-sig-geo&e=52342f8a&h=f7d4a649&f=y&p=y>


--
This message has been checked by Libra Esva and is found to be clean.
Mark it as spam<http://libraesvan2.regionemarche.intra/cgi-bin/learn-msg.cgi?id=A07034025C.AF6D7>
Blacklist sender<http://libraesvan2.regionemarche.intra/cgi-bin/learn-msg.cgi?blacklist=1&id=A07034025C.AF6D7>

________________________________

AVVISO IMPORTANTE: Questo messaggio di posta elettronica pu� contenere informazioni confidenziali, pertanto � destinato solo a persone autorizzate alla ricezione. I messaggi di posta elettronica per i client di Regione Marche possono contenere informazioni confidenziali e con privilegi legali. Se non si � il destinatario specificato, non leggere, copiare, inoltrare o archiviare questo messaggio. Se si � ricevuto questo messaggio per errore, inoltrarlo al mittente ed eliminarlo completamente dal sistema del proprio computer. Ai sensi dell�art. 6 della DGR n. 1394/2008 si segnala che, in caso di necessit� ed urgenza, la risposta al presente messaggio di posta elettronica pu� essere visionata da persone estranee al destinatario.
IMPORTANT NOTICE: This e-mail message is intended to be received only by persons entitled to receive the confidential information it may contain. E-mail messages to clients of Regione Marche may contain information that is confidential and legally privileged. Please do not read, copy, forward, or store this message unless you are an intended recipient of it. If you have received this message in error, please forward it to the sender and delete it completely from your computer system.

--
This message was scanned by Libra ESVA and is believed to be clean.


        [[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
|

I: Interpolating snowfall values on a Digital Elevation Model

Stefano Sofia
In reply to this post by Stefano Sofia
This is the contribute of Daniel Knitter to my previous doubts.

Thank you again to Daniel Knitter and Dominik Scheider for their help.

Stefano

         (oo)
--oOO--( )--OOo----------------
Stefano Sofia PhD
Area Meteorologica e  Area nivologica - Centro Funzionale
Servizio Protezione Civile - Regione Marche
Via del Colle Ameno 5
60126 Torrette di Ancona, Ancona
Uff: 071 806 7743
E-mail: [hidden email]
---Oo---------oO----------------
________________________________________
Da: Daniel Knitter [[hidden email]]
Inviato: martedì 13 febbraio 2018 10.51
A: Stefano Sofia
Oggetto: Re: [R-sig-Geo]  Interpolating snowfall values on a Digital Elevation Model

Dear Stefano,

concerning the error messages:

1) you need projected (metric) coordinates -- while you are using geographic ones
2) the extract function is from package raster and expects a raster input -- while you give a SpatialGridDataFrame as input

this code should work:

library(raster)
ita_DEM <- getData('alt', country='ITA', mask=TRUE)
ita_DEM <- projectRaster(ita_DEM, crs = CRS("+init=epsg:32633"))

## LOADING RAINFALL DATA
rain_data <- data.frame(cumulata=c(11.8, 9.0, 8.0, 36.6, 9.4),
                        Long_Cent=c(12.61874, 12.78690, 12.96756, 13.15599, 13.28157),
                        Lat_Cent=c(43.79447, 43.85185, 43.76267, 43.03470, 43.08003),
                        altitude=c(112.20, 42.93, 36.14, 747, 465))

library(sp)
coordinates(rain_data) <- ~Long_Cent+Lat_Cent
proj4string(rain_data) <- CRS("+init=epsg:4326")
rain_data <- spTransform(rain_data, CRS("+init=epsg:32633"))

rain_data$extractedelevationvalues <- extract(x=ita_DEM, y=rain_data)

newgrid <- as(ita_DEM, "SpatialGridDataFrame")
names(newgrid) <- "extractedelevationvalues"

library(automap)
RegressionKriging_snow <- autoKrige(cumulata~extractedelevationvalues,
                                    rain_data,
                                    newgrid)

Cheers,
Daniel



On Tue, 13 Feb 2018 08:45:34 +0000
Stefano Sofia <[hidden email]> wrote:

> Dear Daniel and list users,
> I tried to follow the instructions but I encountered two kinds of errors.
> This is a reproducibile code:
>
> ---------------------------------------------------------------------------------------------------------------
> library(automap)
> library(ggplot2)
> library(gstat)
> library(raster)
> library(rasterVis)
> library(rgdal)
> library(maptools)
>
> ## LOADING DEM
> ita_DEM <- getData('alt', country='ITA', mask=TRUE)
> crs(ita_DEM) <- "+init=epsg:4326 +proj=longlat +datum=WGS84 +no_defs +ellps=WGS84 +towgs84=0,0,0"
> #ita_DEM <- as(ita_DEM, "SpatialGridDataFrame")
> str(ita_DEM)
>
> ## LOADING RAINFALL DATA
> rain_data <- data.frame(Cumulata=c(11.8, 9.0, 8.0, 36.6, 9.4), Long_Cent=c(12.61874, 12.78690, 12.96756, 13.15599, 13.28157), Lat_Cent=c(43.79447, 43.85185, 43.76267, 43.03470, 43.08003), Altitude=c(112.20, 42.93, 36.14, 747, 465))
>
> stations <- data.frame(rain_data$Long_Cent, rain_data$Lat_Cent)
> rain_data <- SpatialPointsDataFrame(stations, rain_data, proj4string=CRS("+init=epsg:4326"))
> stations <- SpatialPoints(stations, proj4string=CRS("+init=epsg:4326"))
>
> ## EXTRACT THE ELEVATION VALUES TO MY POINTS
> rain_data$ExtractedElevationValues <- extract(x=ita_DEM, y=stations)
>
> ## CREATE GRID FOR KRIGING OUTPUT
> minx <-  rain_data@bbox[1,1]
> maxx <- rain_data@bbox[1,2]
> miny <- rain_data@bbox[2,1]
> maxy <- rain_data@bbox[2,2]
> pixel <- 0.01
> grd <- expand.grid(x=seq(minx, maxx, by=pixel), y=seq(miny, maxy, by=pixel))
> coordinates(grd) <- ~x+y
> gridded(grd) <- TRUE
> proj4string(grd) <- CRS("+init=epsg:4326")
>
> ## KRIGING: autoKrige(YourMeasurements ~ YourExtractedElevationValues, YourMeasurementLocations, TargetGrid)
> OK_snow <- autoKrige(Cumulata ~ rain_data$ExtractedElevationValues, rain_data, grd)
> -------------------------------------------------------------------------------------------------------------------------------
>
> The error I get is:
> Error in autoKrige(Cumulata ~ rain_data$ExtractedElevationValues, rain_data,  :
>   Either input_data or new_data is in LongLat, please reproject.
>    input_data:  +init=epsg:4326 +proj=longlat +datum=WGS84 +no_defs +ellps=WGS84 +towgs84=0,0,0
>    new_data:    +init=epsg:4326 +proj=longlat +datum=WGS84 +no_defs +ellps=WGS84 +towgs84=0,0,0
>
> but I did pay attention to have the same reference system in rain_data, drg and the Digital Elevation Model.
>
> Moreover, if I impose the class of the DEM to SpatialGridDataFrame when I extraxt the elevation points from the DEM I get the following error:
> Error in (function (classes, fdef, mtable)  :
>   unable to find an inherited method for function ‘extract’ for signature ‘"SpatialGridDataFrame", "SpatialPoints"’
> Calls: extract -> <Anonymous>
>
>
> Would you please somebody help to show me where is my mistake?
>
> Thank you for all your attention
> Stefano
>
>          (oo)
> --oOO--( )--OOo----------------
> Stefano Sofia PhD
> Area Meteorologica e  Area nivologica - Centro Funzionale
> Servizio Protezione Civile - Regione Marche
> Via del Colle Ameno 5
> 60126 Torrette di Ancona, Ancona
> Uff: 071 806 7743
> E-mail: [hidden email]
> ---Oo---------oO----------------
> ________________________________________
> Da: R-sig-Geo [[hidden email]] per conto di Daniel Knitter [[hidden email]]
> Inviato: lunedì 12 febbraio 2018 9.16
> A: [hidden email]
> Oggetto: Re: [R-sig-Geo]  Interpolating snowfall values on a Digital Elevation Model
>
> ...sorry, I missed one step: you need to extract the elevation values to your points via extract function from the raster package:
>
> YourPoints$YourExtractedElevationValues <- extract(x = DEM, y = YourPoints)
>
> autoKrige(YourMeasurements ~ YourExtractedElevationValues, YourMeasurementLocations, TargetGrid)
>
>
> Sorry for spamming.
>
> Best,
> Daniel
>
> On Mon, 12 Feb 2018 08:03:41 +0000
> Stefano Sofia <[hidden email]> wrote:
>
> > Dear list users,
> > I have to produce rainfall maps. I know how to create a (bi-dimensional) grid and interpolate rainfall values (from automatic rain gauges) on that grid using Kriging:
> >
> > myinterpolation <- autoKrige(myrainfall_cumulate ~ 1, rain_data_UTM, mygrid)
> >
> > In reality I am dealing with snowfall values on mountain regions, and in this case altitude is an important factor, the use of a Digital Elevation Model might make the difference.
> > Looking in the web I found some important material about accessing elevation data in R with the "elevatr" package (by J.W.Hollister), I am reading it.
> > My concern would then be to interpolate snowfall values on a Digital Elevation Model. Did somebody already use R for these kinds of calculations? Could somebody share with me some useful hints?
> >
> > Thank you for your attention
> > Stefano Sofia
> >
> >
> >          (oo)
> > --oOO--( )--OOo----------------
> > Stefano Sofia PhD
> > Area Meteorologica e  Area nivologica - Centro Funzionale
> > Servizio Protezione Civile - Regione Marche
> > Via del Colle Ameno 5
> > 60126 Torrette di Ancona, Ancona
> > Uff: 071 806 7743
> > E-mail: [hidden email]
> > ---Oo---------oO----------------
> >
> > ________________________________
> >
> > AVVISO IMPORTANTE: Questo messaggio di posta elettronica può contenere informazioni confidenziali, pertanto è destinato solo a persone autorizzate alla ricezione. I messaggi di posta elettronica per i client di Regione Marche possono contenere informazioni confidenziali e con privilegi legali. Se non si è il destinatario specificato, non leggere, copiare, inoltrare o archiviare questo messaggio. Se si è ricevuto questo messaggio per errore, inoltrarlo al mittente ed eliminarlo completamente dal sistema del proprio computer. Ai sensi dell’art. 6 della DGR n. 1394/2008 si segnala che, in caso di necessità ed urgenza, la risposta al presente messaggio di posta elettronica può essere visionata da persone estranee al destinatario.
> > IMPORTANT NOTICE: This e-mail message is intended to be received only by persons entitled to receive the confidential information it may contain. E-mail messages to clients of Regione Marche may contain information that is confidential and legally privileged. Please do not read, copy, forward, or store this message unless you are an intended recipient of it. If you have received this message in error, please forward it to the sender and delete it completely from your computer system.
> >
> > --
> > This message was scanned by Libra ESVA and is believed to be clean.
> >
> >
> >       [[alternative HTML version deleted]]
> >
> > _______________________________________________
> > R-sig-Geo mailing list
> > [hidden email]
> > https://urlsand.esvalabs.com/?u=https%3A%2F%2Fstat.ethz.ch%2Fmailman%2Flistinfo%2Fr-sig-geo&e=52342f8a&h=f7d4a649&f=y&p=y
>
>
> --
>
> Dr. Daniel Knitter
> CRC1266 -- Scales of Transformation
> Project A2 "Integrative Modeling of Socio-Environmental Dynamics"
>
> Christian-Albrechts-Universität zu Kiel
> Department of Geography
> Physical Geography -- Landscape Ecology and Geoinformation
> Ludewig-Meyn-Str. 14, room 109
> D - 24118 Kiel, Germany
>
> Phone: +49 431 880 2941
> Email: [hidden email]
>
> ________________________________
>
> AVVISO IMPORTANTE: Questo messaggio di posta elettronica può contenere informazioni confidenziali, pertanto è destinato solo a persone autorizzate alla ricezione. I messaggi di posta elettronica per i client di Regione Marche possono contenere informazioni confidenziali e con privilegi legali. Se non si è il destinatario specificato, non leggere, copiare, inoltrare o archiviare questo messaggio. Se si è ricevuto questo messaggio per errore, inoltrarlo al mittente ed eliminarlo completamente dal sistema del proprio computer. Ai sensi dell’art. 6 della DGR n. 1394/2008 si segnala che, in caso di necessità ed urgenza, la risposta al presente messaggio di posta elettronica può essere visionata da persone estranee al destinatario.
> IMPORTANT NOTICE: This e-mail message is intended to be received only by persons entitled to receive the confidential information it may contain. E-mail messages to clients of Regione Marche may contain information that is confidential and legally privileged. Please do not read, copy, forward, or store this message unless you are an intended recipient of it. If you have received this message in error, please forward it to the sender and delete it completely from your computer system.
>
> --
> This message was scanned by Libra ESVA and is believed to be clean.
>


--

Dr. Daniel Knitter
CRC1266 -- Scales of Transformation
Project A2 "Integrative Modeling of Socio-Environmental Dynamics"

Christian-Albrechts-Universität zu Kiel
Department of Geography
Physical Geography -- Landscape Ecology and Geoinformation
Ludewig-Meyn-Str. 14, room 109
D - 24118 Kiel, Germany

Phone: +49 431 880 2941
Email: [hidden email]

________________________________

AVVISO IMPORTANTE: Questo messaggio di posta elettronica può contenere informazioni confidenziali, pertanto è destinato solo a persone autorizzate alla ricezione. I messaggi di posta elettronica per i client di Regione Marche possono contenere informazioni confidenziali e con privilegi legali. Se non si è il destinatario specificato, non leggere, copiare, inoltrare o archiviare questo messaggio. Se si è ricevuto questo messaggio per errore, inoltrarlo al mittente ed eliminarlo completamente dal sistema del proprio computer. Ai sensi dell’art. 6 della DGR n. 1394/2008 si segnala che, in caso di necessità ed urgenza, la risposta al presente messaggio di posta elettronica può essere visionata da persone estranee al destinatario.
IMPORTANT NOTICE: This e-mail message is intended to be received only by persons entitled to receive the confidential information it may contain. E-mail messages to clients of Regione Marche may contain information that is confidential and legally privileged. Please do not read, copy, forward, or store this message unless you are an intended recipient of it. If you have received this message in error, please forward it to the sender and delete it completely from your computer system.

--
This message was scanned by Libra ESVA and is believed to be clean.

_______________________________________________
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: I: Interpolating snowfall values on a Digital Elevation Model

Biplab Biswas
 Dear All,

Please see the link for a International Conference in the University of
Burdwan

https://sites.google.com/buruniv.ac.in/fbms/home

Regards.
Biplab



On Wed, Feb 14, 2018 at 2:04 PM, Stefano Sofia <
[hidden email]> wrote:

> This is the contribute of Daniel Knitter to my previous doubts.
>
> Thank you again to Daniel Knitter and Dominik Scheider for their help.
>
> Stefano
>
>          (oo)
> --oOO--( )--OOo----------------
> Stefano Sofia PhD
> Area Meteorologica e  Area nivologica - Centro Funzionale
> Servizio Protezione Civile - Regione Marche
> Via del Colle Ameno 5
> 60126 Torrette di Ancona, Ancona
> Uff: 071 806 7743
> E-mail: [hidden email]
> ---Oo---------oO----------------
> ________________________________________
> Da: Daniel Knitter [[hidden email]]
> Inviato: martedì 13 febbraio 2018 10.51
> A: Stefano Sofia
> Oggetto: Re: [R-sig-Geo]  Interpolating snowfall values on a Digital
> Elevation Model
>
> Dear Stefano,
>
> concerning the error messages:
>
> 1) you need projected (metric) coordinates -- while you are using
> geographic ones
> 2) the extract function is from package raster and expects a raster input
> -- while you give a SpatialGridDataFrame as input
>
> this code should work:
>
> library(raster)
> ita_DEM <- getData('alt', country='ITA', mask=TRUE)
> ita_DEM <- projectRaster(ita_DEM, crs = CRS("+init=epsg:32633"))
>
> ## LOADING RAINFALL DATA
> rain_data <- data.frame(cumulata=c(11.8, 9.0, 8.0, 36.6, 9.4),
>                         Long_Cent=c(12.61874, 12.78690, 12.96756,
> 13.15599, 13.28157),
>                         Lat_Cent=c(43.79447, 43.85185, 43.76267, 43.03470,
> 43.08003),
>                         altitude=c(112.20, 42.93, 36.14, 747, 465))
>
> library(sp)
> coordinates(rain_data) <- ~Long_Cent+Lat_Cent
> proj4string(rain_data) <- CRS("+init=epsg:4326")
> rain_data <- spTransform(rain_data, CRS("+init=epsg:32633"))
>
> rain_data$extractedelevationvalues <- extract(x=ita_DEM, y=rain_data)
>
> newgrid <- as(ita_DEM, "SpatialGridDataFrame")
> names(newgrid) <- "extractedelevationvalues"
>
> library(automap)
> RegressionKriging_snow <- autoKrige(cumulata~extractedelevationvalues,
>                                     rain_data,
>                                     newgrid)
>
> Cheers,
> Daniel
>
>
>
> On Tue, 13 Feb 2018 08:45:34 +0000
> Stefano Sofia <[hidden email]> wrote:
>
> > Dear Daniel and list users,
> > I tried to follow the instructions but I encountered two kinds of errors.
> > This is a reproducibile code:
> >
> > ------------------------------------------------------------
> ---------------------------------------------------
> > library(automap)
> > library(ggplot2)
> > library(gstat)
> > library(raster)
> > library(rasterVis)
> > library(rgdal)
> > library(maptools)
> >
> > ## LOADING DEM
> > ita_DEM <- getData('alt', country='ITA', mask=TRUE)
> > crs(ita_DEM) <- "+init=epsg:4326 +proj=longlat +datum=WGS84 +no_defs
> +ellps=WGS84 +towgs84=0,0,0"
> > #ita_DEM <- as(ita_DEM, "SpatialGridDataFrame")
> > str(ita_DEM)
> >
> > ## LOADING RAINFALL DATA
> > rain_data <- data.frame(Cumulata=c(11.8, 9.0, 8.0, 36.6, 9.4),
> Long_Cent=c(12.61874, 12.78690, 12.96756, 13.15599, 13.28157),
> Lat_Cent=c(43.79447, 43.85185, 43.76267, 43.03470, 43.08003),
> Altitude=c(112.20, 42.93, 36.14, 747, 465))
> >
> > stations <- data.frame(rain_data$Long_Cent, rain_data$Lat_Cent)
> > rain_data <- SpatialPointsDataFrame(stations, rain_data,
> proj4string=CRS("+init=epsg:4326"))
> > stations <- SpatialPoints(stations, proj4string=CRS("+init=epsg:4326"))
> >
> > ## EXTRACT THE ELEVATION VALUES TO MY POINTS
> > rain_data$ExtractedElevationValues <- extract(x=ita_DEM, y=stations)
> >
> > ## CREATE GRID FOR KRIGING OUTPUT
> > minx <-  rain_data@bbox[1,1]
> > maxx <- rain_data@bbox[1,2]
> > miny <- rain_data@bbox[2,1]
> > maxy <- rain_data@bbox[2,2]
> > pixel <- 0.01
> > grd <- expand.grid(x=seq(minx, maxx, by=pixel), y=seq(miny, maxy,
> by=pixel))
> > coordinates(grd) <- ~x+y
> > gridded(grd) <- TRUE
> > proj4string(grd) <- CRS("+init=epsg:4326")
> >
> > ## KRIGING: autoKrige(YourMeasurements ~ YourExtractedElevationValues,
> YourMeasurementLocations, TargetGrid)
> > OK_snow <- autoKrige(Cumulata ~ rain_data$ExtractedElevationValues,
> rain_data, grd)
> > ------------------------------------------------------------
> -------------------------------------------------------------------
> >
> > The error I get is:
> > Error in autoKrige(Cumulata ~ rain_data$ExtractedElevationValues,
> rain_data,  :
> >   Either input_data or new_data is in LongLat, please reproject.
> >    input_data:  +init=epsg:4326 +proj=longlat +datum=WGS84 +no_defs
> +ellps=WGS84 +towgs84=0,0,0
> >    new_data:    +init=epsg:4326 +proj=longlat +datum=WGS84 +no_defs
> +ellps=WGS84 +towgs84=0,0,0
> >
> > but I did pay attention to have the same reference system in rain_data,
> drg and the Digital Elevation Model.
> >
> > Moreover, if I impose the class of the DEM to SpatialGridDataFrame when
> I extraxt the elevation points from the DEM I get the following error:
> > Error in (function (classes, fdef, mtable)  :
> >   unable to find an inherited method for function ‘extract’ for
> signature ‘"SpatialGridDataFrame", "SpatialPoints"’
> > Calls: extract -> <Anonymous>
> >
> >
> > Would you please somebody help to show me where is my mistake?
> >
> > Thank you for all your attention
> > Stefano
> >
> >          (oo)
> > --oOO--( )--OOo----------------
> > Stefano Sofia PhD
> > Area Meteorologica e  Area nivologica - Centro Funzionale
> > Servizio Protezione Civile - Regione Marche
> > Via del Colle Ameno 5
> > 60126 Torrette di Ancona, Ancona
> > Uff: 071 806 7743
> > E-mail: [hidden email]
> > ---Oo---------oO----------------
> > ________________________________________
> > Da: R-sig-Geo [[hidden email]] per conto di Daniel
> Knitter [[hidden email]]
> > Inviato: lunedì 12 febbraio 2018 9.16
> > A: [hidden email]
> > Oggetto: Re: [R-sig-Geo]  Interpolating snowfall values on a Digital
> Elevation Model
> >
> > ...sorry, I missed one step: you need to extract the elevation values to
> your points via extract function from the raster package:
> >
> > YourPoints$YourExtractedElevationValues <- extract(x = DEM, y =
> YourPoints)
> >
> > autoKrige(YourMeasurements ~ YourExtractedElevationValues,
> YourMeasurementLocations, TargetGrid)
> >
> >
> > Sorry for spamming.
> >
> > Best,
> > Daniel
> >
> > On Mon, 12 Feb 2018 08:03:41 +0000
> > Stefano Sofia <[hidden email]> wrote:
> >
> > > Dear list users,
> > > I have to produce rainfall maps. I know how to create a
> (bi-dimensional) grid and interpolate rainfall values (from automatic rain
> gauges) on that grid using Kriging:
> > >
> > > myinterpolation <- autoKrige(myrainfall_cumulate ~ 1, rain_data_UTM,
> mygrid)
> > >
> > > In reality I am dealing with snowfall values on mountain regions, and
> in this case altitude is an important factor, the use of a Digital
> Elevation Model might make the difference.
> > > Looking in the web I found some important material about accessing
> elevation data in R with the "elevatr" package (by J.W.Hollister), I am
> reading it.
> > > My concern would then be to interpolate snowfall values on a Digital
> Elevation Model. Did somebody already use R for these kinds of
> calculations? Could somebody share with me some useful hints?
> > >
> > > Thank you for your attention
> > > Stefano Sofia
> > >
> > >
> > >          (oo)
> > > --oOO--( )--OOo----------------
> > > Stefano Sofia PhD
> > > Area Meteorologica e  Area nivologica - Centro Funzionale
> > > Servizio Protezione Civile - Regione Marche
> > > Via del Colle Ameno 5
> > > 60126 Torrette di Ancona, Ancona
> > > Uff: 071 806 7743
> > > E-mail: [hidden email]
> > > ---Oo---------oO----------------
> > >
> > > ________________________________
> > >
> > > AVVISO IMPORTANTE: Questo messaggio di posta elettronica può contenere
> informazioni confidenziali, pertanto è destinato solo a persone autorizzate
> alla ricezione. I messaggi di posta elettronica per i client di Regione
> Marche possono contenere informazioni confidenziali e con privilegi legali.
> Se non si è il destinatario specificato, non leggere, copiare, inoltrare o
> archiviare questo messaggio. Se si è ricevuto questo messaggio per errore,
> inoltrarlo al mittente ed eliminarlo completamente dal sistema del proprio
> computer. Ai sensi dell’art. 6 della DGR n. 1394/2008 si segnala che, in
> caso di necessità ed urgenza, la risposta al presente messaggio di posta
> elettronica può essere visionata da persone estranee al destinatario.
> > > IMPORTANT NOTICE: This e-mail message is intended to be received only
> by persons entitled to receive the confidential information it may contain.
> E-mail messages to clients of Regione Marche may contain information that
> is confidential and legally privileged. Please do not read, copy, forward,
> or store this message unless you are an intended recipient of it. If you
> have received this message in error, please forward it to the sender and
> delete it completely from your computer system.
> > >
> > > --
> > > This message was scanned by Libra ESVA and is believed to be clean.
> > >
> > >
> > >       [[alternative HTML version deleted]]
> > >
> > > _______________________________________________
> > > R-sig-Geo mailing list
> > > [hidden email]
> > > <a href="https://urlsand.esvalabs.com/?u=https%3A%2F%2Fstat.ethz.ch%">https://urlsand.esvalabs.com/?u=https%3A%2F%2Fstat.ethz.ch%
> 2Fmailman%2Flistinfo%2Fr-sig-geo&e=52342f8a&h=f7d4a649&f=y&p=y
> >
> >
> > --
> >
> > Dr. Daniel Knitter
> > CRC1266 -- Scales of Transformation
> > Project A2 "Integrative Modeling of Socio-Environmental Dynamics"
> >
> > Christian-Albrechts-Universität zu Kiel
> > Department of Geography
> > Physical Geography -- Landscape Ecology and Geoinformation
> > Ludewig-Meyn-Str. 14, room 109
> > D - 24118 Kiel, Germany
> >
> > Phone: +49 431 880 2941
> > Email: [hidden email]
> >
> > ________________________________
> >
> > AVVISO IMPORTANTE: Questo messaggio di posta elettronica può contenere
> informazioni confidenziali, pertanto è destinato solo a persone autorizzate
> alla ricezione. I messaggi di posta elettronica per i client di Regione
> Marche possono contenere informazioni confidenziali e con privilegi legali.
> Se non si è il destinatario specificato, non leggere, copiare, inoltrare o
> archiviare questo messaggio. Se si è ricevuto questo messaggio per errore,
> inoltrarlo al mittente ed eliminarlo completamente dal sistema del proprio
> computer. Ai sensi dell’art. 6 della DGR n. 1394/2008 si segnala che, in
> caso di necessità ed urgenza, la risposta al presente messaggio di posta
> elettronica può essere visionata da persone estranee al destinatario.
> > IMPORTANT NOTICE: This e-mail message is intended to be received only by
> persons entitled to receive the confidential information it may contain.
> E-mail messages to clients of Regione Marche may contain information that
> is confidential and legally privileged. Please do not read, copy, forward,
> or store this message unless you are an intended recipient of it. If you
> have received this message in error, please forward it to the sender and
> delete it completely from your computer system.
> >
> > --
> > This message was scanned by Libra ESVA and is believed to be clean.
> >
>
>
> --
>
> Dr. Daniel Knitter
> CRC1266 -- Scales of Transformation
> Project A2 "Integrative Modeling of Socio-Environmental Dynamics"
>
> Christian-Albrechts-Universität zu Kiel
> Department of Geography
> Physical Geography -- Landscape Ecology and Geoinformation
> Ludewig-Meyn-Str. 14, room 109
> D - 24118 Kiel, Germany
>
> Phone: +49 431 880 2941
> Email: [hidden email]
>
> ________________________________
>
> AVVISO IMPORTANTE: Questo messaggio di posta elettronica può contenere
> informazioni confidenziali, pertanto è destinato solo a persone autorizzate
> alla ricezione. I messaggi di posta elettronica per i client di Regione
> Marche possono contenere informazioni confidenziali e con privilegi legali.
> Se non si è il destinatario specificato, non leggere, copiare, inoltrare o
> archiviare questo messaggio. Se si è ricevuto questo messaggio per errore,
> inoltrarlo al mittente ed eliminarlo completamente dal sistema del proprio
> computer. Ai sensi dell’art. 6 della DGR n. 1394/2008 si segnala che, in
> caso di necessità ed urgenza, la risposta al presente messaggio di posta
> elettronica può essere visionata da persone estranee al destinatario.
> IMPORTANT NOTICE: This e-mail message is intended to be received only by
> persons entitled to receive the confidential information it may contain.
> E-mail messages to clients of Regione Marche may contain information that
> is confidential and legally privileged. Please do not read, copy, forward,
> or store this message unless you are an intended recipient of it. If you
> have received this message in error, please forward it to the sender and
> delete it completely from your computer system.
>
> --
> This message was scanned by Libra ESVA and is believed to be clean.
>
> _______________________________________________
> R-sig-Geo mailing list
> [hidden email]
> https://stat.ethz.ch/mailman/listinfo/r-sig-geo
>



--
Dr. Biplab Biswas, 'Raman Fellow' (USA)
Associate Professor,
Department of Geography,
The University of Burdwan,
Burdwan - 713104
West Bengal, INDIA
http://www.buruniv.ac.in/
<http://www.buruniv.ac.in/>http://buruniv.academia.edu/BIPLABBISWAS

        [[alternative HTML version deleted]]

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