-
Notifications
You must be signed in to change notification settings - Fork 91
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
Mapview support for COGs #400
Comments
Servus, |
I tried as follows... not sure if the call is correct though. It gives me an empty map only showing the open street map base layer. url = "/vsicurl/http://s3.eu-central-1.wasabisys.com/eumap/lcv/lcv_landcover.hcl_lucas.corine.rf_p_30m_0..0cm_2019_eumap_epsg3035_v0.1.tif"
leaflet() %>% addTiles() %>% leafem:::addCOG(url = url) |
If you delete the "/vsicurl/" part of the link, things should work, I think. So, unless you can find a COG in 4326 or 3857 I think we're out of luck (with the current implementation). I think there may have been updates upstream to support arbitrary projections in Maybe @DanielJDufour can shed some light on if this is supposed to work with |
👋 hi all! Hope you are having a nice autumn. Is mapview using the newest version of georaster-layer-for-leaflet? One of the newer versions added support for most projections. I created another example which we can use to test this COG. Please see here: You can see that it looks off when you first load it, but when you zoom in, it looks better. I'm not sure what's to explain why it's off when zoomed out. I'll have to dive in. |
@tim-salabim , nvm. It's something else. I'll submit a PR to leafem soon. |
@DanielJDufour thanks for your efforts! No, we're using a rather ancient version of georaster-layer-for-leaflet. I should be able to find some time tomorrow to update the dependency and test with the above example. |
This "should" be addressed with r-spatial/leafem#48 |
Thanks @DanielJDufour ! library(stars)
library(leaflet)
library(leafem)
url = "http://s3.eu-central-1.wasabisys.com/eumap/lcv/lcv_landcover.hcl_lucas.corine.rf_p_30m_0..0cm_2019_eumap_epsg3035_v0.1.tif"
leaflet() %>%
addTiles(group = "osm") %>%
addProviderTiles("Esri.WorldImagery", group = "esri") %>%
addMapPane("cog", zIndex = 500) %>%
setView(lng = 11.35, lat = 46.5, zoom = 12) %>%
leafem:::addCOG(
url = url
, group = "corine"
, opacity = 0.8
, options = list(pane = "cog")
, resolution = 128
, autozoom = FALSE
) %>%
addMouseCoordinates() %>%
addLayersControl(
baseGroups = c("osm", "esri")
, overlayGroups = "corine"
) ## test some others
url = 'http://s3.eu-central-1.wasabisys.com/eumap/aq/aq_pm25_et.eml_m_1km_na_2018.03.01..2018.03.31_eumap_epsg3035_v0.1prebeta.tif'
url = 'http://s3.eu-central-1.wasabisys.com/eumap/adm/adm_county_nuts.osm_c_30m_0..0cm_2021_eumap_epsg3035_v0.1.tif'
leaflet() %>%
addTiles(group = "osm") %>%
addProviderTiles("Esri.WorldImagery", group = "esri") %>%
addMapPane("cog", zIndex = 500) %>%
leafem:::addCOG(
url = url
, group = "cog-layer"
, opacity = 0.7
, options = list(pane = "cog")
, resolution = 96
, autozoom = TRUE
) %>%
addMouseCoordinates() %>%
addLayersControl(
baseGroups = c("osm", "esri")
, overlayGroups = "cog-layer"
) @przell it is still very alpha, as we currently cannot control coloring, for example. Still, I am closing this here, as all further dev needs to happen in |
I've tried to reproduce the examples above. I've updated mapview, leafem and leaflet to the latest CRAN version. url = "http://s3.eu-central-1.wasabisys.com/eumap/lcv/lcv_landcover.hcl_lucas.corine.rf_p_30m_0..0cm_2019_eumap_epsg3035_v0.1.tif"
url = 'http://s3.eu-central-1.wasabisys.com/eumap/aq/aq_pm25_et.eml_m_1km_na_2018.03.01..2018.03.31_eumap_epsg3035_v0.1prebeta.tif'
url = 'http://s3.eu-central-1.wasabisys.com/eumap/adm/adm_county_nuts.osm_c_30m_0..0cm_2021_eumap_epsg3035_v0.1.tif'
url = "https://geotiff.github.io/georaster-layer-for-leaflet-example/examples/load-cog-via-url-param.html?url=http%3A%2F%2Fs3.eu-central-1.wasabisys.com%2Feumap%2Flcv%2Flcv_landcover.hcl_lucas.corine.rf_p_30m_0..0cm_2019_eumap_epsg3035_v0.1.tif"
leaflet() %>%
addTiles(group = "osm") %>%
addProviderTiles("Esri.WorldImagery", group = "esri") %>%
addMapPane("cog", zIndex = 500) %>%
leafem:::addCOG(
url = url
, group = "cog-layer"
, opacity = 0.7
, options = list(pane = "cog")
, resolution = 96
, autozoom = TRUE
) %>%
addMouseCoordinates() %>%
addLayersControl(
baseGroups = c("osm", "esri")
, overlayGroups = "cog-layer"
) sessionInfo
|
You need to install leafem from github |
Hi @tim-salabim and @DanielJDufour, |
Np plans, no. Until when would you need it updated? |
I've just updated @DanielJDufour I still see some (projection) issues with your COG example. I am assuming that the issue of "looking off" at low zoom levels is still a lingering one? library(leaflet)
library(leafem)
url = "https://georaster-layer-for-leaflet.s3.amazonaws.com/GHS_POP_E2015_GLOBE_R2019A_4326_9ss_V1_0.tif"
leaflet() %>%
addTiles(group = "osm") %>%
addProviderTiles("Esri.WorldImagery", group = "esri") %>%
addMapPane("cog", zIndex = 500) %>%
leafem:::addCOG(
url = url
, group = "cog-layer"
, opacity = 0.7
, options = list(pane = "cog")
, resolution = 96
, autozoom = TRUE
# , colorOptions = colorOptions(
# palette = hcl.colors(3, "Inferno")
# , breaks = seq(0, 100, 1)
# , domain = c(0, 100)
# , na.color = "#ff00ff88"
# )
, pixelValuesToColorFn = JS(
"function (values) {
var scale = chroma.scale(['brown', 'orange', 'red']).domain([0,100,1000]);
var population = values[0];
if (population === -200) return;
if (population < 0) return;
return scale(population).hex();
}"
)
) %>%
addMouseCoordinates() %>%
addLayersControl(
baseGroups = c("osm", "esri")
, overlayGroups = "cog-layer"
) |
Hey, @tim-salabim . Sorry about that. I'll take a look. Could you provide a link to the basemap that you are using? Just so I can replicate as closely as possible this scenario when debugging. Thank you! |
The one you see in the image above should be var OpenStreetMap_Mapnik = L.tileLayer('https://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png', {
maxZoom: 19,
attribution: '© <a href="https://www.openstreetmap.org/copyright">OpenStreetMap</a> contributors'
}); |
is there an open issue on the georaster-for-leaflet side @DanielJDufour ? certainly this cog is well behaved, I'm keen to explore the js side a bit ;) |
We've just reused the code snippet from above for a demo at the LPS, while you are working on the integration into mapview etc. We used it with COGs generated by openEO platform and it worked! Thanks for that! |
Are there any plans to support COGs in mapview. Our use case would be passing the url, or urls per band, to the COG directly to mapview? Have you considered leaflet extensions for COGs (georasterlayer for leaflet or stac-layer)?
Reading COGs with stars is possible and could be a workaround:
The text was updated successfully, but these errors were encountered: