ThinkGeo.com    |     Documentation    |     Premium Support

Loading ArcGIS Image Server

Hello. I am trying to load an ImageServer from an arcgis portal using the ArcGISServerRestLayer.cs class. I’m on version 13.1.2.

Here is the url of the image server I’m trying to load:
https://sampleserver6.arcgisonline.com/arcgis/rest/services/Elevation/earthquakedemoelevation/ImageServer/exportImage?bbox=344337.12498628,3784364.8258005,369637.12498628,3804664.8258005

My map’s unit is in meters and everything is using srid of 3395. Here is what I’m doing to create the layer:

ArcGISServerRestLayer test = new ArcGISServerRestLayer(new Uri("https://sampleserver6.arcgisonline.com/arcgis/rest/services/Elevation/earthquakedemoelevation/ImageServer/exportImage"));
test.Parameters.Add("imageSR", "3395");
test.Parameters.Add("bboxSR", "3395");
test.ImageFormat = ArcGISServerRestLayerImageFormat.Png;
// add layer to overlay here

After adding, it’s just a black square that covers the entire map. Here is the full URL generated by the class:
https://sampleserver6.arcgisonline.com/arcgis/rest/services/Elevation/earthquakedemoelevation/ImageServer/exportImage?IMAGESR=3395&BBOXSR=3395&BBOX=14964879.6212408%2C869533.931175921%2C15798269.8082101%2C1702924.11814522&SIZE=512%2C512&format=Png24&F=image

Is there something I’m doing wrong?

It seems a projection issue, can you check the attached sample which is also using v13.1.2

Post12409.zip (2.0 KB)

thanks for the response. hmm, so the ArcGISServerRestLayer is automatically using the canvas’s current extent as the bbox parameter. How does it know the correct srid to pass though? I know you’re manually setting it there, but I thought I would be able to set the bbox srid to whatever my other layers are in, which match with the unit that the canvas’ extent is in. For example something like this:

https://sampleserver6.arcgisonline.com/arcgis/rest/services/Elevation/earthquakedemoelevation/ImageServer/exportImage?bbox=-118.6901888%2C34.1904288%2C-118.4187758%2C34.37692&bboxSR=4326&size=&imageSR=4326&time=&format=png&pixelType=S16&noData=&noDataInterpretation=esriNoDataMatchAny&interpolation=+RSP_BilinearInterpolation&compression=&compressionQuality=&bandIds=&sliceId=&mosaicRule=&renderingRule=&adjustAspectRatio=true&validateExtent=false&lercVersion=1&compressionTolerance=&f=image

where I set the bboxSR to 4326, and imageSR to 4326, and the map unit is Decimal Degrees. However, I just see the black box in that case without the image.

Using the the exportImage url directly, I can set the bbox srid and image srid to whatever and it works fine:

Hi Dan,

The layer uses MapView.CurrentExtent as the BBOX verbatim — it doesn’t reproject. bboxSR is just how you tell the server which SR those numbers are in; it doesn’t transform them.

So MapUnit / CurrentExtent / bboxSR all have to agree. MapUnit is only the unit (meters or degrees) — 3395 and 26711 both use Meter, so changing MapUnit doesn’t change the SR. And the four CurrentExtent numbers have to be valid in your chosen SR and actually overlap the service’s data. This service only covers ~25 × 20 km near LA (see ?f=json → fullExtent, wkid 26711).

When you switched to MapUnit=DD + bboxSR=4326, my guess is CurrentExtent still held the old 3395 numbers (~14M, ~1M). The server got BBOX=14964879,869534,… interpreted as lon/lat — nonsense — and returned NoData, which Png24 renders as solid black RGB. That’s your black square.

Attached is a minimal v13.1.2 sample that works in 3395:

 mapView.MapUnit = GeographyUnit.Meter;
 mapView.CurrentExtent = new RectangleShape(-13222000, 4065000, -13172000, 4017000);

 var layer = new ArcGISServerRestLayer(new Uri(".../exportImage"));
 layer.Parameters.Add("imageSR", "3395");
 layer.Parameters.Add("bboxSR", "3395");
 layer.ImageFormat = ArcGISServerRestLayerImageFormat.Png;

By the way, if you want the NoData area transparent instead of black, set layer.Parameters[“format”] = “Png32” and don’t assign ImageFormat.

Thanks,
Ben

Thank you for the tip on the NoData transparency!

What do you mean by the current extent has to overlap the service’s data? In the example you gave, I can zoom out very far to where the extent is almost the entire world, and I can still see the image (very very tiny dot).

But if for instance I have:

mapView.MapUnit = GeographyUnit.DecimalDegree;
var layer = new ArcGISServerRestLayer(new Uri(
    "https://sampleserver6.arcgisonline.com/arcgis/rest/services/Elevation/earthquakedemoelevation/ImageServer/exportImage"));
layer.Parameters.Add("imageSR", "4326");
layer.Parameters.Add("bboxSR", "4326");
layer.Parameters.Add("format", "Png32");

it does not work. Shouldn’t it be the same as the other two examples if my current extent is in the same location?

I see your mapUnit is set to Decimal Degree which matches 4326, but what’s the mapView’s CurrentExtent? The map will not show if the CurrentExtent is still in meter (really large number).