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

API for geoplots with GeoMakie.jl and docs #93

Closed
wants to merge 35 commits into from
Closed
Show file tree
Hide file tree
Changes from 33 commits
Commits
Show all changes
35 commits
Select commit Hold shift + click to select a range
386c7ac
added working examples for latest GeoMakie version
lazarusA Aug 25, 2021
c62df09
added working examples latest version
lazarusA Aug 25, 2021
fd4af96
Merge remote-tracking branch 'origin/examples' into examples
lazarusA Aug 25, 2021
97f6797
delete unecessary files
Datseris Oct 29, 2021
cc24e38
correct dependencies
Datseris Oct 29, 2021
c9077f8
Merge branch 'master' into runnable_docs
Datseris Oct 29, 2021
e87718e
add API functions so that user doesn't mess with transforms
Datseris Oct 29, 2021
449717b
add Proj4 to the stuff
Datseris Oct 29, 2021
23d9135
first deaft of geoplotting API
Datseris Oct 29, 2021
52386bd
working API + 1 example code
Datseris Oct 29, 2021
3826c2e
declare API
Datseris Oct 29, 2021
e3c1f8e
finish example
Datseris Oct 29, 2021
14b0734
remove previous eamples
Datseris Oct 29, 2021
3bd811d
working GeoAxis
Datseris Oct 29, 2021
3a93cb0
add gridlines
Datseris Oct 29, 2021
a89016f
fix limit setting
Datseris Oct 29, 2021
321b5af
allow user tunable ticks
Datseris Oct 29, 2021
d8a4e75
add example in the docstring
Datseris Oct 29, 2021
7bc4774
use translate, add better comments
Datseris Nov 16, 2021
0df27c7
improve source string
Datseris Nov 16, 2021
1593567
push current work on the docs (still WIP)
Datseris Nov 16, 2021
0f3092c
remove submarine example
Datseris Nov 16, 2021
4f39905
buildable docs
Datseris Nov 16, 2021
821a82a
add documentation build phase to CI
Datseris Nov 16, 2021
8b2efae
change readme, up version to 0.3
Datseris Nov 18, 2021
556a13c
add tests
Datseris Nov 18, 2021
02e0515
rename source file for clarity
Datseris Nov 18, 2021
edb5753
link lon_0 secdtion
Datseris Nov 18, 2021
6b89b1f
good docs = done
Datseris Nov 18, 2021
369ef61
add level 3 collapse for sidebar
Datseris Nov 18, 2021
22fa839
mention that lon/lat are always in degrees
Datseris Nov 18, 2021
fd2cba2
mention how coastlines are plotted
Datseris Nov 18, 2021
6616258
propagate kw into `Axis`
Datseris Nov 19, 2021
b79bdda
Apply suggestions from code review
Datseris Dec 15, 2021
71b0abe
mention coastline plot
Datseris Dec 15, 2021
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
55 changes: 43 additions & 12 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,21 +9,26 @@ on:
tags: '*'
jobs:
test:
name: Julia ${{ matrix.version }} - ${{ matrix.os }} - ${{ matrix.arch }} - ${{ github.event_name }}
name: Tests, Julia ${{ matrix.version }} - ${{ matrix.os }} - ${{ matrix.arch }} - ${{ github.event_name }}
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
version:
- '1' # Leave this line unchanged. '1' will automatically expand to the latest stable 1.x release of Julia.
- 'nightly'
os:
- ubuntu-latest
- '1' # Replace this with the minimum Julia version that your package supports. E.g. if your package requires Julia 1.5 or higher, change this to '1.5'.
os: [ubuntu-latest, windows-latest, macos-latest] # adjust according to need, e.g. os: [ubuntu-latest] if testing only on linux
arch:
- x64
steps:
- name: Checkout
uses: actions/checkout@v2
# Cancel ongoing CI test runs if pushing to branch again before the previous tests
# have finished
- name: Cancel ongoing test runs for previous commits
uses: styfle/[email protected]
with:
access_token: ${{ github.token }}

