Skip to content

Rasters.create does not respect Extent #1031

@tiemvanderdeure

Description

@tiemvanderdeure

Passing extent and res to Rasters.create results in a raster with a different extent that what was passed in:

julia> ras = Rasters.create(                                                                                             
           Float64, Extent(X=(-180, 180), Y=(-90, 90));                                                                  
           res = 1/12, sampling=(X=Intervals(Start()), Y=Intervals(Start()))
       )
┌ 4321×2161 Raster{Float64, 2} ┐
├──────────────────────────────┴──────────────────────────────────────────────────────────── dims ┐
  ↓ X Sampled{Float64} -180.0:0.08333333333333333:180.0 ForwardOrdered Regular Intervals{Start},
  → Y Sampled{Float64} -90.0:0.08333333333333333:90.0 ForwardOrdered Regular Intervals{Start}
├───────────────────────────────────────────────────────────────────────────────────────── raster ┤
  extent: Extent(X = (-180.0, 180.08333333333334), Y = (-90.0, 90.08333333333333))
└─────────────────────────────────────────────────────────────────────────────────────────────────┘
    ↓ →    -90.0  -89.9167  -89.8333  -89.75  -89.6667  …  89.5  89.5833  89.6667  89.75  89.8333  89.9167  90.0
 -180.0      0.0    0.0       0.0       0.0     0.0         0.0   0.0      0.0      0.0    0.0      0.0      0.0
 -179.917    0.0    0.0       0.0       0.0     0.0         0.0   0.0      0.0      0.0    0.0      0.0      0.0
 -179.833    0.0    0.0       0.0       0.0     0.0         0.0   0.0      0.0      0.0    0.0      0.0      0.0
    ⋮                                           ⋮       ⋱   ⋮                                       ⋮
  179.75     0.0    0.0       0.0       0.0     0.0         0.0   0.0      0.0      0.0    0.0      0.0      0.0
  179.833    0.0    0.0       0.0       0.0     0.0         0.0   0.0      0.0      0.0    0.0      0.0      0.0
  179.917    0.0    0.0       0.0       0.0     0.0     …   0.0   0.0      0.0      0.0    0.0      0.0      0.0
  180.0      0.0    0.0       0.0       0.0     0.0         0.0   0.0      0.0      0.0    0.0      0.0      0.0

julia> extent(ras)
Extent(X = (-180.0, 180.08333333333334), Y = (-90.0, 90.08333333333333))

This is similar to #913 - maybe we can reuse some of the internals from #914

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions