{
 "cells": [
  {
   "cell_type": "markdown",
   "id": "52fb0a23-5a9b-4c64-b01f-0687d631055f",
   "metadata": {},
   "source": [
    "# Synthetic city\n",
    "\n",
    "<h1 style=\"color:red\">VERY WIP -- not ready yet!</h1>"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "initial_id",
   "metadata": {},
   "outputs": [],
   "source": [
    "import init_notebooks\n",
    "init_notebooks.setup_environment()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "14d4ee43-886c-4a39-a928-09fdfcd40545",
   "metadata": {},
   "outputs": [],
   "source": [
    "from openavmkit.utilities.geometry import (\n",
    "    get_crs\n",
    ")\n",
    "from openavmkit.synthetic.city import SynCity"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "5e0f0cc9-b349-4dcb-8481-6246822209b3",
   "metadata": {},
   "outputs": [],
   "source": [
    "latitude = 29.7604\n",
    "longitude = -95.3698\n",
    "max_width = 10 * 5280\n",
    "max_height = 10 * 5280\n",
    "crs = \"EPSG:4326\"\n",
    "units = \"imperial\"\n",
    "\n",
    "params = {\n",
    "    \"latitude\": latitude,\n",
    "    \"longitude\": longitude,\n",
    "    \"anchor\": \"center\",\n",
    "    \"crs\": crs,\n",
    "    \"width_in_blocks\": 160,\n",
    "    \"height_in_blocks\": 96,\n",
    "    \"cbd_width_in_blocks\": 16,\n",
    "    \"cbd_height_in_blocks\": 8,\n",
    "    \"units\": units\n",
    "}\n",
    "city = SynCity(params)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "1bf49f57-9e8f-4aed-869e-32d2d00ad7da",
   "metadata": {},
   "outputs": [],
   "source": [
    "import geopandas as gpd\n",
    "import matplotlib.pyplot as plt\n",
    "\n",
    "city.gdf_parcels.to_file(\"city_parcels.gpkg\", driver=\"gpkg\")\n",
    "city.gdf_blocks.to_file(\"city_blocks.gpkg\", driver=\"gpkg\")\n",
    "city.gdf_roads.to_file(\"city_roads.gpkg\", driver=\"gpkg\")\n",
    "# Then plot the line strings on top using the same axes\n",
    "#city.gdf_roads.plot(ax=ax, color='red', linewidth=2)\n",
    "\n",
    "\n",
    "# display(city.gdf_blocks)\n",
    "\n",
    "# display(city.gdf_blocks.geometry[0].bounds)\n",
    "# display(city.gdf_blocks.geometry[1].bounds)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "1aa54db1-6876-426e-a4d2-552ae6736333",
   "metadata": {},
   "outputs": [],
   "source": [
    "city.gdf_parcels['zoning'].value_counts()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "e55f0263-8c69-4898-aadd-66db3ffe4488",
   "metadata": {},
   "outputs": [],
   "source": []
  }
 ],
 "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.10.6"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 5
}
