2

I'm little bit worried, because of this:

satellite_buffered <- raster::extract(satellite_raster, hila_FI_WGS84, buffer=7000)

If buffer is in meters the code works, but if I use degrees, it won't. Using degrees I will get only one raster value to each point. Raster is 0.05 degree grid and originally point data is 10km*10km grid (metric projection ETRS-TM35FIN and after transformation to lat/lon it is not any more a regular grid)

Data structures:

str(satellite_raster) Formal class '.RasterFile' [package "raster"] with 13 slots

@ projargs: chr "+init=epsg:4326 +proj=longlat +datum=WGS84 +no_defs +ellps=WGS84 +towgs84=0,0,0"

and str(hila_FI_WGS84) Formal class 'SpatialPointsDataFrame' [package "sp"] with 5 slots

@ projargs: chr "+init=epsg:4326 +proj=longlat +datum=WGS84 +no_defs +ellps=WGS84 +towgs84=0,0,0"

1 Answer 1

4

If buffer is in meters the code works, but if I use degrees, it won't.

Indeed; the buffer cannot be specified in degrees. ?extract, buffer says: "If the data are not projected (latitude/longitude), the unit should be meters. Otherwise it should be in map-units (typically also meters)."

Do you really want the buffer to be in degrees?

Is so, temporarily set the CRS to UTM, do the extract, and set it back.

cr <- crs(r)
crs(r) <- '+proj=utm +zone=10 +datum=WGS84'
e <- extract(r, xy, buffer=0.5)
crs(r) <- cr

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.