Spaces:
Sleeping
Sleeping
File size: 4,191 Bytes
a2e63bc | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 | {
"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
}
|