I have a datset, which is
dat<-matrix(seq(1:5290),c(115,46))
- How can I convert
datto a raster file with GIS – related metadata such as map projection? -
and then how to map the data to a us map with
lon <- seq(-124.25,length=115,by=0.5) lat <- seq(26.25,length=46,by=0.5) -
what should I do if I want to calculate the mean of each state? or specific region?
thanks very much for your feedback.
D
You could try the following:
Create a raster with your desired extent
and plot it
take the mean over the whole raster
mean over a region
Extract from polygons
You need a SpatialPolygonsDataFrame. Here I am creating a dummy one with
readWKT()but you could also read a shapefile withreadShapePoly()from themaptoolspackage.And extract the mean: