10.1. Lesson: Serviciile Web Mapping

Un Serviciu de Cartografiere Web (WMS) este un serviciu găzduit pe un server aflat la distanță. Similar unui site web, îl puteți accesa, atât timp cât aveți o conexiune la server. Cu ajutorul QGIS, puteți încărca un WMS direct în harta existentă.

Din lecția despre plugin-uri, ne amintim că este posibilă încărcarea unei noi imagini raster, spre exemplu, de la Google. Totuși, aceasta este o tranzacție once-off: o dată ce ați descărcat imaginea, aceasta nu se mai schimbă. Un WMS este diferit prin faptul că este un serviciu live, care se va actualiza automat, la deplasarea sau mărirea hărții.

Scopul acestei lecții: De a folosi un WMS și de a-i înțelege limitările.

10.1.1. basic Follow Along: Încărcarea unui strat WMS

For this exercise, you can either use the basic map you made at the start of the course, or just start a new map and load some existing layers into it. For this example, we used a new map and loaded the original places, landuse and protected_areas layers and adjusted the symbology:

../../../_images/new_map.png
  1. Încărcați aceste straturi într-o nouă hartă, sau folosiți harta originală doar cu aceste straturi vizibile.

  2. Before starting to add the WMS layer, deactivate „on the fly” projection (Project ► Properties… ► CRS tab, check No CRS (or unknown/non-Earth projection). This may cause the layers to no longer overlap properly, but don’t worry: we’ll fix that later.

  3. To add WMS layers, click on the dataSourceManager button to open the Data Source Manager dialog and enable the addWmsLayer WMS/WMTS tab.

    ../../../_images/datasourcemanager_wms.png

    Remember how you connected to a SpatiaLite or GeoPackage database at the beginning of the course. The landuse, buildings, and roads layers are stored in a database. To use those layers, you first needed to connect to the database. Using a WMS is similar, with the exception that the layers are on a remote server.

  4. Pentru a crea o nouă conexiune la un WMS, faceți clic pe butonul New.

    You’ll need a WMS address to continue. There are several free WMS servers available on the Internet. One of these is terrestris, which makes use of the OpenStreetMap dataset.

  5. Pentru a face uz de acest WMS, setați-l în dialogul curent, astfel:

    ../../../_images/new_wms_connection.png
    • The value of the Name field should be terrestris.

    • The value of the URL field should be https://ows.terrestris.de/osm/service.

  6. Faceți clic pe Ok. Ar trebui să vedeți listat noul server WMS:

    ../../../_images/new_connection_listed.png
  7. Faceți clic pe Conectare. În lista de mai jos, ar trebui să vedeți încărcate acum, aceste noi intrări:

    ../../../_images/new_wms_entries.png

    Acestea sunt toate straturile găzduite de acest server WMS.

  8. Faceți clic o dată pe stratul OSM-WMS. Se va afișa Sistemul său de Coordonate de Referință:

    ../../../_images/osm_wms_selected.png

    Since we’re not using WGS 84 for our map, let’s see all the CRSs we have to choose from.

    1. Click the Change… button. You will see a standard Coordinate Reference System Selector dialog.

    2. Dorim un CRS proiectat, așa că haideți să alegem WGS 84 / Pseudo Mercator.

      1. Enter the value pseudo in the Filter field:

      2. Choose WGS 84 / Pseudo Mercator (with epsg:3857) from the list.

        ../../../_images/pseudo_mercator_selected.png
      3. Click OK. The Coordinate Reference System associated with the entry has changed.

  9. Click Add and the new layer will appear in your map as OpenStreetMap WMS - by terrestris.

  10. Close the Data Source Manager dialog if not done automatically

  11. In the Layers panel, click and drag it to the bottom of the list.

  12. Zoom out in order to get a global view of the layers. You will notice that your layers aren’t located correctly (near west of Africa). This is because „on the fly” projection is disabled.

    ../../../_images/reprojection_off.png
  13. Let’s enable the reprojection again, but using the same projection as the OpenStreetMap WMS layer, which is WGS 84 / Pseudo Mercator.

    1. Open the Project ► Properties… ► CRS tab

    2. Uncheck No CRS (or unknown/non-Earth projection)

    3. Alegeți WGS 84 / Pseudo Mercator din listă.

      ../../../_images/enable_projection.png
    4. Clic pe OK

  14. Now right-click on one of your own layers in the Layers panel and click Zoom to layer extent. You should see the Swellendam area:

    ../../../_images/wms_result.png

Notă cum se suprapun străzile stratului WMS cu propriile noastre străzi. Ăsta e un semn bun!

Natura și limitele WMS

By now you may have noticed that this WMS layer actually has many features in it. It has streets, rivers, nature reserves, and so on. What’s more, even though it looks like it’s made up of vectors, it seems to be a raster, but you can’t change its symbology. Why is that?

This is how a WMS works: it’s a map, similar to a normal map on paper, that you receive as an image. What usually happens is that you have vector layers, which QGIS renders as a map. But using a WMS, those vector layers are on the WMS server, which renders it as a map and sends that map to you as an image. QGIS can display this image, but can’t change its symbology, because all that is handled on the server.

This has several advantages, because you don’t need to worry about the symbology. It’s already worked out, and should be nice to look at on any competently designed WMS.

On the other hand, you can’t change the symbology if you don’t like it, and if things change on the WMS server, then they’ll change on your map as well. This is why you sometimes want to use a Web Feature Service (WFS) instead, which gives you vector layers separately, and not as part of a WMS-style map.

Acest lucru va fi acoperit în lecția următoare, cu toate acestea. În primul rând, haideți să adăugați un alt strat WMS din serverul terrestris.

10.1.2. basic Try Yourself

  1. Hide the OSM-WSM layer in the Layers panel.

  2. Add the „ZAF CGS 1M Bedrock Lithostratigraphy” WMS server at this URL: http://196.33.85.22/cgi-bin/ZAF_CGS_Bedrock_Geology/wms

  3. Load the BEDROCKGEOLOGY layer into the map (you can also use the Layer ► Add Layer ► addWmsLayer Add WMS/WMTS Layer… button to open the Data Source Manager dialog). Remember to check that it’s in the same WGS 84 / World Mercator projection as the rest of your map!

  4. You might want to set its Encoding to JPEG and its Tile size option to 200 by 200, so that it loads faster:

    ../../../_images/bedrock_geology_layer.png

Check your results

10.1.3. moderate Try Yourself

  1. Hide all other WMS layers to prevent them from rendering unnecessarily in the background.

  2. Add the „OGC” WMS server at this URL: http://ogc.gbif.org:80/wms

  3. Adăugați stratul bluemarble.

Check your results

10.1.4. hard Try Yourself

O parte din dificultatea de a folosi WMS, este de a găsi un server bun (și gratuit).

  • Find a new WMS at directory.spatineo.com (or elsewhere online). It must not have associated fees or restrictions, and must have coverage over the Swellendam study area.

    Amintiți-vă că pentru un WMS aveți nevoie doar de URL-ul său (și, de preferință, un fel de descriere).

Check your results

10.1.5. In Conclusion

Folosind un WMS, puteți adăuga hărți inactive ca fundaluri pentru datele hărților existente.

10.1.6. Further Reading

10.1.7. What’s Next?

Now that you’ve added an inactive map as a backdrop, you’ll be glad to know that it’s also possible to add features (such as the other vector layers you added before). Adding features from remote servers is possible by using a Web Feature Service (WFS). That’s the topic of the next lesson.