Javascript Api Identify Raster pixel value

9663
21
Jump to solution
08-20-2014 07:02 AM
BeakalGobena
New Contributor II

I have this map loaded using the ArcGIS API

http://ags.servirlabs.net/ArcGIS/rest/services/ReferenceNode/TRMM_30DAY/MapServer

I want to let the user click on the raster layer and display the pixel value at that specific x,y location in a pop up window. While googling I found this example

https://developers.arcgis.com/javascript/jssamples/find_popup.html

explaining how to use IdentifyTask. Can I use this feature for a raster layer plus the data is already loaded do I need to make an extra request to get the values every time the user clicks on the layer?

0 Kudos
1 Solution

Accepted Solutions
KevinMacLeod4
Frequent Contributor

Tim Witt Riyas Deen

Thanks! Teamwork!!

We needed this too. It just needed a small fix from Riyas' example. Here is an updated working sample, using our DEM:

http://jsfiddle.net/kevinmSAGIS/L834u2nt/4/

 Identify cell value with Popup in a mapServer raster  

I had to add the following line because there's a space in Pixel Value:

                    "Pixel Value is : " + feature.attributes[ 'Pixel Value']); 

View solution in original post

21 Replies
TimWitt2
MVP Regular Contributor

Here you go!

Edit fiddle - JSFiddle

RiyasDeen
Regular Contributor

Hi Beakal,

Noticed that Tim's sample is displaying the pixel's attributes like colour and layer name, i understand you are interested in the value of the pixel.

I have modified find_popup sample to display the pixel value.

Edit fiddle - JSFiddle

AudyBarnett
New Contributor

Thanks Riyas. This is helpful. However, when I try to use your code I receive "undefined" as my pixel value in the pop up. My map service shows in the app and I can click to make the pop up show, but I do not receive a pixel value. Any ideas?

Thanks.

0 Kudos
NMWater
New Contributor III

Hi Audy,

I have the same problem currently, I was wondering if you ever figured out how to tackle this issue? I still get undefined when trying to find the pixel value.

Many Thanks.

0 Kudos
KevinMacLeod4
Frequent Contributor

see my reply at the bottom for the fix NM Water

0 Kudos
BeakalGobena
New Contributor II

Thanks Tim and Riyas and  for the reply, IdentifyParameter and IdentifyTask is the write approach.

But I ran into another problem, on my page I'm loading four different layers at a time while the IdentifyParameter object accepts only one url as a parameter. Note that the layers are not in the same map service, they are in a different urls and different locations.

When the users click on any of the layer, I want to get the pixel values from the clicked layer.

Is this some thing possible?

KevinMacLeod4
Frequent Contributor

Tim Witt Riyas Deen

Thanks! Teamwork!!

We needed this too. It just needed a small fix from Riyas' example. Here is an updated working sample, using our DEM:

http://jsfiddle.net/kevinmSAGIS/L834u2nt/4/

 Identify cell value with Popup in a mapServer raster  

I had to add the following line because there's a space in Pixel Value:

                    "Pixel Value is : " + feature.attributes[ 'Pixel Value']); 

LloydBronn
Occasional Contributor II

This is great! I want to incorporate it into a script I'm working on. Will it work to reference the 3.17 API instead of 3.10?

Thanks!

0 Kudos
RobertScheitlin__GISP
MVP Esteemed Contributor

Absolutely 

0 Kudos