{ "cells": [ { "cell_type": "code", "execution_count": 1, "id": "770d1893-70b9-4c65-8651-903346f355a9", "metadata": {}, "outputs": [], "source": [ "%load_ext autoreload\n", "%autoreload 2\n", "from prettymapp.geo import get_aoi\n", "from prettymapp.osm import get_osm_geometries\n", "from prettymapp.plotting import Plot\n", "from prettymapp.settings import STYLES" ] }, { "cell_type": "code", "execution_count": 2, "id": "568f32ec", "metadata": {}, "outputs": [], "source": [ "aoi = get_aoi(address=\"Praça Ferreira do Amaral, Macau\", radius=1100, rectangular=False)" ] }, { "cell_type": "code", "execution_count": null, "id": "2e574053", "metadata": {}, "outputs": [], "source": [ "# Regular example\n", "df = get_osm_geometries(aoi=aoi)\n", "\n", "fig = Plot(\n", " df=df,\n", " aoi_bounds=aoi.bounds,\n", " draw_settings=STYLES[\"Peach\"],\n", ").plot_all()\n" ] }, { "cell_type": "code", "execution_count": null, "id": "1321e1fb-82d9-4d15-a4a3-696422063ecc", "metadata": {}, "outputs": [], "source": [ "# Plot from OSM XML file\n", "from prettymapp.osm import get_osm_geometries_from_xml\n", "\n", "df = get_osm_geometries_from_xml(filepath=\"./tests/mock_data/osm_xml_file.osm\")\n", "aoi_bounds = df.total_bounds\n", "\n", "fig = Plot(\n", " df=df,\n", " aoi_bounds=aoi_bounds,\n", ").plot_all()" ] }, { "cell_type": "code", "execution_count": null, "id": "787f0a25-0eb4-45de-8889-2db572c09c26", "metadata": {}, "outputs": [], "source": [ "# Customize plotting style\n", "from prettymapp.settings import STYLES\n", "\n", "custom_style = STYLES[\"Peach\"].copy()\n", "custom_style[\"urban\"] = {\n", " \"cmap\": [\"#3452eb\"],\n", " \"ec\": \"#E9724C\",\n", " \"lw\": 0.2,\n", " \"zorder\": 4,\n", "}\n", "\n", "fig = Plot(\n", " df=df,\n", " aoi_bounds=aoi.bounds,\n", " draw_settings=custom_style,\n", " shape=\"circle\",\n", " contour_width=0,\n", " credits=False,\n", ").plot_all()" ] }, { "cell_type": "code", "execution_count": null, "id": "82d6dd94", "metadata": {}, "outputs": [], "source": [ "# Customize landcover classes\n", "\n", "# 1. Overwrite specific classes\n", "from prettymapp.settings import LANDCOVER_CLASSES\n", "custom_lc_classes = LANDCOVER_CLASSES.copy()\n", "custom_lc_classes[\"urban\"][\"building\"] = False # drops all building subclasses\n", "custom_lc_classes[\"grassland\"][\"leisure\"] = True # Include all leisure subclasses\n", "custom_lc_classes[\"grassland\"][\"natural\"] = [\"island\"] # Selects only specific natural subclasses\n", "\n", "# 2. Or completely custom\n", "# custom_lc_classes ={\n", "# \"water\": {\n", "# \"natural\": [\"water\", \"bay\"],\n", "# \"place\": [\"sea\"],\n", "# },\n", "# \"woodland\": {\"landuse\": [\"forest\"]},\n", "# \"grassland\": {\n", "# \"natural\": [\"island\", \"wood\"],\n", "# },\n", "# \"streets\": {\n", "# \"highway\": [\n", "# \"motorway\",\n", "# \"trunk\",\n", "# \"primary\",\n", "# \"secondary\",\n", "# ],\n", "# \"railway\": True,\n", "# }\n", "# }\n", "\n", "df = get_osm_geometries(aoi=aoi, landcover_classes=custom_lc_classes)\n", "\n", "fig = Plot(\n", " df=df,\n", " aoi_bounds=aoi.bounds,\n", ").plot_all()" ] } ], "metadata": { "kernelspec": { "display_name": ".venv", "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.11.10" } }, "nbformat": 4, "nbformat_minor": 5 }