Add raster layer from map service in ArcGIS Portal

Problem

User needs to add one or many raster layers into ArcGIS Pro from a map service.  Default behaviour only allows adding the complete map service and all it’s constituent rasters (of which there could be dozens).

First of all map services need to be enabled with WMS before you can even start thinking about adding discrete layers.  This is done via ArcGIS Server:

In Portal, as admin, you need to make sure both the map service and the WMS service are given the correct permissions to your end users – you must do this for both services!

The Code

Note the code below is referencing the WMS url not the standard map service.


string wmsUrl = "https://gisportal.foocompany.local/ags/services/fooservice/MapServer/WMSServer";
string rasterName = "fooRasterName";  
var serverConnection = new CIMInternetServerConnection { URL = wmsUrl };
var connection = new CIMWMSServiceConnection { ServerConnection = serverConnection };
connection.ServerConnection.User = "fooUser";
connection.ServerConnection.Password = "barPassword";
connection.LayerName = layerName;
RasterLayer rasterLayer = null;
await QueuedTask.Run(() =>
{
    var layer = LayerFactory.Instance.CreateLayer(connection, MapView.Active.Map);
});

Conclusion

This method seems clunky becuase you have the overhead of having to create a WMS service and not just being able to stick with standard map services.

After asking ESRI why when trying to add a raster layer nothing happens – they replied by saying “it’s by design” – with no further explanation. To me it makes no sense – why not have it behave the same way when adding feature based layers from a map service.

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s