ImageServiceMeasure Parameter syntax

2712
9
02-29-2016 02:37 PM
JordanLynn
New Contributor

Hello,

I've been trying to measure the total area of a given raster from a clipped geometry (specifically a selected county), and I've been thinking that ImageServiceMeasureTask​ is what I need to use.

My problem is I have no idea how to setup the ImageServiceMeasureParameters object to work with the image service I'm using. And I can not find any examples anywhere for either the task or the parameter so any help would be greatly appreciated. Here's the relevant javascript and the URL to the image service I'm using.

var imageMeasureTask = new ImageServiceMeasureTask(rasterURL);

imageServiceMeasureParams = new ImageServiceMeasureParameters();

imageServiceMeasureParams.fromGeometry = evt.graphic.geometry;

imageMeasureTask.execute(imageServiceMeasureParams, success, failure);

0 Kudos
9 Replies
YueWu1
by Esri Regular Contributor
Esri Regular Contributor

Hi Jordan,

Here I share with you this sample code that you can take a look about JS Bin - Collaborative JavaScript Debugging

Hope this can help.

YueWu1
by Esri Regular Contributor
Esri Regular Contributor

Hi Jordan,

Kind of follow up my previous answer. The sample that I mentioned above is using an ImageServiceMeasure | API Reference | ArcGIS API for JavaScript widget. You can check the hyperlink about this widget. However, I confirm with our dev team that this doc has some issue and may confuse you. I do internally logged a documentation enhancement and we should update this documentation pretty. [ENH-000094580 Incomplete documentation for IncopImageServiceMeasure widget]

Currently, I would suggest just follow the sample that I showed to you to finish your task.

Best Regards,

0 Kudos
JordanLynn
New Contributor

Yue,
Thanks for the reply! The sample code does help, I'll work on integrating it into my own and I'll mark this question solved once I've gotten it working.

0 Kudos
JordanLynn
New Contributor

Yue,

Sorry for the confusion but I've actually meant I'm using the ImageServiceMeasureTask​, which I assume can use the same parameter object. What I'm having trouble with is when the user selects a county of the state I'd like to know the total area of the raster (with certain values) within that county.

So I'm trying to use the "fromGeometry" property of ImageServiceMeasureParameters by handing it the county's geometry. And right now the query fails with an error "unable to complete operation". I assume this is because I'm just not getting the parameter fields correctly? Thanks for the help.

0 Kudos
YueWu1
by Esri Regular Contributor
Esri Regular Contributor

Hi Jordan,


I think the issue is if you using the widget that I showed in my sample, then you don't have to worry about ImageServiceMeasureTask or ImageServiceMeasureParameters

The reason is because the widget already handle those task behind, and all you need to do is interact with the UI widget and draw polygon on screen to get the result.

I assume you want to pro-grammatically to get the result without interact with widget, then you need to

pass all the right values that you need to get the result to execute.

The easy way to identify what type of requests that you send to image service, is using the developer tool from browser. Then used that widget sample to see the request. Here I show you a screenshot to illustrate what I mean:

0 Kudos
JordanLynn
New Contributor

Yue,

I think we've gotten a little far from what I was originally trying to do, sorry.

I'm trying to count the total area for specific values (52 and 71) within the a county geometry. Originally I tried to find a way just to count the amount of pixels (I know each pixel is 30 meters) that is returned after I've clipped the image to the shape of the county. So right now I have a clipped image in the shape of a given county and I've filtered the values so that only 52 and 71 appear. I'm just stuck on how to find the area of the image that is showing (after the filter and clipping) inside a selected county. Here's a image of what I'm trying to accomplish: (The green area is the image I'd like to find the area of, ignore the red overlay)
2016-03-02-151949_1280x800_scrot.png

And if it helps the code for this project is on my github here although it's getting very long the important raster/image service stuff is along line 195. Thank you!

0 Kudos
BruceGodfrey
Occasional Contributor

Yue,

When an area calculation is performed, are pixels with a value of "noData" include in the result?  In the testing I've done it seems like "noData" pixels are included but maybe I'm missing something.  Is there a way to exclude them?  Thanks.  -Bruce

0 Kudos
YueWu1
by Esri Regular Contributor
Esri Regular Contributor

Hi Bruce,

Not sure if it is related to your data or other setup issue. You can try to test with this sample Measure Polygon Area and Perimeter ​at least you can try if any "noData" value included in this sample with your data.

Essentially, I assume that ImageServiceMeasure Widget is using this method AreasAndLengthsParameters | API Reference | ArcGIS API for JavaScript​ to calculate the Area.

Hope this can help you to narrow down something at least.

0 Kudos
BruceGodfrey
Occasional Contributor

Hi Yue,

When I try the sample app you provided above (JS Bin - Collaborative JavaScript Debugging​)

and I draw an area in western Montana (say around Missoula) an area is calculated.  While the pixels are within the bounding box of the service, they are "noData" (based on identifying).  It doesn't seem like the Widget is taking into account "noData" pixels.  I would expect no area value to be calculated in this case.  Does it seem to you like the Widget isn't working correctly or am I missing something?

Thank you,

-Bruce

0 Kudos