Creación de un mapa de uso de la tierra (QGIS3)

Las designaciones de zonificación definen y regulan qué tipos de usos están permitidos en parcelas específicas y esbozan los requisitos y directrices de diseño y desarrollo. En este tutorial aprenderá a acceder a conjuntos de datos de parcelas, a aplicarles estilos según los atributos de zonificación y a crear un mapa.

Visión general de la tarea

Trabajará con un conjunto de datos de parcelas con información de zonificación y creará un mapa que muestre el patrón de zonificación en la región del CBD de Ciudad del Cabo.

../../_images/zoning_map.png

Otras competencias que aprenderá

  • Cómo acceder y descargar datos de ArcGIS REST en QGIS.

  • Cómo extraer objetos espaciales de una capa que intersecta una capa límite.

  • Cómo fusionar diferentes subcategorías desde el renderizador Categorizado.

Obtener los datos

Puede encontrar los datos para el tutorial en el Portal de Datos Abiertos de Ciudad del Cabo - https://odp-cctegis.opendata.arcgis.com. Vamos a importar datos desde el portal utilizando ArcGIS REST URL del servidor y se preparará tres capas se mencionan a continuación .

  1. Capa de zonificación: Un archivo shape de polígonos con el código de zonificación y la descripción de las parcelas que tienen una única zonificación - recortada en el área del CBD de Ciudad del Cabo.

  2. Capa de zonificación dividida: Un archivo shape de polígonos con el código de zonificación y la descripción de las parcelas con zonificación múltiple, con cada polígono dividido en polígonos de zonas individuales.

  3. Área CDB de Ciudad del Cabo: Un polígono que delimita la zona del CDB de Ciudad del Cabo.

Veamos paso a paso cómo preparar el conjunto de datos para este tutorial.

  1. Vaya al portal de datos - https://odp-cctegis.opendata.arcgis.com/. Buscaremos los datos del CBD de Ciudad del Cabo en la barra de búsqueda y haremos clic para seguir navegando.

    ../../_images/db1.png
  2. Haga clic en Ver todos los detalles para explorar los servicios disponibles para obtener los datos.

    ../../_images/db2.png
  3. Scroll down to find View Data Source and click on the it.

    ../../_images/db3.png
  4. En el Directorio de Servicios REST de ArcGIS, vaya a :guilabel: Inicio y copie la URL de esa página. La URL copiada tiene el siguiente aspecto - https://citymaps.capetown.gov.za/agsext1/rest/services.

    ../../_images/db4.png
  5. Ahora, abra QGIS y vaya a :menuselection: Abrir Gestor de Fuentes de Datos.

    ../../_images/db5.png
  6. La lista de fuentes de datos se ve en el panel izquierdo. Desplácese hacia abajo hasta encontrar ArcGIS REST Server. Haga clic en nuevo para crear una nueva conexión al servidor.

    ../../_images/db6.png
  7. In the Connection Details, give the Name Cape Town Open Data Portal and paste the copied url as an input for URL.

    ../../_images/db7.png
  8. Haga clic en :guilabel: Aceptar y luego en :guilabel: Conectar para ver las carpetas de datos disponibles en el servidor.

    ../../_images/db8.png
  9. Ahora buscaremos en la base de datos las tres capas necesarias para el tutorial. En primer lugar, abriremos la capa Cape Town CBD en QGIS. Despliegue las carpetas para buscar las capas. La ruta completa a la capa es Theme_Based ‣ Open_Data_Service ‣ Cape Town CBD. Seleccione la capa y haga clic en :guilabel: Añadir.

    ../../_images/db9.png
  10. Cierre :menuselection: Gestor de fuentes de datos para ver la capa añadida al QGIS. Haga clic en :menuselection: Zoom a Capa para centrar y mostrar la capa en el lienzo.

    ../../_images/db10.png
  11. Ahora, añadiremos la capa Zoning usando Gestor de Fuentes de Datos. Conéctese al «Portal de Datos Abiertos de Ciudad del Cabo» y busque la capa Zoning. La ruta completa es Theme_Based ‣ Open_Data_Service_Zoning ‣ Zoning. Esta es una capa muy grande, así que asegúrese de marcar la casilla Only request features overlapping the current view extent para evitar cargar todas las prestaciones disponibles en la capa. Si olvida esto, la carga de la capa puede tardar mucho tiempo. Haga clic en Add para abrir en QGIS.

    ../../_images/db11.png
  12. Del mismo modo añadir Split_Zoning capa. La ruta completa es - Theme_Based ‣ Land_Parcel_Zoning ‣ Split Zoning.

    ../../_images/db12.png
  13. Podemos ver que las tres capas de origen están abiertas en QGIS. Queremos recortar las capas Zoning y Split Zoning a la capa límite Cape Town CBD. En primer lugar, vamos a guardar las tres capas localmente como archivos shape. Haga clic con el botón derecho en la capa Cape Town CBD. Busque Exportar y haga clic en :guilabel: Guardar objetos espaciales como.

    ../../_images/db13.png
  14. Establezca el formato ESRI Shapefile y vaya a la carpeta local donde desea guardar los archivos shape. Guardaremos todas las capas relacionadas con este tutorial en una única carpeta de datos. Guarde la capa como cbd. Mantenga el resto de opciones por defecto y haga clic en Aceptar. Del mismo modo exportar otras dos capas como Zoning.shp y Split Zoning a la misma carpeta.

    ../../_images/db14.png
  15. Elimine las capas cargadas desde el servidor. Seleccione las tres capas, y haga clic en :guilabel: Quitar Capa / Grupo icono. Queremos extraer los objetos espaciales de las capas Zoning y Split Zoning que se cruzan con el límite cbd.

    ../../_images/db15.png
  16. Vaya a Procesos ‣ Caja de herramientas de la barra de menús.

    ../../_images/db16.png
  17. En la caja de herramientas, busque el algoritmo :guilabel: Intersección y haga doble clic para abrirlo.

    ../../_images/db17.png
  18. Seleccione Zoning como Capa de entrada y cbd como Capa de superposición. Mantenga las demás opciones por defecto y proceda a guardar el resultado en un archivo.

    ../../_images/db18.png
  19. Guarde la capa de salida como zoning_cbd en la carpeta de datos y haga clic en Ejecutar.

    ../../_images/db19.png
  20. Dependiendo de la configuración de Procesos, verá algunos errores o advertencias en la pestaña Registro. La capa de entrada tiene algunas geometrías inválidas y está siendo omitida mientras se ejecuta la intersección. Corregiremos las geometrías de las capas Zoning y Split Zoning antes de ejecutar la intersección para extraer todas las geometrías.

    ../../_images/db20.png
  21. Elimine la salida de intersección de QGIS y de la carpeta de datos. Busque la herramienta Corregir geometrías en la caja de herramientas de procesamiento. Haga doble clic para abrir.

    ../../_images/db21.png
  22. Seleccione Zoning como Capa de entrada. Mantenga el resto de entradas por defecto y guarde la capa de salida como zoning_fixed.shp en la carpeta de datos haciendo clic en Guardar en archivo. Haga clic en Ejecutar. Repita el proceso para fijar las geometrías en la capa Split Zoning y guarde la capa con geometrías fijas como split_zoning_fixed.shp.

    ../../_images/db22.png
  23. Eliminar Zoning y Split Zoning capas. Vamos a seguir adelante con la extracción de objetos espaciales de zoning_fixed y split_zoning_fixed capas que se cruzan cbd. Busque Intersección en la caja de herramientas de procesado y haga doble clic para abrirla.

    ../../_images/db23.png

