Welcome to ESRI Blogs

Adding spatial reference systems to a WMS service's capabilities file

Yingqi Tang, a product engineer specializing in ArcGIS Server and OGC services, contributed the following post:

In ArcGIS Server 9.2 you can publish a map document as an OGC WMS service. All WMS services advertise the spatial reference systems they support through capabilities files. WMS clients read the capabilities file to find out which spatial reference systems they can use to request a map.

The WMS services you create with ArcGIS Server support hundreds of spatial reference systems, but only two are advertised in the capabilities file: EPSG 4326 (required by every WMS service) and the spatial reference of the data frame from which you published the service. Although you can request a map from the WMS service using any of the hundreds of supported spatial reference systems, some WMS clients will return an error if the spatial reference you request does not appear in the capabilities file. Other clients, such as ArcMap, only allow you to switch among the spatial reference systems listed in the capabilities file.

This post shows how to add more spatial reference systems to the capabilities file of a WMS service that you have published with ArcGIS Server. To do this, you publish the WMS service using an external capabilities file. You can then manually add spatial reference systems to this file. This procedure is mentioned in the ArcGIS Server 9.2 documentation as one reason to use external WMS capabilities files.

Assume that you have a map document whose data frame’s spatial reference system is "World_Fuller (EPSG:54050)". So by default the WMS service being published on that map document will only support spatial reference system EPSG:4326 and EPSG:54050. Now let’s add one additional spatial reference system "World_Aitoff (EPSG:54043)" into this WMS service by following detailed steps below.

  1. Publish the map document as a WMS service using system generated capabilities files. Use a system generated capabilities file as a template when creating an external WMS capabilities file. To use system generated capabilities files, select the option "Enter service properties below" in the WMS capabilities page in the Service Properties.

    Publishing with system generated capabilities files

  2. Assume you named your map service "world", so the WMS service URL for "world" will be something like "http://<host>:port/arcgis/services/world/MapServer/WMSServer?". Start a browser and type "http://<host>:port/arcgis/services/world/MapServer/WMSServer?version=1.1.1&service=WMS&request=GetCapabilities". Save the response as an XML file called "capabilities111.xml".

  3. Copy "capabilities111.xml" to a place on your file system and make it accessible as a URL. As an example, "capabilities111.xml" can be copied to "C:\Inetpub\wwwroot\ArcGIS\Wms\world" (assuming you are using ArcGIS Server for the Microsoft .NET Framework and you have created the folder "world" yourself). So now the file can be accessible as URL "http://<host>/arcgis/wms/world/capabilities111.xml". Before you keep going, start a browser and type in this URL to make sure the file is accessible.
  4. Stop the map service you just published in step 1. Go to the WMS capabilities page of the map service properties panel.

    Switch to use the second option "Use external capabilities files" to publish this WMS service. Type in the URL of the folder where you put "capabilities111.xml" plus the prefix of file "capabilities" in the "Specify the location and prefix" input box. (So in this example you would type "http://<host>/arcgis/wms/world/capabilities") The reason why only the URL of folder and file prefix are required is to allow you to create external capabilities files for other versions of WMS (1.0.0, 1.1.0, 1.3.0). Click "OK" and restart the map service "world".

    Publishing with external capabilities files

  5. Before you keep going, make a connection in ArcCatalog to the WMS service you just republished in step 4. The URL of your service is "http://<server name>/<instance name>/services/<folder name (if applicable)>/<service name>/MapServer/WMSServer?". Preview the WMS service and make sure it’s working properly.

  6. Now you can add spatial reference systems to your WMS service. Make a copy of your map document and open the copy in ArcMap. Change the data frame’s coordinate system to "World_Aitoff (EPSG:54043)", which is the one we want to add, and save the map document.

    World Aitoff projection in ArcMap

  7. Zoom to the full extent of the map. Right click the data frame and click Properties > Data Frame. Write down the extent values of current map (see the values in Extent > Fixed Extent).

    Getting the extent of the map
  8. Open "capabilities111.xml" which you saved in step 3 in a text editor. Search for the root "<Layer>" element (There will be only root <Layer> element in the xml).

    Add "<SRS>EPSG:54043</SRS>" right after "<SRS>EPSG:4326</SRS>" and "<SRS>EPSG:54050</SRS>".

    How can you get the EPSG code for the spatial reference you want to add? One way is to look it up here in the Coordinate IDs and Descriptions book.

    Now add "<BoundingBox SRS="54043" minx="-22041257.7736507" miny="-17284666.2314989" maxx="22041257.7724258" maxy="17222309.5138405"/>" right after "<BoundingBox SRS="54050" . . .>" Substitute your own minx, miny, maxx, and maxy values that you wrote down.

    Original XML file:

    XML before change

    XML after adding new spatial reference system "EPSG:54043" and its "BoundingBox" for root layer:

    XML after change

  9. For each layer of the map document, do the following things in order to figure out the layer’s extent: (1) Right-click the data frame and go to Properties > Data Frame. (2) Select "Other" in "Extent used by Full extent command" and click "Specify"; (3) Select "Outline of the Feature", and pick the layer. (4) Apply the change and return to the map document. (5) Click Full Extent. (6) Go back to Properties > Data Frame and note the extent of the layer.

    Resetting Full Extent

  10. In "capabilities111.xml", search for each <Layer> element according to its name and tile. For each layer add "<SRS>EPSG:54043</SRS>" right after "<SRS>EPSG:4326</SRS>" and "<SRS>EPSG:54050</SRS>"; Add "<BoundingBox SRS="54043" minx="" miny="" maxx="" maxy=""/>" right after "<BoundingBox SRS="54050"……>" (you need to fill in minx, miny, maxx and maxy values with what you got in step 9).

    Final XML

  11. Save "capabilities111.xml" and restart the map service.

  12. You’ve successfully added a spatial reference system to your WMS service. To prove it, connect to the WMS service in ArcCatalog and view the layer’s properties. "EPSG:54043" should be listed as a "Supported SRS".

    Supported spatial reference systems

  13. Add the WMS service in ArcMap. In the table of contents, right-click the service and click Change Coordinate System. Notice that World Aitoff is now a supported spatial reference system. You can use this dialog to switch among the supported spatial reference systems.

    Viewing spatial reference systems in ArcMap
Published Wednesday, September 26, 2007 12:23 PM by sterlingdq
Filed under:

Comment Notification

If you would like to receive an email when updates are made to this post, please register here

Subscribe to this post's comments using RSS

Comments

No Comments

Leave a Comment

(required) 
required 
(required)