.. _topography: Topography ========== Topographic information is an important input to WAsP's flow models. Specifically, WAsP's terrain model takes as input maps of surface elevation, surface roughness, and optionally displacement height. In PyWAsP, instead of dealing with surface roughness maps and displacement height maps as completely separate layers, we deal with them as land cover maps, where patches of land are associated with specific land cover classes, each having specific surface characteristics (i.e. the surface roughness and displacement height). .. seealso:: :doc:`windkit:user_guide/topography/index` Overview, map conversion, and data download. :doc:`windkit:user_guide/topography/elevation_maps` Elevation maps - schema, I/O, working with raster and vector. :doc:`windkit:user_guide/topography/roughness_maps` Roughness maps - schema, I/O, best practices. :doc:`windkit:user_guide/topography/landcover_maps` Land cover maps - schema, I/O, land cover tables. Preparing Input for Terrain Modeling ------------------------------------ To predict site effects from topography data with PyWAsP, the data is bundled together in the :class:`pywasp.wasp.TopographyMap` class. It takes as input an elevation vector map, a land cover vector map, and a land cover table. .. ipython:: python :okwarning: import windkit as wk import pywasp as pw import matplotlib.pyplot as plt # Read elevation and land cover maps elev_map = wk.read_elevation_map( "source/tutorials/data/SerraSantaLuzia.map", crs="EPSG:32629", ) lc_map, lc_tbl = wk.read_roughness_map( "source/tutorials/data/SerraSantaLuzia.map", crs="EPSG:32629", convert_to_landcover=True, polygons=False ) # Create TopographyMap for flow modeling topo_map = pw.wasp.TopographyMap( elev_map, lc_map, lc_tbl ) print(topo_map) Topography maps can be saved to, and loaded from, a ZipFile archive using the :py:meth:`pywasp.wasp.TopographyMap.save` and :py:func:`pywasp.wasp.TopographyMap.load` methods. In :ref:`wasp_flow_model` we describe the WAsP models in more details and show how terrain effects can be calculated from a ``topo_map``, like the one above. Best practices for working with roughness maps ---------------------------------------------- Roughness maps can come from many different sources and can be of varying quality and resolution. When working with roughness maps, it is important to consider the following best practices for making them suitable for use in WAsP: 1. **Water bodies have 0.0 roughness**: Water bodies should have a roughness value of 0.0, this is the signal to WAsP that the surface is water. During calculations in WAsP, the roughness value of 0.0 is replaced with the water roughness value set in the :py:class:`pw.wasp.Config` (default is 0.0002). This is important for the stability model of WAsP, as it uses different stability functions for water and land. 2. **Land roughness values should be in the range [0.0002, 5.0]**: Roughness values should be in the range [0.0002, 5.0] for land surfaces. WAsP assumes the lowest roughness to be the water roughness value (0.0002) and the highest roughness to be 5.0. Any land roughness values outside this range can cause problems in WAsP. If a lower water roughness value was set in the WAsP Config, the lower limit is adjusted accordingly. 3. **Keep the number of unique roughness values to a reasonable number**: WindKit reads roughness maps and converts them to land cover classes. The number of unique roughness values in the roughness map should be kept to a reasonable number to avoid too many land cover classes. The suitable number of unique roughness values depends on the application. PyWAsP allows up to 100, but typically 5-50 unique roughness values are sufficient. Internally, WAsP uses a limited number of roughness-change events per sector, so having too many unique roughness values don't add any value. In the future, WindKit will provide tools to preprocess roughness maps to adhere to these best practices. In the meantime, ``QGIS``, ``xarray``, ``xarray-spatial``, and other GIS tools can be used. Converting Raster Maps to Vector Maps ------------------------------------- While WindKit and PyWAsP have great support for working with both raster and vector maps and the PyWAsP terrain model can work with elevation maps as both rasters and vector maps, for land cover maps PyWAsP expects vector maps as input. Therefore, PyWAsP enables conversion from raster maps to vector maps, through the :py:func:`pywasp.raster_to_vector` function. .. ipython:: python :okwarning: # Read a raster elevation map elev_raster = wk.read_elevation_map("source/tutorials/data/elev.tif") # Convert to vector (contour lines) elev_vector = pw.raster_to_vector(elev_raster) print(f"Raster shape: {elev_raster.shape}") print(f"Vector features: {len(elev_vector)}")