[R-sig-Geo] questions on spatial interpolation exercise(NL)

Tomislav Hengl hengl at spatial-analyst.net
Mon Nov 24 19:24:34 CET 2014


You need to provide access to "monv_201310.txt" so that we can see what 
is the structure of that file. The original file with rainfall data from 
that URL is simply a text file from the KNMI website (without any 
tabular structure) so that e.g.:

...
write.table(t(matrix(unlist(strsplit(tmp, ",")[-c(1:8)]), nrow=41)), 
"tmp.txt", col.names=FALSE, row.names=FALSE)
...
monv_200906 <- read.table("tmp.txt", col.names=c("empty1", "NR", 
paste("D", 1:30, sep=""), "I", "NORM", "II", "NORM", "III", "NORM", 
"MND", "NORM", "Locatie"))

creates structure based on what is in the text object (hence I first 
open the text file and then figure out the code to read the values). Of 
course, the structure of the raw KNMI files could have changed from 2009.

If you are planning to interpolate monthly rainfall data take also a 
look at the two geostatistical packages that elaborate geostatistics 
with skewed values / variables with skewed distributions (I have not 
updated the 
http://spatial-analyst.net/wiki/index.php?title=Spatial_interpolation_exercises_(NL) 
pages for a long time; sorry for that):

http://cran.r-project.org/package=georob
http://cran.r-project.org/package=geostatsp
described in -> http://pbrown.ca/geostatsp/document-rev.pdf

HTH,

T. Hengl

On 23-11-2014 23:51, Mengxi Yang wrote:
> Dear list,
> I have a question on write.table. I found an nice exercise on spatial
> interpolation from
> http://spatial-analyst.net/wiki/index.php?title=Spatial_interpolation_exercises_(NL)#Spatial_prediction_of_daily_precipitation_in_the_Netherlands
>
> In this exercise, the date is 200906. but when I change to 201310. there is
> a wrong message like:
>
>> tmp <- readLines(paste(getwd(), "/", "monv_201310.txt", sep=""))
>> tmp <- gsub(pattern=' . ', replacement=' 0.0 ', tmp, fixed = TRUE)
>> tmp <- gsub(pattern='[[:space:]]{2,7}', replacement=',', tmp)
>> write.table(t(matrix(unlist(strsplit(tmp, ",")[-c(1:8)]), nrow=41)),
> "tmp.txt", col.names=FALSE, row.names=FALSE)
> Warning message:
> In matrix(unlist(strsplit(tmp, ",")[-c(1:8)]), nrow = 41) :
>    data length [13625] is not a sub-multiple or multiple of the number of
> rows [41]
>
>
> I checked several month, some success but some not.
> Does anyone know what is the wrong with it? should I change something?
>
> Thank you very much.
>
> Mengxi Yang
>
> 	[[alternative HTML version deleted]]
>
> _______________________________________________
> R-sig-Geo mailing list
> R-sig-Geo at r-project.org
> https://stat.ethz.ch/mailman/listinfo/r-sig-geo
>



More information about the R-sig-Geo mailing list