{ "cells": [ { "cell_type": "markdown", "id": "50c8fb92", "metadata": {}, "source": [ "# Vectorized and harmonized geological maps\n", "![](./Charm-50.png)" ] }, { "cell_type": "markdown", "id": "a7ade3d2", "metadata": {}, "source": [ "## Pre-requeries" ] }, { "cell_type": "markdown", "id": "39cf4787", "metadata": {}, "source": [ "### GeoPandas installation" ] }, { "cell_type": "code", "execution_count": null, "id": "e732b692", "metadata": {}, "outputs": [], "source": [ "!pip install geopandas" ] }, { "cell_type": "markdown", "id": "77573e62", "metadata": {}, "source": [ "### Download and unzip dataset" ] }, { "cell_type": "code", "execution_count": null, "id": "9483ab3c", "metadata": {}, "outputs": [], "source": [ "### http://infoterre.brgm.fr/telechargements/BDCharm50/GEO050K_HARM_001.zip\n", "from glob import glob\n", "import os\n", "\n", "data_folder = '/tmp'\n", "shapefile_paths = glob(os.path.join(data_folder, '*.shp'))" ] }, { "cell_type": "markdown", "id": "1b9cdb23", "metadata": {}, "source": [ "## Load and visualize dataset" ] }, { "cell_type": "markdown", "id": "d65150c5", "metadata": {}, "source": [ "### Load shape data as streamlines" ] }, { "cell_type": "code", "execution_count": null, "id": "29accbc8", "metadata": { "scrolled": true }, "outputs": [], "source": [ "from bioexplorer import BioExplorer\n", "import geopandas as gpd\n", "from tqdm import tqdm\n", "import seaborn as sns\n", "\n", "be = BioExplorer()\n", "core = be.core_api()\n", "status = be.reset_scene()\n", "\n", "DEFAULT_RADIUS = 25.0\n", "\n", "errors = list()\n", "palette = sns.color_palette('Blues', len(shapefile_paths))\n", "i = 0\n", "for shapefile_path in tqdm(shapefile_paths):\n", " c = palette[i]\n", " data = gpd.read_file(shapefile_path)\n", " line_geometry = data.geometry\n", " colors = list()\n", " indices = list()\n", " indices.append(0)\n", " vertices = list()\n", " index = 0\n", " for line in line_geometry:\n", " try:\n", " coordinates = line.coords\n", " if len(coordinates) <= 2:\n", " continue\n", " for coordinate in coordinates:\n", " vertices.append(coordinate[0])\n", " vertices.append(coordinate[1])\n", " vertices.append(0.0) # 2D dataset\n", " vertices.append(DEFAULT_RADIUS)\n", " colors.append(c[0])\n", " colors.append(c[1])\n", " colors.append(c[2])\n", " colors.append(1)\n", " index += len(coordinates)\n", " indices.append(index)\n", " except Exception as e:\n", " errors.append(e)\n", " if len(indices)>2:\n", " be.add_streamlines(os.path.basename(shapefile_path), indices, vertices, colors)\n", " i += 1\n", "\n", "status = be.reset_camera()" ] } ], "metadata": { "kernelspec": { "display_name": "Python 3 (ipykernel)", "language": "python", "name": "python3" }, "language_info": { "codemirror_mode": { "name": "ipython", "version": 3 }, "file_extension": ".py", "mimetype": "text/x-python", "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", "version": "3.8.10" } }, "nbformat": 4, "nbformat_minor": 5 }