---
title: "LayerMap"
description: "Named layer definitions loaded from rosette.toml."
canonical_url: "https://www.rosette.dev/docs/api-reference/LayerMap"
markdown_url: "https://www.rosette.dev/docs/api-reference/LayerMap.md"
source_url: "https://github.com/PreFab-Photonics/rosette/blob/f086d7670645fd36c05362d696d442a2b2e74850/www/content/docs/api-reference/LayerMap.mdx"
docs_channel: "main"
docs_revision: "f086d7670645fd36c05362d696d442a2b2e74850"
---

# LayerMap

Named layer definitions loaded from `rosette.toml`.

Import with `from rosette.project import LayerMap`.

Provides attribute-style access to layers by semantic name, so
components and designs can reference layers without hardcoded numbers.

```python
from rosette.components import grating_coupler

layers = load_layer_map()
layers.silicon        # -> LayerInfo('silicon', Layer(1, 0), color='#ff69b4')
layers.silicon.layer  # -> Layer(1, 0)
layers.silicon.color  # -> '#ff69b4'

# Use directly in component calls and cell operations
gc = grating_coupler(layers.silicon.layer, waveguide_width=0.5)
cell.add_polygon(poly, layers.silicon.layer)

# Iterate over all layers
for info in layers:
    print(f"{info.name}: {info.layer}")

# Check if a layer exists
if "silicon" in layers:
    print("has silicon layer")
```

## Methods



### `__init__`

```python
__init__(layer_infos=None) -> None
```

Create a LayerMap from a list of LayerInfo objects.

Usually you don't create this directly. Use `load_layer_map()` instead.



- **`layer_infos`** (`list[LayerInfo] | None`, default `None`)

  List of layer definitions. If `None`, creates an empty map.





**Returns:** `None`





### `get`

```python
get(name) -> LayerInfo | None
```

Get a layer by name, or `None` if not found.



- **`name`** (`str`)

  Layer name to look up.





**Returns:** `LayerInfo | None`





### `names`

```python
names() -> list[str]
```

Get all layer names.



**Returns:** `list[str]`



### Supported operations

* **Attribute access:** `layers.silicon` returns the `LayerInfo` for `"silicon"`
* **Containment:** `"silicon" in layers` checks if a layer name exists
* **Iteration:** `for info in layers:` iterates over all `LayerInfo` objects
* **Length:** `len(layers)` returns the number of layers