I’m trying to make a map with JunJius code but I have a problem when reading my data and building the matrix.

x<-seq(-83.2,-68.1, 0.1)#lon

y<-seq(-58.6, -4.1, 0.1)#lat

My z values are obtained by reading an ASCII file and when introducing them to build the matrix I get "Numeric,546". If I read the data I can see the data set but when building the matrix I'm finding it impossible. I have tried the as.matrix, as.numeric and other functions but…

Any suggestions?

Thanks in advance

But it does make it awesome!

]]>R can be similarly terse/opaque if you want to code that way. Granted, I think you need ggplot2 to implement opacity (I could be wrong), but I’d say that a single (free) external package install isn’t all that daunting. Otherwise, have fun with your $140-$2500 and closed-source Mathmatica!

]]>

data = Rest@Import["http://www.decisionsciencenews.com/wp-content/uploads/2010/07/latlong.zip", "latlong.csv"];

```
```

`ListPlot[data, PlotRange -> {{-130, -65}, {23.5, 50.5}}, Frame -> True, PlotStyle -> Opacity[0.5]]`

That’s two lines, including downloading, unzipping, and parsing the data. And no libraries! Take that, R!

]]>x<-seq(29,36,2.8)#lon

y<-seq(-4,6,2.5)#lat

z<-matrix(runif(length(x)*length(y)),length(x),length(y))# my original matrix

par(mfrow=c(2,2))

image(x,y,z,col=cm.colors(20))# plots the data as is

#Using Interpolation with Akima Interp

library(akima)

xd<-seq(29,36,1)# new lon

yd<-seq(-4,6,1) # new lat

old.kords<-expand.grid(x,y)

zd<-interp(old.kords[,1],old.kords[,2],c(z),xd,yd)

image(xd,yd,zd$z,col=cm.colors(20))# shows that interpolation has distorted the spatial pattern. What i want is similar pattern but with finer grid. Interp clearly cannot do this.

# so how do i resample without changing the pattern.

]]>can anyone help me please ]]>

I have data in a matrix with longitude (x coordinates) regularly spaced at 2.8 degrees and lat (y coordinates) at 2.5 degrees. x<-seq(29,36,2.8) & y<-seq(-4,6,2.5)

My matrix is 26 rows *28 e.g. z<-matrix(runif(26*28),26,28). I want to Resample this matrix to a different resolution of 0.5 * 0.5 in R without using interpolation (e.g inter in Akima package) because this distorts the data i.e. The data should not vary smoothly in space. What I want is analogous to resample in a GIS withoout smoothing, something like assigning the new pixel with the average or maximum of the contents in the pixel location.

]]>