We are trying to run a ClientSide clip on an image service layer using the JavaScript API. Ideally we would want it to work like the the create feature layer from shapefile sample (https://developers.arcgis.com/javascript/latest/sample-code/layers-featurelayer-shapefile/) where we would like to generate landcover charts using the clipped extent.
While it seems that creating a GP task is a good alternative, will this be possible over client side and if so could someone direct us to any samples.
Thanks for your help!
It can depend on many, many things and there are probably several ways to do most steps depending on the application requirements. Do you control the image service? Do you control the polygon vector data? Is it necessary for the application to allow for the polygon vector data to come from a shapefile? What is the desired user experience? What is the desired output? As you can see there are too many things involved to provide a simple answer. Here's a quick example of one way in which you can use the Clip raster function, but how this raster function is applied in your use-case will depend on the image service you use and how it's configured. I hope this helps.https://codepen.io/john-grayson/pen/ExmXBLr
https://developers.arcgis.com/documentation/common-data-types/raster-function-objects.htm
https://desktop.arcgis.com/en/arcmap/latest/manage-data/raster-and-images/clip-function.htm
As mentioned previously there are more than one way to do this task depending on your needs. If you have multiple layers but don't want to display them in the map and still create these types of charts, then using a client-side pixel filter is probably not the way to do this as your use-case and workflow are very, very different. I would suggest you investigate the use of histograms as a possibility. You can still pass in the 'clip' raster function as part of the renderingRule. The counts you get back would represent the number of pixels in each class and you could build the charts based on those values.
Hello @JohnGrayson ,
Was the above description helpful amd will it be possible to run this entire operation over client side.
Thanks again.
Thank you somuch for your response.
Is it advisable to use a GP service with teh Clip Raster function and consume that within the application or is there a way to have this entire process be executed over a client side and then maybe create the resulting charts.
We are new to the the JavaScript API and have been using samples to learn how to build applications. Is there any sample you could direct us to which uses a raster clip?
We really appreciate all the help you've provided us.
In looking at your other question, an important concept to understand is that the buffer/circle constructed to filter the data is based on a pixel location and distances, but what you get back from converting the shapefile are vector based geometries. The first step in combining these concepts is that you will need to re-write the calls to the ImageryLayer to include your vector based geometry filter (a geometry from one of the converted shapefile layers) before retrieving the pixels. You can use the 'Clip' raster function to help with this task. You could then create the chart from those returned pixels. What you want to do will require a lot of changes to the code, but it should be possible. This process will result in a different user experience from the sample as you will loose the interactive calculations, which will now only happen when the view extent changes.
Thank you @JohnGrayson ,
Essentially we did refer to the sample and did work on it. What this sample does is bases the extraction on a buffer generated via the mouse event. We want this to work using the boundary of an uploaded polygon shapefile.
We are loking to use the ouput feature collection defined by the following sample (https://developers.arcgis.com/javascript/latest/sample-code/layers-featurelayer-shapefile/) to query the attributes of the image service.
Please do let us know if it is possible as we have been trying to implement this for a while now.
We had outlined our problem within the following post: https://community.esri.com/t5/arcgis-api-for-javascript-questions/imagerylayer-client-side-chart-using-an-uploaded/m-p/1066750#M73449
Thanks a ton!
Have you seen this sample:https://developers.arcgis.com/javascript/latest/sample-code/layers-imagery-clientside/
Les membres connectés peuvent publier, suivre les mises à jour, et plus encore. Nouveau ici ? Inscrivez-vous gratuitement.
Find useful guides, FAQs, and documents to help you navigate and make the most of Esri Community.