24.Seleccione Zoning_fixed como Capa de entrada y cbd como Capa de superposición` para realizar la intersección como se describe en los pasos 18 y 19. Guarde la salida como zoning_cbd y repita lo mismo para la capa split_zoning_fixed y guarde la capa de salida como split_zoning_cbd. Guarde la salida como zoning_cbd y repita lo mismo para la capa split_zoning_fixed y guarde la capa de salida como split_zoning_cbd.

../../_images/db24.png

Para mayor comodidad, puede descargar directamente una copia de las tres capas preprocesadas desde los siguientes enlaces:

cbd.shp

zoning_cbd.shp

split_zoning_cbd.shp

Procedure

  1. Open QGIS. Click Open Data Source Manager icon to add layers to work on for the tutorial.

../../_images/160.png
  1. Switch to the Vector tab and use the browsing button to navigate to the folder where you have kept the processed shapefiles.

../../_images/230.png
  1. Select cbd.shp, zoning_cbd.shp and split_zoning_cbd.shp files and click Open.

../../_images/325.png
  1. You will see all three file paths in the text box beside Vector Dataset. Click Add followed by Close.

../../_images/410.png
  1. As we work on the exercise, it is important to save our work. Go to Project ‣ Save.

../../_images/510.png
  1. Save the project to the data directory as landuse_map.qgz file. The QGIS Project file contains references to the data layers and saves styles, map templates etc.

../../_images/610.png
  1. Select the zoning_cbd layer and click the Open Attribute Table button in the Attributes Toolbar. Note that the attribute INT_ZONE_C has the zoning codes and INT_ZONE_D has the zoning description. Close the attribute table.

../../_images/710.png
  1. Now let’s style the layer based on these attributes, so the parcels with the same zoning codes are styles in the same color. Click the Open the Layer Styling panel button in the Layers panel. Click the dropdown button next to Single Symbol.

../../_images/810.png
  1. Select Categorized as the renderer. Select INT_ZONE_C as the Value. Click Classify.

    ../../_images/910.png
  2. You will see a series of symbols appear. There is a different color symbol assigned for every unique code in the layer.

    ../../_images/1014.png
  3. Notice that each zoning category has sub-categories. The General Business (GB) category has further sub-divisions like GB1, GB2, and so on. For the purpose of this map, we can merge all the sub-categories to a single top-level category. Hold the Shift key and select all sub-categories. Right-click and select Merge Categories.

    ../../_images/1117.png
  4. Repeat the process for MU and TR categories. Once merged, we can now change the Legend label to be more descriptive. Click on the Legend label to rename a class.

    ../../_images/1215.png
  5. Enter descriptions of each zoning category based on the values given in the INR_ZONE_D column. As you enter those description, you will see the legend of the layer in the Layers panel also updates.

    ../../_images/1313.png
  6. Now we can update the colors and symbology of each category. Click on the Symbol for a category.

    ../../_images/1412.png
  7. Change the Fill color and Stroke color of the symbol to a color of your choice.

    ../../_images/1512.png
  8. Repeat the process for each category. The last category is all other values. This category contains all parcels which have NULL values. This is because those parcels have multiple zoning categories attached to them and are represented in the split_zoning_cbd.shp layer. We do not need them in this layer. Select it and click the - icon to remove that category.

    ../../_images/1611.png
  9. Next, select the cbd layer. Change the symbol to Simple Line and increase the Stroke width.

    ../../_images/1712.png
  10. The split_zoning_cbd.shp layer contains all parcels that were missing zoning codes in the zoning_cbd layer. The attribute table and values for the zones in the split_zoning_cbd are the same as the zoning_cbd layer. Instead of configuring the symbology for this layer manually, we can copy/paste the styles. Select the zoning_cbd layer, right-click and select Styles ‣ Copy Style ‣ Symbology.

    ../../_images/1810.png
  11. Now select the newly added split_zoning_cbd layer, right-click and select Styles ‣ Paste Style ‣ Symbology.

    ../../_images/199.png
  12. You will see the same symbology being applied to the polygons in the split_zoning_cbd layer. The styling and legend are complete now.

    ../../_images/209.png
  13. We have our layers styled and legend labels created. Now let’s create a map using these styled layers along with map elements like, scale bar, north arrow, labels etc. QGIS comes with a Print Layout that allows composing maps. Go to Project ‣ New Print Layout. When prompted for a name, you can leave it blank and click OK.

    ../../_images/2114.png
  14. In the Print Layout window, you will see a canvas. Right-click and select Page Properties.

    ../../_images/2211.png
  15. Set the Orientation to Portrait. Next, go to Add Item ‣ Add Map.

    ../../_images/238.png
  16. Hold the left mouse button and draw a rectangle on the canvas. This is the map frame which will contain the map from the main QGIS window. In the Item Properties tab, use the Interactively Edit Map Extent icon to pan/zoom the content of the map frame.

    ../../_images/249.png
  17. Scroll down in the Item Properties tab and check the Frame option. Expand it and select a Color for the frame border. You can also increase the Thickness.

    ../../_images/258.png
  18. The map frame is now ready. Let’s add other elements. Go to Add Item ‣ Add Legend.

    ../../_images/267.png
  19. Drag a rectangle where you want to place the legend. Once added, scroll down in the Item Properties tab and un-check the Auto update button so we can manually edit the legend items.

    ../../_images/278.png
  20. We have 2 layers with identical legends, so we can remove one of them. Select the split_zoning_cbd layer and click the Remove selected item(s) from legend icon. Similarly remove cbd layer from the legend.

    ../../_images/288.png
  21. Right-click the zoning_cbd layer and check the Hidden option.

    ../../_images/297.png
  22. Scroll down and expand the Columns section. Check the Split layers option and increase the Count to 2.

    ../../_images/307.png
  23. Scroll down further to the Spacing section. Adjust the spacing between different elements till the legend is clearly legible.

    ../../_images/3111.png
  24. You can change style and size of the fonts in legend from Fonts and Text Formatting properties. When done, go to Add Item ‣ Add North Arrow. Drag a rectangle where you want to place the element on the map.

    ../../_images/326.png
  25. Pick a symbol of your choice. Scroll down and expand the SVG Parameters. Change the Fill color and Stroke color as per your choice.

    ../../_images/333.png
  26. Now we will add a Scale Bar. Go to Add Item ‣ Add Scale Bar. Drag a rectangle where you want to place the element on the map. Adjust the Style and Segments parameters for the scale bar.

    ../../_images/343.png
  27. Our map needs a title and other information labels. Go to Add Item ‣ Add Label.

    ../../_images/353.png
  28. Enter a map title in the Main Properties section. Click the Font button under Appearance section to adjust the font size and style.

    ../../_images/362.png
  29. Add other labels indicating the data source and your name. Lastly we will finish our map by adding a frame around the label block. Go to Add Item ‣ Add Shape ‣ Add Rectangle.

    ../../_images/372.png
  30. Draw a rectangle. Click the symbol for Style and set the Fill Color to transparent and Stroke color to match other frames.

    ../../_images/372.png
  31. Once you are satisfied with your composition, you can export the result. Go to Layout ‣ Export as PDF. Save the PDF in your data folder as capetown_zoning_map.pdf.

    ../../_images/392.png

If you want to give feedback or share your experience with this tutorial, please comment below. (requires GitHub account)