I want to change the units of small raster files from degrees to meters using R. Is there any way to do this without projecting and hence altering the extent and shape of the rasters in the process? Or is there a projection that doesn't distort small areas at all?

I am aware that projections always distort the area of interest to some degree and that this is their desired property. However, my rasters are very small (less than 10x10 km) and have a very coarse resolution (ca. 300x300 pixels), and hence I would prefer to simply change my unit of measurement from degree to meters without altering the raster at all (and just accept that this causes some minor geographic inaccuracies)

I've tried both using the appropriate UTM zone or a Lambert Azimuthal Equal Area projection centered on my raster, but both projections slightly change the extent of the raster.

  • What issues are you having with distortion? Why would using a projection like Transverse Mercator not work for you? What is the issue with changing the extent? Thanks for the clarification.
    – Aaron
    Nov 21 '20 at 14:14
  • 1
    Projecting with UTM changes the extent of one of my rasters from 334x334 to 345x346, for example. This also results in a changed spatial configuration of some pixels (individual pixels are added or lost), which causes problems with the metrics that I am trying to calculate based on these pixels.
    – tAlbert
    Nov 21 '20 at 14:23
  • Why not reproject the larger raster data and retile? This should help with local resampling issues and help with consistency.
    – Aaron
    Nov 21 '20 at 15:16
  • The larger raster which serves as a template for the tiles contains important information of its own, so reprojecting it is not an option unfortunately
    – tAlbert
    Nov 21 '20 at 15:30
  • 1
    Without knowing what exactly you are doing, my intuition tells me that first you need to reproject from a geographic to a projected coordinate system. I would reevaluate your analysis if it breaks down when reprojecting and retiling data.
    – Aaron
    Nov 21 '20 at 16:24

In your description you do not provide a reason why you want to change the projection. The only valid reason in data analysis would be that you need to align raster data with some other raster data. That does not seem to be the case here (as you would not have to choose the projection). Can you explain why you want to project?

You do mention that you want to have meters, suggesting that the reason could be that you want to measure area. But you can do that with lon/lat raster data as well, see, e.g., raster::area. That could be the preferable approach if you are concerned, as you are, about data loss.

It would be helpful if you included a minimal, self-contained, reproducible example in your question (that is, create an example raster with code and show / state what you ultimately want to do with it).

Here is an approach to sum area by classes

r <- raster(ncol=20, nrow=10, vals=sample(4, 200, replace=TRUE))
a <- area(r) / 1000000
zonal(a, r, sum)
#     zone     value
#[1,]    1 129.01240
#[2,]    2 145.11511
#[3,]    3 136.19166
#[4,]    4  99.59283
  • I am using the package "landscapemetrics" to calculate various metrics. It requires the input data to be in meters because some metrics have area measurements as an outcome. The metrics I am primarily interested in depend on pixel counts, however, and therefore I do not want any distortions in the pixels
    – tAlbert
    Nov 22 '20 at 11:59
  • I have added an example that may be relevant. Nov 22 '20 at 22:07

Here is a way to get the results you want, but you should know that this will also have distortions (math says literally anything will), but it will at least have distortions that fulfill your requirements.

Using the HwB package,

distanceLong = haversine(long1, long2)
distanceLat = haversine(lat1, lat2)

where the locations are the lats/longs at the far edge of your raster. Now just enforce these distances as the edge lengths on either side of your raster (I'll let you figure that one out, but it probably involves dividing the distances by the number of cells and making that distance apply to each individual pixel).

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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