{
  "cells": [
    {
      "cell_type": "markdown",
      "metadata": {},
      "source": [
        "# GeoPython Lab 03 — GeoPandas\n",
        "**Στόχος:** δημιουργία GeoDataFrame, CRS, buffers και βασικός χάρτης.\n"
      ]
    },
    {
      "cell_type": "code",
      "execution_count": null,
      "metadata": {},
      "outputs": [],
      "source": [
        "!pip -q install geopandas\n"
      ]
    },
    {
      "cell_type": "code",
      "execution_count": null,
      "metadata": {},
      "outputs": [],
      "source": [
        "import geopandas as gpd\n",
        "from shapely.geometry import Point\n",
        "\n",
        "gdf = gpd.GeoDataFrame(\n",
        "    {\"name\": [\"A\", \"B\", \"C\"],\n",
        "     \"type\": [\"station\", \"station\", \"control\"]},\n",
        "    geometry=[Point(22.94, 41.09), Point(22.95, 41.08), Point(22.93, 41.10)],\n",
        "    crs=\"EPSG:4326\"\n",
        ")\n",
        "gdf\n"
      ]
    },
    {
      "cell_type": "code",
      "execution_count": null,
      "metadata": {},
      "outputs": [],
      "source": [
        "# Μετατροπή σε ΕΓΣΑ87 ώστε οι αποστάσεις να είναι σε μέτρα\n",
        "gdf_egsa = gdf.to_crs(\"EPSG:2100\")\n",
        "gdf_egsa[[\"name\", \"geometry\"]]\n"
      ]
    },
    {
      "cell_type": "code",
      "execution_count": null,
      "metadata": {},
      "outputs": [],
      "source": [
        "# Buffer 250 m\n",
        "buffers = gdf_egsa.copy()\n",
        "buffers[\"geometry\"] = buffers.buffer(250)\n",
        "buffers\n"
      ]
    },
    {
      "cell_type": "code",
      "execution_count": null,
      "metadata": {},
      "outputs": [],
      "source": [
        "ax = buffers.plot(alpha=0.25)\n",
        "gdf_egsa.plot(ax=ax, markersize=40)\n",
        "ax.set_title(\"Σημεία και ζώνες 250 m\")\n"
      ]
    },
    {
      "cell_type": "markdown",
      "metadata": {},
      "source": [
        "## Μικρή άσκηση\n",
        "Δοκίμασε buffer 500 m και έλεγξε αν οι ζώνες των σημείων αλληλεπικαλύπτονται.\n"
      ]
    }
  ],
  "metadata": {
    "kernelspec": {
      "display_name": "Python 3",
      "language": "python",
      "name": "python3"
    },
    "language_info": {
      "name": "python",
      "version": "3.x"
    }
  },
  "nbformat": 4,
  "nbformat_minor": 5
}