How data frame with latitude longitude and z value convert to grid for plot using level plot?

597 Views Asked by At

I have chlorophyll data obtained from netcdf and average to final output as follows.

head(cdata)
     lat    lon chl
1 24.875 30.125  NA
2 24.625 30.125  NA
3 24.375 30.125  NA
4 24.125 30.125  NA
5 23.875 30.125  NA
6 23.625 30.125  NA

i need to plot this with levelplot() but levelplot() need data in grid. how to convert data frame to grid or array?

1

There are 1 best solutions below

1
On BEST ANSWER

With the Lattice levelplot() command you can just pass a formula if your observations come from a "regular grid." So with your data, it would be

levelplot(chl ~ lat*lon, cdata)