Hi
Sorry for the complicated example, but I'm really stuck:
I am trying to merge two rasters/datasets: one for the continental USA and one
for Mexico. The dataset for Mexico was initially derived from a larger raster
of North America that was at the same extent, resolution etc. as the US
raster...all in an equal area projection (so the Mexico raster simply had NA
values for the US and vice versa).
For purposes of populating the Mexico layer with appropriate cell values (using
a separate program), I needed to convert the Mexico layer to points, reproject
the points to WGS84 and feed those points into a separate program using the
following:
m<-as.data.frame(mexico,xy=TRUE)
m_noNA<-na.omit(m)
# reproject to WGS84, feed resulting points into external program (climateSA)...
My data frame output from the external program includes x and y coordinates for
each cell based on the original equal area projection as well as cell values
for the variable of interest. I can either leave this output as a data frame OR
convert it to an ascii grid using:
library(SDMTools)
dataframe2asc(myTable)
But this asci will have a different extent from the original mexico layer
because I had to remove the NA values from the data frame (no way to avoid
this). So now I'm trying to figure out how to either:
1) merge/mosaic two rasters with different extents and NO overlap (e.g. the US
raster has NA values in Mexico and the Mexico raster [of a different extent]
has NA values for the US...). In this case, I don't know how to get merge to
produce a raster with cell values for BOTH the US and Mexico (I always end up
with NA values in one region or the other). And similarly with mosaic, I don't
know what function to use ...there shouldn't be overlap between there rasters
and if there is by chance, I would want to populate the resulting raster with
the values from the US (not the mean, min, etc.)
or
2) For the US raster, replace NA values that overlap with Mexico with the
values in myTable based on the x y co-ordinates...I haven't been able to figure
out this type of indexing/ look-up yet...
Any help would be greatly greatly appreciated!
Thanks
Julie
[[alternative HTML version deleted]]
_______________________________________________
R-sig-Geo mailing list
[email protected]
https://stat.ethz.ch/mailman/listinfo/r-sig-geo