WMS stands for Web Map Service. In a simplified interpretation, it is just a line of code to enter into the address bar of our web browser. The result is an image with cartographic, geological, urban planning or other types of information supplied by web applications. The correct line format and the interpretation of its code can be done by reverse engineering. In some cases, the server web pages provide explicit data about the code. In other cases, you may try to find the code by inspecting the web page code.
In short, WMS can be considered a minimalist GIS system in a single line of code. Let's see some examples and how to use it in a practical way.
https://geoserveis.icgc.cat/servei/catalunya/orto-territorial/wms?REQUEST=GetMap&VERSION=1.3.0&SERVICE=WMS&CRS=EPSG:25831&BBOX=445636.00,4685404.00,446136.00,4685904.00&WIDTH=4000&HEIGHT=4000&LAYERS=ortofoto_color_vigent&STYLES=&FORMAT=JPEG&BGCOLOR=0xFFFFFF&TRANSPARENT=TRUE&EXCEPTION=INIMAGE
Explanation:
This link opens a high‑resolution orthophoto from the server of the Cartographic Institute of Catalonia (icc.cat) with the parameter "orto_color_vigent". In this case it is the urban area of Llanars (El Ripollès), Catalonia. Pay close attention to the code, it is always similar (deciphering the code):
https://geoserveis.icgc.cat/servei/catalunya/orto-territorial/ < Main server of the Cartographic and Geological Institute of Catalonia
CRS=EPSG:25831& < Indicates the UTM coordinate system for Catalonia (EPSG 25831)
LAYERS=orto_color_vigent& < Specifies that the layer to download is the current colour orthophoto
FORMAT=JPG < Specifies jpg format
SERVICE=WMS&VERSION=1.3
SRS=EPSG:25831 < Specifies the geographic reference system used in Catalonia (ETRS89 UTM zone 31N)
BBOX=445636.00,4685404.00,446136.00,4685904.00 < This is the most important part, it specifies UTM coordinates x1,y1,x2,y2 of the rectangle to download. Point (x1,y1) bottom left, point (x2,y2) top right.
WIDTH=4000 < Specifies the width in pixels of the box
HEIGHT=4000 < Specifies the height in pixels of the box
All WMS servers have a very similar code. Only by modifying the coordinates after "BBOX" and the values "WIDTH" and "HEIGHT", we can obtain orthophotos of any other part of our UTM zone, provided that the server provides data at the specified point. The width and height must be proportional to the dimensions of the rectangle defined by the points (x1,y1) (x2,y2). There are also limits to the resolution in number of pixels relative to the dimensions of the box. Some tests are needed to achieve successful results. In this case, with a 500x500 m ground rectangle and a 4000x4000 pixel photo, we are almost at the maximum resolution of the system. With the mouse, right‑click and "Save image as...".
We can modify the LAYER parameter to other options provided by the ICGC server, such as "orto_gris_vigent", "orto_color_2020", etc.:
https://geoserveis.icgc.cat/servei/catalunya/orto-territorial/wms?REQUEST=GetMap&VERSION=1.3.0&SERVICE=WMS&CRS=EPSG:25831&BBOX=445636.00,4685404.00,446136.00,4685904.00&WIDTH=4000&HEIGHT=4000&LAYERS=ortofoto_infraroig_vigent&STYLES=&FORMAT=JPEG&BGCOLOR=0xFFFFFF&TRANSPARENT=TRUE&EXCEPTION=INIMAGE
Here the main LAYER is called "ortofoto_infraroig_vigent". The use of "BBOX" coordinates and pixel dimensions "WIDTH" and "HEIGHT" is similar.
Information about territorial orthophoto layers on the ICGC website:
https://www.icgc.cat/ca/Geoinformacio-i-mapes/Geoinformacio-en-linia-Geoserveis/WMS-Ortoimatges/WMS-dOrtofoto-Territorial
Territorial topography:
https://www.icgc.cat/ca/Geoinformacio-i-mapes/Geoinformacio-en-linia-Geoserveis/WMS-Topografics/WMS-Referencial-Topografic-Territorial
To know the names of the available LAYERS you need to search for information on the website of the institution providing the data, or use reverse engineering by studying the general code when loading different layers. There are servers for multiple topics of interest to civil engineering, geology, delimitation of natural areas, urban planning, archaeological heritage, etc. In the following example we will see how to obtain WMS codes hidden on the web...
Again, you need to search for information on the website of the institution that provides the maps, which is not always published, or use reverse engineering, searching and studying the generated codes. Generally, it involves opening the map server, and with the button
1) Open an online map server provided by a public or private institution. For example, we will open the geological map of the Geological Institute of Catalonia, which has the following web address:
https://www.icgc.cat/en/Public-Administration-and-Enterprises/Downloads/Geological-and-geothematic-cartography/Geological-cartography/Geological-map-1-50-000
2) Now we need to find the internal WMS server code...
3) Using the Firefox browser (or others) right‑click and "Inspect" and a code window appears at the bottom.
4) Look for the "Network" tab. Here we must find some lines of code that talk about "WMSServer" or "service=WMS" or similar. That's what we are looking for!
5) Copy one of the lines of code that contain the word WMS and have the necessary structure, and verify the result.
6) For example, on the first attempt I found the code:
The WMS lines that interest us most are those in which the coordinates specified in "BBOX" are UTM, since the units are metres and very easy to interpret. Some WMS servers use different reference systems (code associated with the parameter "EPSG").
https://siurana.icgc.cat/arcgis/services/geologic/icgc_mg250m/MapServer/WMSServer?=&service=WMS&request=GetMap&layers=UGEO_PA&styles=&format=image/png&transparent=true&version=1.1.1&nom=Unitats%20geol%C3%B2giques&tipus=wms&businessId=a8c42945fbd6de690b1d8080f2fbdf44&width=512&height=512&srs=EPSG:3857&bbox=0,5087648.602661333,78271.51696402048,5165920.119625352
https://geoserveis.icgc.cat/arcgis/services/geologic/icgc_mg250m/MapServer/WMSServer?&service=WMS&request=GetMap&layers=UGEO_PA&styles=&format=image%2Fpng&transparent=true&version=1.1.1&nom=Unitats%20geol%C3%B2giques&tipus=wms&businessId=a8c42945fbd6de690b1d8080f2fbdf44&width=512&height=512&srs=EPSG%3A3857&bbox=156543.03392804097,5165920.119625352,234814.5508920615,5244191.636589374
It has the appropriate structure and gives good results. Remember that we must adjust the coordinates after "bbox" and the pixels "width" and "height" if necessary. In this case the layer is "layers=UGEO_PA". The cartographic system is EPSG:3857 (WGS84 Pseudo‑Mercator).
In summary, collecting WMS servers and knowing the codes to download our georeferenced images is very interesting and useful. One must be careful, as WMS map servers often change the names of the servers and their control parameters.
Here we have only talked about how to manually download image by image by editing the code. However, I have also automated this task for multiple images with a bash script (link). And using the UNIX philosophy of making simple programs that do one thing, do it well, and are connected to each other, it is also solved with another bash script: how to download multiple boxes and load them as external references into a DXF file using the FortranCAD application.
Learn more about the WMS standard here:
https://portal.ogc.org/files/?artifact_id=14416
https://portal.ogc.org/files/?artifact_id=14416