def clip_2Dtiles(db, user_schema, schema_tiles, tiles, poly, clip_prefix,
                 fields_view):
    """Creates views for the clipped tiles.

    Parameters
    ----------
    db : db Class instance
    user_schema: str
    schema_tiles : str
    tiles : list
    poly : Shapely polygon
    clip_prefix : str

    Returns
    -------
    list
        Name of the views of the clipped tiles.

    """
    user_schema = sql.Identifier(user_schema)
    schema_tiles = sql.Identifier(schema_tiles)
    tiles_clipped = []

    fields_all = fields_view['all']
    field_geom_q = sql.Identifier(fields_view['geometry'])

    for tile in tiles:
        t = clip_prefix + tile
        tiles_clipped.append(t)
        view = sql.Identifier(t)
        tile_view = sql.Identifier(tile)
        fields_q = parse_sql_select_fields(tile, fields_all)
        wkb = sql.Literal(poly.wkb_hex)
        query = sql.SQL("""
            CREATE OR REPLACE VIEW {user_schema}.{view} AS
                SELECT
                    {fields}
                FROM
                    {schema_tiles}.{tile_view}
                WHERE
                    st_within({tile_view}.{geom}, {wkb}::geometry)"""
                        ).format(user_schema=user_schema,
                                 schema_tiles=schema_tiles,
                                 view=view,
                                 fields=fields_q,
                                 tile_view=tile_view,
                                 geom=field_geom_q,
                                 wkb=wkb)
        db.sendQuery(query)
    try:
        db.conn.commit()
        print(
            str(
                len(tiles_clipped)) +
            " views with prefix '{}' are created in schema {}.".format(
                clip_prefix,
                user_schema))
    except BaseException:
        print("Cannot create view {user_schema}.{clip_prefix}{tile}".format(
            schema_tiles=schema_tiles, clip_prefix=clip_prefix))
        db.conn.rollback()

    return(tiles_clipped)