Dear R-sig-geo list users, given n meteorological automatic stations with rain gouge, I need to produce an image with the isohyets of the rainfall values of my region (Italy, Marche region, on the Adriatic Sea in front of Croatia). For each station the available coordinates are in Gauss Boaga, Long and Lat in degrees, minutes and seconds and Long and Lat in degrees and decimals. In the code below reported Long and Lat in degrees and decimals have been used.
This is an example of the input file called in the code "pointfile.csv": Station_code, Rainfall_value, GaussBoaga_EST, GaussBoaga_NORD, Long_degrees, Long_minutes, Long_seconds, Lat_degrees, Lat_minutes, Lat_seconds, Long_Cent, Lat_Cent 1056, 11.8, 2328427, 4851813, 12, 37, 7.45291, 43, 47, 40.09906, 12.618737, 43.794472 The code below reported (with the precious support of Micha Silver) does compile, but the final image reports some numerical values (isohjet_map.png). Would please somebody be able and help me to see where the code can be improved? Thank you for your help Stefano Code: library(automap) library(ggplot2) library(gstat) library(rasterVis) library(rgdal) ## READ INPUT FILE rain_data <- read.csv(file="pointfile.csv") str(rain_data) point_coords <- rain_data[c("Long_Cent","Lat_Cent")] coordinates(rain_data) <- point_coords p4str <- CRS("+init=epsg:4326") proj4string(rain_data) <- p4str ## CONVERTION TO UTM p4str_UTM <- CRS("+init=epsg:32633") rain_data_UTM <- spTransform(rain_data, p4str_UTM) ## CHECK THAT THIS IS A SPDF IN THE UTM COORDINATE SYSTEM str(rain_data_UTM) ## CREATE GRID FOR KRIGING OUTPUT, USING THE EXTENT OF THE RAIN DATA SPDF minx <- rain_data_UTM@bbox[1,1] maxx <- rain_data_UTM@bbox[1,2] miny <- rain_data_UTM@bbox[2,1] maxy <- rain_data_UTM@bbox[2,2] ## EACH PIXEL WILL BE 1000 METERS pixel <- 1000 grd <- expand.grid(x=seq(minx, maxx, by=pixel), y=seq(miny, maxy, by=pixel)) coordinates(grd) <- ~x+y gridded(grd) <- TRUE proj4string(grd) <- p4str_UTM ## KRIGING, USING AUTOKRIGE WHICH CREATES A BEST GUESS VARIOGRAM OK_rain <- autoKrige(Rainfall_value ~ 1, rain_data_UTM, grd) ## TRASFORM TO RASTER rain_rast <- raster(OK_rain$krige_output) ## READ THE MARCHE BOUNDARY SHAPEFILE Marche_shape <- readOGR(dsn="Lim_reg_2012_wgs32633.shp", layer="Lim_reg_2012_wgs32633") ##PLOT png(file="isohyet_map.png") gplot(rain_rast) + geom_tile(aes(fill=factor(value),alpha=0.8)) + geom_polygon(data=Marche_shape, aes(x=long, y=lat, group=group), fill=NA, color="grey50", size=1) + coord_equal() dev.off() (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: stefano.so...@regione.marche.it ---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.
<<attachment: winmail.dat>>
_______________________________________________ R-sig-Geo mailing list R-sig-Geo@r-project.org https://stat.ethz.ch/mailman/listinfo/r-sig-geo