rafaqz / Rasters.jl

Raster manipulation for the Julia language
MIT License
214 stars 36 forks source link

Error in `Makie.plot` of rotated raster #701

Open joshday opened 3 months ago

joshday commented 3 months ago

Plots.plot works, but Makie.plot produces an error.

Reproducing

using ArchGDAL, CoordinateTransformations, Rasters, GLMakie

path = "path/to/FARAD_X_BAND/20151027_1027X04_PS0010_PT000001_N03_M1_CH0_OSAPF.ntf"

r = Raster(path)

plot(r)
# ERROR: MethodError: no method matching order(::Rasters.AffineProjected{Int64, CoordinateTransformations.AffineMap{…}, Base.OneTo{…}, DimensionalData.Dimensions.Lookups.NoMetadata, WellKnownText{…}, Nothing, Base.OneTo{…}, X{…}})
joshday commented 2 months ago

As a temporary workaround, is there a way to remove the coordinate transformation?

rafaqz commented 2 months ago

Makie.heatmap(parent(raster)) !

But we do have the code for the rotation in the plots recipes, it should be too hard to hook up, it's just about time to do it when I don't ever need it.

rafaqz commented 2 months ago

Maybe set(A, X => No lookup, Y => NoLookup) is better to keep dim names.

On main of DD it's just set(A, NoLookup)

asinghvi17 commented 2 months ago

It could always decompose to matrix like lookups, I suppose...

Edit: did Rasters ever have those or am I completely misremembering??

rafaqz commented 2 months ago

No, I never wrote it. Transformed gets you half way.

But what would that give us for plotting that the affine transform function doesn't? Can we just use the affine transform directly in Makie to transform pixel coordinates in the hearmap?

asinghvi17 commented 2 months ago

Not really, unless you return a plotspec. Plus, I don't think it would play well with GeoMakie at all since affine transforms are applied after the nonlinear transform function...

Proj does have the capability to affine transform internally though, so maybe we could use that? It sounds fragile though.

rafaqz commented 2 months ago

Hmm. Making GeoMakie handle affine transforms seems important too. Or is a matrix easier?

asinghvi17 commented 1 month ago

Well Makie in general can't handle affine transforms before the transform_func, unless you explicitly compose the transform_func.

A general solution here would be a chained Proj pipeline + surface though.