Skip to content

Commit

Permalink
Added Makie plotting extension. (#169)
Browse files Browse the repository at this point in the history
  • Loading branch information
evetion authored Dec 5, 2024
1 parent af463cb commit eafff43
Show file tree
Hide file tree
Showing 3 changed files with 39 additions and 10 deletions.
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,11 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

## [Unreleased]

## [0.9.1] - 2024-12-5

### Added
- Added Makie plotting extension for GeoArrays. Use `plot(ga)` to plot a GeoArray with Makie.

## [0.9.0] - 2024-06-11

### Changes
Expand Down
19 changes: 9 additions & 10 deletions Project.toml
Original file line number Diff line number Diff line change
@@ -1,16 +1,7 @@
name = "GeoArrays"
uuid = "2fb1d81b-e6a0-5fc5-82e6-8e06903437ab"
authors = ["Maarten Pronk <[email protected]>"]
version = "0.9.0"

[weakdeps]
GeoStatsBase = "323cb8eb-fbf6-51c0-afd0-f8fba70507b2"

[extensions]
# name of extension to the left
# extension dependencies required to load the extension to the right
# use a list for multiple extension dependencies
GeoArraysStatsExt = "GeoStatsBase"
version = "0.9.1"

[deps]
ArchGDAL = "c9ce4bd3-c3d5-55b8-8973-c0e20141b8c3"
Expand All @@ -24,6 +15,14 @@ PrecompileTools = "aea7be01-6a6a-4083-8856-8a6e6704d82a"
RecipesBase = "3cdcf5f2-1ef4-517c-9805-6587b60abb01"
StaticArrays = "90137ffa-7385-5640-81b9-e52037218182"

[weakdeps]
GeoStatsBase = "323cb8eb-fbf6-51c0-afd0-f8fba70507b2"
Makie = "ee78f7c6-11fb-53f2-987a-cfe4a2b5a57a"

[extensions]
GeoArraysMakieExt = "Makie"
GeoArraysStatsExt = "GeoStatsBase"

[compat]
ArchGDAL = "0.7 - 0.9, 0.10"
CoordinateTransformations = "0.5 - 0.6"
Expand Down
25 changes: 25 additions & 0 deletions ext/GeoArraysMakieExt.jl
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
module GeoArraysMakieExt
using GeoArrays
using Makie

Makie.plottype(raster::GeoArray) = Makie.Heatmap
Makie.used_attributes(::Type{Makie.Heatmap}, ::GeoArray) = (:band,)

function _convert(t, ga, band)
GeoArrays.is_rotated(ga) && (ga = GeoArrays.straighten(ga))

c = collect(GeoArrays.coords(ga, Vertex()))
x = map(first, c[:, 1])
y = map(last, c[end, :])
z = ndims(ga) == 2 ? parent(ga) : @view parent(ga)[:, :, band]
if eltype(z) <: Complex
@warn "Plotting real part of Complex GeoArray."
z = real.(z)
end
(x, y, z)
end

Makie.convert_arguments(t::Type{Heatmap}, x::Any, y::Any, ga::GeoArray; band=1) = _convert(t, ga, band)
Makie.convert_arguments(t::Type{Heatmap}, ga::GeoArray; band=1) = _convert(t, ga, band)

end

2 comments on commit eafff43

@evetion
Copy link
Owner Author

@evetion evetion commented on eafff43 Dec 5, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@JuliaRegistrator
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Registration pull request created: JuliaRegistries/General/120757

Tip: Release Notes

Did you know you can add release notes too? Just add markdown formatted text underneath the comment after the text
"Release notes:" and it will be added to the registry PR, and if TagBot is installed it will also be added to the
release that TagBot creates. i.e.

@JuliaRegistrator register

Release notes:

## Breaking changes

- blah

To add them here just re-invoke and the PR will be updated.

Tagging

After the above pull request is merged, it is recommended that a tag is created on this repository for the registered package version.

This will be done automatically if the Julia TagBot GitHub Action is installed, or can be done manually through the github interface, or via:

git tag -a v0.9.1 -m "<description of version>" eafff433a3cb71008ef0502de6a2ec3eb2d742bd
git push origin v0.9.1

Please sign in to comment.