code: from pathlib import Path
  
  import geopandas as gpd
  import lancedb
  import matplotlib.pyplot as plt
  from skimage import io
  
  # Set working directory
  wd = "/home/usr/Desktop/"
  
  # To download the existing embeddings run aws s3 sync
  # aws s3 sync s3://clay-worldcover-embeddings /my/dir/clay-worldcover-embeddings
  
  vector_dir = Path(wd + "clay-worldcover-embeddings/v002/2021/")
  
  # Create new DB structure or open existing
  db = lancedb.connect(wd + "worldcoverembeddings_db")
  
  # Read all vector embeddings into a list
  data = []
  for strip in vector_dir.glob("*.gpq"):
      print(strip)
      tile_df = gpd.read_parquet(strip).to_crs("epsg:3857")
  
      for _, row in tile_df.iterrows():
          data.append(
              {"vector": row["embeddings"], "year": 2021, "bbox": row.geometry.bounds}
          )
  
  # Show table names
  db.table_names()
  
  # Drop existing table if exists
  db.drop_table("worldcover-2021-v001")
  
  # Create embeddings table and insert the vector data
  tbl = db.create_table("worldcover-2021-v001", data=data, mode="overwrite")
  
  
  # Visualize some image chips
  def plot(df, cols=10):
      fig, axs = plt.subplots(1, cols, figsize=(20, 10))
  
      for ax, (i, row) in zip(axs.flatten(), df.iterrows()):
          bbox = row["bbox"]
          url = f"https://services.terrascope.be/wms/v2?SERVICE=WMS&version=1.1.1&REQUEST=GetMap&layers=WORLDCOVER_2021_S2_TCC&BBOX={','.join([str(dat) for dat in bbox])}&SRS=EPSG:3857&FORMAT=image/png&WIDTH=512&HEIGHT=512"  # noqa: E501
          image = io.imread(url)
          ax.imshow(image)
          ax.set_axis_off()
  
      plt.tight_layout()
      plt.show()
  
  
  # Select a vector by index, and search 10 similar pairs, and plot
  v = tbl.to_pandas()["vector"].values[10540]
  result = tbl.search(query=v).limit(5).to_pandas()
  plot(result, 5)
  
apis: lancedb.connect
extract_api: [((321, 371), 'pathlib.Path', 'Path', (["(wd + 'clay-worldcover-embeddings/v002/2021/')"], {}), "(wd + 'clay-worldcover-embeddings/v002/2021/')\n", (325, 371), False, 'from pathlib import Path\n'), ((421, 468), 'lancedb.connect', 'lancedb.connect', (["(wd + 'worldcoverembeddings_db')"], {}), "(wd + 'worldcoverembeddings_db')\n", (436, 468), False, 'import lancedb\n'), ((1096, 1135), 'matplotlib.pyplot.subplots', 'plt.subplots', (['(1)', 'cols'], {'figsize': '(20, 10)'}), '(1, cols, figsize=(20, 10))\n', (1108, 1135), True, 'import matplotlib.pyplot as plt\n'), ((1546, 1564), 'matplotlib.pyplot.tight_layout', 'plt.tight_layout', ([], {}), '()\n', (1562, 1564), True, 'import matplotlib.pyplot as plt\n'), ((1569, 1579), 'matplotlib.pyplot.show', 'plt.show', ([], {}), '()\n', (1577, 1579), True, 'import matplotlib.pyplot as plt\n'), ((1475, 1489), 'skimage.io.imread', 'io.imread', (['url'], {}), '(url)\n', (1484, 1489), False, 'from skimage import io\n'), ((591, 614), 'geopandas.read_parquet', 'gpd.read_parquet', (['strip'], {}), '(strip)\n', (607, 614), True, 'import geopandas as gpd\n')]