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

Update plot_map function for simple map plots using leaflet and mapview #291

Merged
merged 8 commits into from
Dec 19, 2023

Conversation

gareth-j
Copy link
Contributor

@gareth-j gareth-j commented Dec 7, 2023

  • Summary of changes (Bug fix, feature, docs update, ...)

This adds a new backend package to plot_map function which uses mapview to plot raster and spatial data on a map. It allows very little customisation but is often more forgiving of data. plot_map by default with use leaflet and and still contains all the customisation features. The backend package can be selected using backend="leaflet" or backend="mapview".

  • Please check if the PR fulfills these requirements

Copy link
Contributor

@aabelean aabelean left a comment

Choose a reason for hiding this comment

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

Looks really nice, @gareth-j. Pity plot_map_mapview doesn't plot filled polygons as the leaflet version. It did work for all my rasters except those rasters created by terra::rasterize as it gave an error like

Error in loadNamespace(x) : there is no package called ‘stars’

A work-around is to apply raster::raster, which makes it work without issues. plot_map_leaflet worked just fine without this step.

@gareth-j
Copy link
Contributor Author

gareth-j commented Dec 18, 2023

Looks really nice, @gareth-j. Pity plot_map_mapview doesn't plot filled polygons as the leaflet version. It did work for all my rasters except those rasters created by terra::rasterize as it gave an error like

Error in loadNamespace(x) : there is no package called ‘stars’

A work-around is to apply raster::raster, which makes it work without issues. plot_map_leaflet worked just fine without this step.

Ah excellent, thanks for taking a look. I've just updated this PR to use the backend = "leaflet" argument by default and allow users to just use plot_map(...) to plot normal leaflet maps. If they want to use mapview they can pass "mapview". I thought it made it a bit tider.

@gareth-j gareth-j changed the title Add new plot_map_mapview function for simple map plots Update plot_map function for simple map plots using leaflet and mapview Dec 18, 2023
@gareth-j gareth-j self-assigned this Dec 18, 2023
@gareth-j gareth-j merged commit 4ea070e into devel Dec 19, 2023
2 checks passed
@gareth-j gareth-j mentioned this pull request Dec 19, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Raster layer doesn't show in plot_map()
2 participants