# coords_to_deme_dict { #spaceprime.coords_to_deme_dict }

`coords_to_deme_dict(raster, coordinates)`

Finds the cells a given set of coordinates belong to in a raster and returns a dictionary mapping the cell indices to the centroid coordinates of those cells.
Because the cells correspond with demes in the 2D stepping stone models, the cell indices are considered deme indices.
The coordinates typically correspond to empirical data that the simulations need to be sampled from.

## Parameters

| Name          | Type                                                     | Description                                               | Default    |
|---------------|----------------------------------------------------------|-----------------------------------------------------------|------------|
| `raster`      | rasterio.DatasetReader                                   | The raster data as a rasterio DatasetReader object.       | _required_ |
| `coordinates` | Union\[List\[Tuple\[float, float\]\], gpd.GeoDataFrame\] | A list of (x, y) coordinates or a geopandas GeoDataFrame. | _required_ |

## Returns

| Type                       | Description                                                           |
|----------------------------|-----------------------------------------------------------------------|
| Dict\[int, List\[float\]\] | A dictionary mapping deme indices to their corresponding coordinates. |