Amen
2012-Apr-25 18:14 UTC
[R] locate values to their positions based on their pixel and line in other files
I have 3 files A ,B ,C as binary files. C represents the values of tepm measured every 3 hours for one month so it has 674200 columns and 248 rows.values of A represent the correspond lines(these values could be within 1to360) and , while values of B represent the correspond pixel(1to720) for each point in file C(so both they have 1 row and 67420rows).Now I will create a new matrix ,M ,which has this dim(360,720).for example the first value in C it will be represented in the creatd matrix based on the corspding pixl and lines.assume the first value is 54(row 1 and column 1)in C so in order to locate it in my new matrix we need to know what its pixl and line that this point shoud be assocated with ,therfore I need to tell R that take its pixl value from A and its line from B and locate it in my new matrix. this is to be done for first row out of 248 rows and write it to new file then do the same for the second row and write to a new file and so on for all 248 rows. library(Matrix) M <- Matrix(-9999, 360, 720)## creat matrix with 720 columns and 360 rows with valus of -9999 long <- file("C:\\New folder (5)\\inra.bin", "rb") A=readBin(long, integer(), size=2,n=1*67420, signed=TRUE) lot <- file("C:\\New folder (5)\\lat.img", "rb") B=readBin(lot, integer(), size=2,n=1*67420, signed=TRUE) for (i in c(1:67420)) { wind <- file("C:\\Wind_WFD_200201.bin", "rb") C=readBin(wind, integer(), size=2,n=248*67420, signed=TRUE)##it has 67420 columns and 248 rows M(A(i),B(i))= C(i)} I wrote the above code but didn't work.I am so sorry for this long description and thanks in advance -- View this message in context: http://r.789695.n4.nabble.com/locate-values-to-their-positions-based-on-their-pixel-and-line-in-other-files-tp4587563p4587563.html Sent from the R help mailing list archive at Nabble.com.