# Do tests
- uses: actions/checkout@v2
- uses: julia-actions/setup-julia@v1
with:
version: ${{ matrix.version }}
Expand All @@ -38,9 +43,35 @@ jobs:
${{ runner.os }}-test-${{ env.cache-name }}-
${{ runner.os }}-test-
${{ runner.os }}-
- run: sudo apt-get update && sudo apt-get install -y xorg-dev mesa-utils xvfb libgl1 freeglut3-dev libxrandr-dev libxinerama-dev libxcursor-dev libxi-dev libxext-dev
- run: DISPLAY=:0 xvfb-run -s '-screen 0 1024x768x24' julia --project=@. -e 'using Pkg; Pkg.build(); Pkg.test(coverage=true)'
- uses: julia-actions/julia-processcoverage@v1
- uses: codecov/codecov-action@v1
- uses: julia-actions/julia-buildpkg@v1
- uses: julia-actions/julia-runtest@v1


docs:
name: Documentation
runs-on: ubuntu-latest
steps:
# Cancel ongoing documentation build if pushing to branch again before the previous
# build is finished.
- name: Cancel ongoing documentation builds for previous commits
uses: styfle/[email protected]
with:
access_token: ${{ github.token }}

# Build docs
- uses: actions/checkout@v2
- uses: julia-actions/setup-julia@v1
with:
file: lcov.info
version: '1'
- name: Instantiate and install dependencies
run: |
julia --project=docs -e '
using Pkg
Pkg.develop(PackageSpec(path=pwd()))
Pkg.instantiate()'
- name: Generate documentation and deploy
env: # needed for pushing to gh-pages branch
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
DOCUMENTER_KEY: ${{ secrets.DOCUMENTER_KEY }}
run:
julia --project=docs docs/make.jl
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -7,3 +7,4 @@
/docs/build/
/docs/site/
stuff.jl
.vscode
12 changes: 5 additions & 7 deletions Project.toml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
name = "GeoMakie"
uuid = "db073c08-6b98-4ee5-b6a4-5efafb3259c6"
authors = ["Anshul Singhvi"]
version = "0.2.2"
authors = ["Makie.jl Contributors"]
version = "0.3.0"

[deps]
Colors = "5ae59095-9a9b-59fe-a467-6f913c188581"
Expand All @@ -10,6 +10,7 @@ GeoJSON = "61d90e0f-e114-555e-ac52-39dfb47a3ef9"
GeometryBasics = "5c1252a2-5f33-56bf-86c9-59e7332b4326"
ImageMagick = "6218d12a-5da1-5696-b52f-db25d2ecc6d1"
Makie = "ee78f7c6-11fb-53f2-987a-cfe4a2b5a57a"
Proj4 = "9a7e659c-8ee8-5706-894e-f68f43bc57ea"
Reexport = "189a3867-3050-52da-a836-e630ba90ab69"
StructArrays = "09ab397b-f2b6-538f-b94a-2f83cf4a842a"

Expand All @@ -20,15 +21,12 @@ GeoJSON = "0.5"
GeometryBasics = "0.4.1"
ImageMagick = "1"
Makie = "0.15.2"
Reexport = "0.2, 1.0"
Reexport = "1"
StructArrays = "0.4, 0.5, 0.6"
julia = "1"

[extras]
CairoMakie = "13f3f980-e62b-5c42-98c6-ff1f3baf88f0"
Downloads = "f43a241f-c20a-4ad4-852c-f6b1247861c6"
Proj4 = "9a7e659c-8ee8-5706-894e-f68f43bc57ea"
Test = "8dfed614-e22c-5e08-85e1-65c5234f0b40"

[targets]
test = ["Test", "Downloads", "CairoMakie", "Proj4"]
test = ["Test"]
83 changes: 2 additions & 81 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# GeoMakie
## Geographic plotting utilities for <a href = "https://www.github.com/JuliaPlots/Makie.jl"><img src="https://raw.githubusercontent.com/JuliaPlots/Makie.jl/master/assets/logo.png" alt="Makie.jl" height="30" align = "top"></a>
## Geographic plotting utilities for Makie.jl <a href = "https://www.github.com/JuliaPlots/Makie.jl"><img src="https://raw.githubusercontent.com/JuliaPlots/Makie.jl/master/assets/logo.png" alt="Makie.jl" height="30" align = "top"></a>

