1

I have around 1000 rasters (b&w tiffs) and most of them overlay each other. At this moment, I'm holding them in mosaic dataset and I want them to be displayed in my javascript webapp. I am able to load it as Dynamic or Image service layer and it loads all the rasters at once. In screenshot below, mosaic's attribute table has field "Name" in which names of all the rasters are held (all names are unique to only one raster). In my webapp, I want to dynamically show only one raster by specifying its name.

Part of mosaic: http://i.imgur.com/RB2zl52.jpg

In arcmap I can use layer's definition query to select only particular raster (screenshot below).

Filtered by definition query: http://i.imgur.com/XDkFl8y.jpg

What would be the appropriate approach to have dataset filtered in webapp?

0

The best way is to publish your Mosaic Dataset as an Image Service and add it to your JavaScript API web map as an ArcGISImageServiceLayer.

If you look at the ArcGIS Server REST API, an Image Service has an operation called exportImage, which takes several parameters; among them is mosaicRule. mosaicRule is a set of options which includes a WHERE clause. This is supported in the ArcGIS JavaScript API by calling setMosaicRule, e.g. imageServiceLayer.setMosaicRule(mosaicRule), where imageServiceLayer is an instance of ArcGISImageServiceLayer and mosaicRule is an instance of the MosaicRule class.

So, if you want to select your image based on its name field, you would do something like this (as of JSAPI v3.5):

var mosaicRule = new esri.layers.MosaicRule({
    "method": esri.layers.MosaicRule.METHOD_CENTER,
    "ascending": true,
    "operation": esri.layers.MosaicRule.OPERATION_FIRST,
    "where": "name='" + rasterName + "'"
});
imageServiceLayer.setMosaicRule(mosaicRule);

...where rasterName is the name of the individual raster you'd like to display. You'll want to do this each time you want to select a new raster (you may also have to refresh the layer manually; not sure).

1
  • Thank you a lot greenlaw! Since I'm using older API I had to use: var mr = new esri.layers.MosaicRule(); mr.method = esri.layers.MosaicRule.METHOD_CENTER; mr.ascending = true; mr.operation = esri.layers.MosaicRule.OPERATION_FIRST; mr.where = "NAME = '5270_r11976'";
    – DTT
    Jun 27 '13 at 6:34
0

We had similar requirement to this, but we did not have access to Image Server (In case other are not familiar, to publish a raster as an Image Service you need to have a license for the ArcGIS Server Image Extension, which depending on your license level and number of cores will be upwards of $4500 - $9000 not including your annual maintenance, etc.....). Our raster catalog was published as map service, and we developed a workflow for raster catalog filtering by also using a polygon featurset that represents outline of each raster in the catalog and has the raster name as an attribute (we automated the process for extracting this from the raster catalog). So at that point our widget queries the map extent to see which raster boundaries are in the current map extent, and user is shown a list of the file names of the rasters in the mosaic, and they can select which to turn on/off, and then this selection is translated into a definition query for the map service to show only those images.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.