Home > Software engineering >  How can I make a upside down map in a right positon in R
How can I make a upside down map in a right positon in R

Time:10-13

Context

I am using terra::rast() to read a nc file and plot it.

But the ploted map is upside down.

When I used raster::raster() to read the nc file and plot it. The map is right.

Question

How can I make the upside down map right when using terra::rast() to read the nc?

Reproducible code

I have uploaded pm2.5_year_2013.ncdata on my github. The data can be found at enter image description here

CodePudding user response:

It looks like this was fixed in the development version of "terra" (or the version of GDAL that it uses on windows)

install.packages('terra', repos='https://rspatial.r-universe.dev')

And now it works as expected.

library(terra)
#terra 1.6.30
f <- "pm2.5_year_2011.nc"
r = rast(f)
plot(r)

enter image description here

  • Related