Select to view content in your preferred language

Client-side: all pixel values from ImageryLayer in Sketch geometry

571
2
07-05-2022 12:51 PM
DaveMcLaughlin
Emerging Contributor

I’m having trouble chaining this together, but here is what I’d like to accomplish:

  1. Display a raster as an ImageryLayer from a 3rd-party server (I’ve got this)
  2. Add the sketch widget and access a polygon the user draws (I think I have this one, too)
  3. Access the pixel values of all pixels from the raster which are within the user-created polygon
  4. Calculate/chart data based on the pixel values (check!)

It’s only step 3 that I’m stuck on. Do I somehow need to loop through every pixel in the current extent and test them individually using geometryEngine’s “within” before adding to an array?

I need to do this client-side and can’t perform a server-side rendering rule clip.

I appreciate any help you can provide!

0 Kudos
2 Replies
DaveMcLaughlin
Emerging Contributor

Another idea, not sure if this is possible:
Create an ImageryLayer I use just for the analysis (with the same raster source), which then gets clipped with a client-side rendering rule…and then get values of all pixels in that layer after the clip?

0 Kudos
ArnoFiva
Esri Contributor

I don't have a running sample at hand, but I believe you should be able to do something like that using the following:

For ImageryLayers: https://developers.arcgis.com/javascript/latest/api-reference/esri-layers-ImageryLayer.html#fetchIma...

For TiledImageryLayers: https://developers.arcgis.com/javascript/latest/api-reference/esri-layers-ImageryTileLayer.html#fetc...

Use the extent of the sketched geometry as an input for these methods. As you describe above, you could then for each point / pixel in the response use the geometry engine to determine if it is part of the original geometry.

Hope this helps!

0 Kudos