[![Stable](https://img.shields.io/badge/docs-stable-blue.svg)](https://JuliaPlots.github.io/GeoMakie.jl/stable)
[![Dev](https://img.shields.io/badge/docs-dev-blue.svg)](https://JuliaPlots.github.io/GeoMakie.jl/dev)
Expand All @@ -12,83 +12,4 @@ This package is **in development** and will **break often**. You can install it
]add GeoMakie
```

## Examples

```julia
using GLMakie
using GeoMakie
using GeoMakie.GeoInterface
using GeoMakie.GeoJSON
using Downloads
using Proj4

begin
# select a coordinate projection, using a string that PROJ accepts
# see e.g. https://proj.org/operations/projections/index.html
source = "+proj=longlat +datum=WGS84"
dest = "+proj=natearth2"
trans = Proj4.Transformation(source, dest, always_xy=true)
ptrans = Makie.PointTrans{2}(trans)

fig = Figure()
ax = Axis(fig[1,1], aspect = DataAspect())

# all input data coordinates are projected using this function
ax.scene.transformation.transform_func[] = ptrans

# draw projected grid lines and set limits accordingly
lats = -90:10.0:90
lons = -180:10.0:180
lons = collect(lons)
lons[end] = prevfloat(lons[end]) # avoid PROJ wrapping 180 to -180
field = [exp(cosd(l)) + 3(y/90) for l in lons, y in lats]
points = map(CartesianIndices(size(field))) do xy
x, y = Tuple(xy)
Point2f(lons[x], lats[y])
end
limits = Rect2f(Makie.apply_transform(ptrans, points))
limits!(ax, limits)
wireframe!(ax, lons, lats, field, color=(:gray, 0.2), transparency=true)

# add black polygons for land area
url = "https://raw.githubusercontent.com/nvkelso/natural-earth-vector/master/geojson/"
land = Downloads.download(url * "ne_110m_land.geojson", IOBuffer())
land_geo = GeoJSON.read(seekstart(land))
poly!(ax, land_geo, color="black")

# add grey dots for populated places
pop = Downloads.download(url * "ne_10m_populated_places_simple.geojson", IOBuffer())
pop_geo = GeoJSON.read(seekstart(pop))
scatter!(ax, GeoMakie.geo2basic(pop_geo), color="lightgrey", markersize=1.2)

hidedecorations!(ax)
hidespines!(ax)
display(fig)
end
```
![image](https://user-images.githubusercontent.com/4471859/123510397-8116ab00-d67b-11eb-8414-cffd18d60f05.png)

These plots can be arbitrarily colored using the `color` keyword, and the full Makie interface is also exposed.

Check the examples in the `test` folder for more recent examples of usage.

## Performance

We use Earcut.jl for added performance when converting polygons to triangular meshes; it decreases time to mesh by an order of magnitude from the Makie implementation.

Since `surface` has an optimized shader, and can accept matrices of deformed grid points, it's **heavily** recommended to use it (or `mesh` if you need the flexibility) over `poly`.

## Planned features
- A `choropleth` recipe which can read data from the properties of a FeatureCollection
- helper functions to extract "columns" of a FeatureCollection

## More examples
```julia
using GeoJSON, GeoMakie, Makie
states = download("https://raw.githubusercontent.com/PublicaMundi/MappingAPI/master/data/geojson/us-states.json")

states_geo = GeoJSON.parse(read(states, String))

poly(states_geo, strokecolor = :blue, strokewidth = 1)
```
![US simple example](https://user-images.githubusercontent.com/32143268/73116030-c6223500-3efd-11ea-9690-f5a92415c264.png)
Please see the documentation for examples and basic usage.
Loading