[R-sig-Geo] Best practices for transforming raster data without altering values
Michael Sumner
mdsumner at gmail.com
Wed Jan 11 01:39:15 CET 2017
I would avoid raster reprojection (warping) here, you can do everything you
need by extraction by, as you say, transforming the vector data to it.
This can be both more exacting without lossy sampling/aggregation, and much
more efficient.
But, it's a little abstract, has some key tricks required for efficiency
and for dealing with *likely* topological limitations in reshaping. Also
the best way to do always depends on specific details about your data and
the desired result. I tend to use polar layers over large regions, so the
common workflows break down pretty quickly and these more abstract tricks
are better.
I would start by making a vector layer that has the final structures in the
coordinate system you want for your model, then decide what's best for
summarizing pixels into those.
If you just want a picture, then I would warp the raster - no problem,
you'll want to think about the target resolution, how the thing gets split
over the longitude boundary and rejoined, and the details of the resampling
(e.g. bilinear, nearest neighbour, or more intensively *explicit
aggregation* or focal/kernel operations). GDAL is generally more suited to
controlling all this, but raster is easier to use of course.
All those warping details also are relevant and can inform how the vector
extraction gets done too, but from a slightly different perspective.
If you can provide a reproducible example of the raster and the vector
layer it's easiest to answer more questions.
Cheers, Mike.
On Mon, 9 Jan 2017 at 07:01 Valentin Stefan via R-sig-Geo <
r-sig-geo at r-project.org> wrote:
> Dear all,
> I have several global rasters from http://worldclim.org/ and I want to
> project them in a equal area projection shifted on Pacific.A sample code
> is:bio_1.WGS84.global <- raster("bio_1.bil")
> # I use World Cylindrical Equal Area (CEA)crs.cea <- "+proj=cea +lon_0=180
> +lat_ts=0 +x_0=0 +y_0=0 +ellps=WGS84 +datum=WGS84 +units=m
> +no_defs"bio_1.1km <- projectRaster(from=bio_1.WGS84.global, res=1000,
> method='bilinear', crs = crs.cea)
> I came across the very helpful page maintained by Robert Hijmans at
> http://rspatial.org/spatial/rst/6-crs.html#transforming-raster-data ,where
> he mentions that "Because projection of rasters affects the cells values,
> in most cases you will want to avoid projecting raster data and rather
> project vector data."
> So, I know that the new (projected) cell values have been altered. There
> are not huge differences, nevertheless, is there a "good practice" to avoid
> changes in data while transforming a raster?
> I presume I can't work on unprojected data and I should use a equal area
> projection as I need to further aggregate the rasters at various
> resolutions (e.g. 5, 10, 20 km) and extract some cell statistics at given
> points across the Pacific.
> Kind regards,Valentin Stefan
>
>
>
> [[alternative HTML version deleted]]
>
> _______________________________________________
> R-sig-Geo mailing list
> R-sig-Geo at r-project.org
> https://stat.ethz.ch/mailman/listinfo/r-sig-geo
--
Dr. Michael Sumner
Software and Database Engineer
Australian Antarctic Division
203 Channel Highway
Kingston Tasmania 7050 Australia
[[alternative HTML version deleted]]
More information about the R-sig-Geo
mailing list