---
title: "MTRasterDEMSource | Mobile sdk | Mobile sdk ios | Ios"
description: "A raster DEM source. Only supports Terrain RGB."
---

> For AI agents: a documentation index is available at [/llms.txt](https://docs.maptiler.com/llms.txt). Markdown versions of all pages are available by appending .md to any URL.

# MTRasterDEMSource

```
public class MTRasterDEMSource : MTTileSource, @unchecked Sendable
```

A raster DEM source. Only supports Terrain RGB.

-   `[identifier](#/s:11MapTilerSDK17MTRasterDEMSourceC10identifierSSvp)`
    
    Unique identifier of a source.
    
    #### Declaration
    
    Swift
    
    ```
    public var identifier: String
    ```
    
-   `[bounds](#/s:11MapTilerSDK17MTRasterDEMSourceC6boundsSaySdGvp)`
    
    An array containing the longitude and latitude of the southwest and northeast corners of the source’s bounding box in the following order: \[sw.lng, sw.lat, ne.lng, ne.lat\].
    
    Note
    
    Defaults to \[-180, -85.051129, 180, 85.051129\].
    
    #### Declaration
    
    Swift
    
    ```
    public var bounds: [Double]
    ```
    
-   `[maxZoom](#/s:11MapTilerSDK17MTRasterDEMSourceC7maxZoomSdvp)`
    
    Maximum zoom level for which tiles are available.
    
    Note
    
    Defaults to 22.
    
    #### Declaration
    
    Swift
    
    ```
    public var maxZoom: Double
    ```
    
-   `[minZoom](#/s:11MapTilerSDK17MTRasterDEMSourceC7minZoomSdvp)`
    
    Minimum zoom level for which tiles are available.
    
    Note
    
    Defaults to 0.
    
    #### Declaration
    
    Swift
    
    ```
    public var minZoom: Double
    ```
    
-   `[tileSize](#/s:11MapTilerSDK17MTRasterDEMSourceC8tileSizeSivp)`
    
    The minimum visual size to display tiles for this layer. Units in pixels.
    
    Note
    
    Defaults to 512.
    
    #### Declaration
    
    Swift
    
    ```
    public var tileSize: Int
    ```
    
-   `[encoding](#/s:11MapTilerSDK17MTRasterDEMSourceC8encodingAA0D11DEMEncodingOvp)`
    
    DEM encoding format. Defaults to Terrain RGB (mapbox).
    
    #### Declaration
    
    Swift
    
    ```
    public var encoding: MTRasterDEMEncoding
    ```
    
-   `[tiles](#/s:11MapTilerSDK17MTRasterDEMSourceC5tilesSay10Foundation3URLVGSgvp)`
    
    An array of one or more tile source URLs.
    
    #### Declaration
    
    Swift
    
    ```
    public var tiles: [URL]?
    ```
    
-   `[url](#/s:11MapTilerSDK17MTRasterDEMSourceC3url10Foundation3URLVSgvp)`
    
    A URL to a TileJSON resource. Supported protocols are http, https.
    
    #### Declaration
    
    Swift
    
    ```
    public var url: URL?
    ```
    
-   `[attribution](#/s:11MapTilerSDK17MTRasterDEMSourceC11attributionSSSgvp)`
    
    Attribution to be displayed when the map is shown to a user.
    
    #### Declaration
    
    Swift
    
    ```
    public var attribution: String?
    ```
    
-   `[type](#/s:11MapTilerSDK17MTRasterDEMSourceC4typeAA12MTSourceTypeOvp)`
    
    Type of the source.
    
    #### Declaration
    
    Swift
    
    ```
    public private(set) var type: MTSourceType { get }
    ```
    
-   `[init(identifier:url:)](#/s:11MapTilerSDK17MTRasterDEMSourceC10identifier3urlACSS_10Foundation3URLVtcfc)`
    
    Initializes the source with unique id and url to TileJSON resource.
    
    #### Declaration
    
    Swift
    
    ```
    public init(identifier: String, url: URL)
    ```
    
-   `[init(identifier:tiles:)](#/s:11MapTilerSDK17MTRasterDEMSourceC10identifier5tilesACSS_Say10Foundation3URLVGtcfc)`
    
    Initializes the source with unique id and one or more tile source urls.
    
    #### Declaration
    
    Swift
    
    ```
    public init(identifier: String, tiles: [URL])
    ```
    
-   `[init(identifier:bounds:maxZoom:minZoom:tileSize:encoding:tiles:url:attribution:)](#/s:11MapTilerSDK17MTRasterDEMSourceC10identifier6bounds7maxZoom03minI08tileSize8encoding5tiles3url11attributionACSS_SaySdGS2dSiAA0D11DEMEncodingOSay10Foundation3URLVGSgARSgSSSgtcfc)`
    
    Initializes the source with all options.
    
    #### Declaration
    
    Swift
    
    ```
    public init(
        identifier: String,
        bounds: [Double],
        maxZoom: Double,
        minZoom: Double,
        tileSize: Int = 512,
        encoding: MTRasterDEMEncoding = .mapbox,
        tiles: [URL]? = nil,
        url: URL? = nil,
        attribution: String? = nil
    )
    ```
    
-   `[setURL(url:in:completionHandler:)](#/s:11MapTilerSDK17MTRasterDEMSourceC6setURL3url2in17completionHandlery10Foundation0G0V_AA9MTMapViewCys6ResultOyytAA7MTErrorOGcSgtF)`
    
    Sets the url of the source.
    
    #### Declaration
    
    Swift
    
    ```
    @available(iOS, deprecated: 16.0, message: "Prefer the async version for modern concurrency handling")
    @MainActor
    public func setURL(url: URL, in mapView: MTMapView, completionHandler: ((Result<Void, MTError>) -> Void)? = nil)
    ```
    
-   `[setTiles(tiles:in:completionHandler:)](#/s:11MapTilerSDK17MTRasterDEMSourceC8setTiles5tiles2in17completionHandlerySay10Foundation3URLVG_AA9MTMapViewCys6ResultOyytAA7MTErrorOGcSgtF)`
    
    Sets the tiles of the source.
    
    #### Declaration
    
    Swift
    
    ```
    @MainActor
    public func setTiles(
        tiles: [URL],
        in mapView: MTMapView,
        completionHandler: ((Result<Void, MTError>) -> Void)? = nil
    )
    ```
    
-   `[setURL(url:in:)](#/s:11MapTilerSDK17MTRasterDEMSourceC6setURL3url2iny10Foundation0G0V_AA9MTMapViewCtYaF)` Asynchronous
    
    Sets the url of the source.
    
    #### Declaration
    
    Swift
    
    ```
    @MainActor
    public func setURL(url: URL, in mapView: MTMapView) async
    ```
    
-   `[setTiles(tiles:in:)](#/s:11MapTilerSDK17MTRasterDEMSourceC8setTiles5tiles2inySay10Foundation3URLVG_AA9MTMapViewCtYaF)` Asynchronous
    
    Sets the tiles of the source.
    
    #### Declaration
    
    Swift
    
    ```
    @MainActor
    public func setTiles(tiles: [URL], in mapView: MTMapView) async
    ```
    
-   `[addToMap(_:)](#/s:11MapTilerSDK17MTRasterDEMSourceC05addToA0yyAA9MTMapViewCF)`
    
    Adds source to map DSL style.
    
    Prefer `[addSource(_:)](https://docs.maptiler.com/mobile-sdk/ios/api/Classes/MTStyle/#/s:11MapTilerSDK7MTStyleC9addSourceyyAA8MTSource_pYaKF)` on MTMapView instead.
    
    #### Declaration
    
    Swift
    
    ```
    public func addToMap(_ mapView: MTMapView)
    ```
