esri-leaflet icon indicating copy to clipboard operation
esri-leaflet copied to clipboard

decode LERC tiles from Esri ImageServer to draw in Leaflet

Open jgravois opened this issue 8 years ago • 14 comments

investigate how much work would be necessary to refactor/extend imageMapLayer to take advantage of tile caches when they are present.

http://elevation3d.arcgis.com/arcgis/rest/services/WorldElevation3D/Terrain3D/ImageServer

in the case of Esri's recent work to open source LERC, it would be really cool if we could download/decode and draw them in Leaflet.

cc/ @tomwayson

jgravois avatar Jan 13 '16 19:01 jgravois

more info in Esri/lerc#4

jgravois avatar Jan 22 '16 17:01 jgravois

work in progress here using L.GridLayer, straight up FOSS!

jgravois avatar Feb 02 '16 18:02 jgravois

Since users don't seem to be asking for this and this issue is 3 years old I'm going to close this.

patrickarlt avatar Jul 12 '19 16:07 patrickarlt

Sorry for the crypto-bump! I am trying to access this new ESRI offering, and seem to be hitting errors related to this thread: livingatlas.arcgis.com/landcover/

I have an open question here; https://community.esri.com/t5/esri-leaflet-questions/how-to-diagnose-error-rendering-esri-2020-land/m-p/1079790#M427

Essentially, I am trying to use standard ESRI.leaflet methods to call in a layer that exists, offers a JSON response, but won't render into Leaflet. Happy for help!

While it's a bit obscure, here's a notebook showing the working pattern and the failed attempt to call ESRI's new 10m land cover:

https://community.esri.com/t5/esri-leaflet-questions/how-to-diagnose-error-rendering-esri-2020-land/m-p/1079790#M427

Welcome help and guidance!

aaronkyle avatar Jul 17 '21 01:07 aaronkyle

@aaronkyle I'll make an attempt to get a demo working to illustrate how this might work. If it is successful, then we can revisit within esri-leaflet how to support LERC decoding. And thanks @jgravois for your earlier work figuring this out!

In this particular example with the new landcover service, we have 2 separate items to deal with, as @gavinr outlined in the Community thread:

  1. Tiles are served out as WGS84 (wkid 4326) but Leaflet defaults to Spherical Mercator (Web Mercator) (wkid 3857). First we'll try to get Leaflet in wkid 4326 and assume we'll only load the landcover layer in the map.
  2. Decode LERC format tiles into a format Leaflet understands, since the service isn't providing an image in jpg/png or JSON pointing to an image url.

jwasilgeo avatar Jul 20 '21 15:07 jwasilgeo

@aaronkyle here is a screenshot to provide hope. 😃 The approach is as expected: use a Leaflet map in WGS84, and for the layer itself manually decode pixels from each tile and write them into a 2d image canvas with appropriate RGB values. This was inspired by @jgravois's https://github.com/jgravois/lerc-leaflet but customized for this particular landcover service.

image

I'd like to first clean up the code before sharing, but I hope to have something to show soon in the coming days.

jwasilgeo avatar Jul 20 '21 20:07 jwasilgeo

Wow, this is great! I really appreciate your help to make this resource available via ESRI-Leaflet.

aaronkyle avatar Jul 21 '21 12:07 aaronkyle

Here's a working sample and brief write-up: https://github.com/jwasilgeo/leaflet-experiments#lerc-imagery-land-cover-layer

Happy to discuss the code a bit more. It is based on the LeafletJS GridLayer approach pioneered by @jgravois but customized for this particular land cover ImageServer: https://github.com/jwasilgeo/leaflet-experiments/blob/master/lerc-landcover/script.js#L4

Between this and @jgravois's https://github.com/jgravois/lerc-leaflet/, we might have some good ideas coalescing to see if/how to bring this into the esri-leaflet ecosystem. I'll write up some more thoughts later.

jwasilgeo avatar Jul 21 '21 20:07 jwasilgeo

Truly grateful for all of your time and expertise. I am amazed at how you are able to do this! Fun also to see you on Observable! Thanks for allowing me to share your solution under the MIT attribution license! :rocket:

aaronkyle avatar Jul 22 '21 17:07 aaronkyle

@jwasilgeo Can we overlay this land cover wms layer (wgs84, 4326) on another wms layer with pseudo mercator projection (epsg 3857)? I tried with leaflet and esri-leaflet but I could not overlay.

I want to overlay with some other layers and compare the results.

venkanna37 avatar Jun 17 '22 21:06 venkanna37

a generic plugin for this would still be welcome, but i don't think we need an open issue to track given that no one is actively pursuing it.

jgravois avatar Jul 25 '22 16:07 jgravois

All of the new hosted tiled imagery layers on ArcGIS.com (and many from the Living Atlas) will be served this way, so please re-consider re-opening this issue as it would allow all of this content to be consumed via this API.

jgrayson-apl avatar Oct 10 '22 16:10 jgrayson-apl

Since the Living Atlas layers will be using this pattern going forward, I agree with @jgrayson-apl that we should re-open this issue to support decoding LERC tiles, via a plugin, in the future.

gavinr avatar Oct 11 '22 19:10 gavinr

Unfortunately, there are issues with the approach suggested by John & Jacob as I can't get the tiled imagery layer to overlay with existing basemaps layers, in either 4326 or 3857. Here's a quick attempt: https://codepen.io/john-grayson/pen/gOzJRgg

jgrayson-apl avatar Oct 18 '22 17:10 jgrayson-apl