def format_cdr_properties(
        geometries,
        densities,
        id_col_name="tower_id",
        density_col_name="density"
):
    """
    Converts the format of additional CDR properties from being in a DataFrame
    to being in a dictionary indexed by the tower node id

    Args:
        geometries (dict): object where the keys are the node id and the value
            is an object with the geometry and the area.
        densities (Pandas.DataFrame): DataFrame with column with node id and
            corresponding density of visitors at that node
        id_col_name (string): Name of the densities DataFrame column for node id
        density_col_name (string): Name of the densities DataFrame column for
            density.

    Returns:
        (dict): object with a key for each tower node id and a value that is an
            object with values for area and density of that node
    """

    props = {}
    ids = densities[id_col_name].unique()

    for tower_id in ids:
        area = None
        tower_id = str(int(tower_id))

        if tower_id in geometries:
            area = geometries[tower_id]['area']

        density = None
        densities[id_col_name] = densities[id_col_name].apply(int).apply(str)

        if area is not None and area > 0:
            densities[density_col_name] = densities[density_col_name] / area

        maximum = densities[density_col_name].max()
        densities[density_col_name] = densities[density_col_name] / maximum

        first_match = densities[densities[id_col_name] == tower_id].head(1)
        if not first_match.empty:
            density = first_match[density_col_name].iloc[0]

        props[tower_id] = {'area': area, 'density': density}

    return props