Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

CRS #222

Closed
tpoisot opened this issue Nov 24, 2023 · 2 comments
Closed

CRS #222

tpoisot opened this issue Nov 24, 2023 · 2 comments

Comments

@tpoisot
Copy link
Member

tpoisot commented Nov 24, 2023

using Revise

using CairoMakie
using Proj
using Distances

module ProjectedLayer

    mutable struct Layer{T}
        crs::String
        grid::Matrix{T}
        xlim::Tuple{Number,Number}
        ylim::Tuple{Number,Number}
        nodata::T
    end

    export Layer

end

using .ProjectedLayer

grd = rand(Float64, (50, 20))
nodata = 9999.
grd[2:20, 3:8] .= nodata
crs = "EPSG:4326"
ys = (53., 55.)
xs = (10., 14.)

lay = Layer(crs, grd, xs, ys, nodata)

x = LinRange(lay.xlim..., size(grd, 2))
y = LinRange(lay.ylim..., size(grd, 1))

trf = Proj.Transformation(lay.crs, "+proj=utm +zone=32 +datum=WGS84")

f = Figure()
ax = Axis(f[1,1])
for i in axes(lay.grid, 2), j in axes(lay.grid, 1)
    if !isequal(lay.nodata)(lay.grid[j,i])
        scatter!(ax, trf(y[j], x[i]), color=lay.grid[j,i], colorrange=(0.,1.), colormap=:Spectral)
    end
end
current_figure()
@asinghvi17
Copy link

Have you considered using Rasters.jl for this?

@tpoisot
Copy link
Member Author

tpoisot commented Apr 15, 2024

Yes! But we won't. There's a new release in prep that works with any CRS natively.

@tpoisot tpoisot closed this as completed Apr 15, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
Development

No branches or pull requests

2 participants