Rasters.jl icon indicating copy to clipboard operation
Rasters.jl copied to clipboard

writing a Regular Intervals to netcdf produces Explicit Intervals

Open tiemvanderdeure opened this issue 2 months ago • 3 comments

Writing a Raster to a netcdf and reading it back in again yields a Raster with Explicit Intervals, even if the raster originally had Regular Intervals.

E.g.

using Rasters, NCDatasets
x = X(-50:1:50; sampling=Rasters.Intervals());
y = Y(-50:1:50; sampling=Rasters.Intervals());
ras = Raster(rand(x, y))
write("myraster.nc", ras; force = true)
ras_nc = Raster("myraster.nc")

This isn't always trivial. For example, rasterizing a polygon to ras works, but to ras_nc does not work.

using ArchGDAL
pointvec = [
    (-20.0, 30.0),
    (-20.0, 10.0),
    (0.0, 10.0),
    (0.0, 30.0),
    (-20.0, 30.0),
]
poly = ArchGDAL.createpolygon(pointvec)

rasterize(poly; to = ras, fill = true)
rasterize(poly; to = ras_nc, fill = true) # errors

tiemvanderdeure avatar Apr 11 '24 11:04 tiemvanderdeure