Check if a point given a longitude and latitude is in a imageLayer

129
1
Jump to solution
05-10-2019 01:55 PM
StevenStapleton1
New Contributor

I am working with arcGIS JavaScript API 4.11. I am trying to see if a point which I provided a longitude and latitude is in a image layer or not. Any suggestions? The code below is what I am trying to use.

//xCord and yCord are the long and lat

 let pt = esri.geometry.geographicToWebMercator(new esri.geometry.Point(xCord, yCord));

let result = map.layers.getItemAt(0).geometry.contains(pt);
console.log("Result is: " + result);

Thanks in advance!

0 Kudos
1 Solution

Accepted Solutions
UndralBatsukh
Esri Regular Contributor

Hi there, 

You will be able to do this on the client using ImageryLayerView.pixelData by getting updated pixel data whenever the layerview is updated. 

You'll have to create the ImageryLayer.format with `lerc` option so that you can access the pixel data on the client. You can set the pixelFilter to change the pixel colors. This sample shows you how to do it.

In view's click event, you'd have to figure out the pixel index from the mouse location and get the data for that pixel. 

I have created this sample app to show what is involved.

Hope this helps

View solution in original post

0 Kudos
1 Reply
UndralBatsukh
Esri Regular Contributor

Hi there, 

You will be able to do this on the client using ImageryLayerView.pixelData by getting updated pixel data whenever the layerview is updated. 

You'll have to create the ImageryLayer.format with `lerc` option so that you can access the pixel data on the client. You can set the pixelFilter to change the pixel colors. This sample shows you how to do it.

In view's click event, you'd have to figure out the pixel index from the mouse location and get the data for that pixel. 

I have created this sample app to show what is involved.

Hope this helps

View solution in original post

0 Kudos