diff --git a/guide/10-mapping-and-visualization/advanced-map-widget-usage.ipynb b/guide/10-mapping-and-visualization/advanced-map-widget-usage.ipynb index 05e08a9c2..89328f06d 100644 --- a/guide/10-mapping-and-visualization/advanced-map-widget-usage.ipynb +++ b/guide/10-mapping-and-visualization/advanced-map-widget-usage.ipynb @@ -35,7 +35,7 @@ }, { "cell_type": "code", - "execution_count": 42, + "execution_count": 1, "metadata": {}, "outputs": [], "source": [ @@ -60,33 +60,16 @@ }, { "cell_type": "code", - "execution_count": 1, + "execution_count": 3, "metadata": {}, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "Intel MKL WARNING: Support of Intel(R) Streaming SIMD Extensions 4.2 (Intel(R) SSE4.2) enabled only processors has been deprecated. Intel oneAPI Math Kernel Library 2025.0 will require Intel(R) Advanced Vector Extensions (Intel(R) AVX) instructions.\n", - "Intel MKL WARNING: Support of Intel(R) Streaming SIMD Extensions 4.2 (Intel(R) SSE4.2) enabled only processors has been deprecated. Intel oneAPI Math Kernel Library 2025.0 will require Intel(R) Advanced Vector Extensions (Intel(R) AVX) instructions.\n" - ] - }, - { - "name": "stderr", - "output_type": "stream", - "text": [ - "/Users/john3092/opt/anaconda3/envs/geosaurus_dev_env/lib/python3.11/site-packages/dask/dataframe/_pyarrow_compat.py:23: UserWarning: You are using pyarrow version 11.0.0 which is known to be insecure. See https://www.cve.org/CVERecord?id=CVE-2023-47248 for further details. Please upgrade to pyarrow>=14.0.1 or install pyarrow-hotfix to patch your current version.\n", - " warnings.warn(\n" - ] - } - ], + "outputs": [], "source": [ "from arcgis.gis import GIS" ] }, { "cell_type": "code", - "execution_count": 237, + "execution_count": 4, "metadata": {}, "outputs": [ { @@ -95,7 +78,7 @@ "arcgis.map.map_widget.Map" ] }, - "execution_count": 237, + "execution_count": 4, "metadata": {}, "output_type": "execute_result" } @@ -106,7 +89,7 @@ }, { "cell_type": "code", - "execution_count": 238, + "execution_count": 5, "metadata": {}, "outputs": [ { @@ -115,7 +98,7 @@ "arcgis.map.scene_widget.Scene" ] }, - "execution_count": 238, + "execution_count": 5, "metadata": {}, "output_type": "execute_result" } @@ -209,7 +192,7 @@ }, { "cell_type": "code", - "execution_count": null, + "execution_count": 6, "metadata": {}, "outputs": [], "source": [ @@ -250,7 +233,7 @@ }, { "cell_type": "code", - "execution_count": 249, + "execution_count": 8, "metadata": {}, "outputs": [], "source": [ @@ -259,7 +242,7 @@ }, { "cell_type": "code", - "execution_count": 250, + "execution_count": 9, "metadata": {}, "outputs": [], "source": [ @@ -268,7 +251,7 @@ }, { "cell_type": "code", - "execution_count": 251, + "execution_count": 10, "metadata": {}, "outputs": [], "source": [ @@ -292,7 +275,7 @@ }, { "cell_type": "code", - "execution_count": 252, + "execution_count": 11, "metadata": {}, "outputs": [], "source": [ @@ -302,7 +285,7 @@ }, { "cell_type": "code", - "execution_count": 253, + "execution_count": 12, "metadata": {}, "outputs": [], "source": [ @@ -368,306 +351,6 @@ "my_zion_webscene_item" ] }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "## Rendering" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "The Python API also supports rendering symbols on the map wideget through defining properties. Once defined, the widget makes use of the Javascript API renderers. Try running the below code snippet to use a `SimpleRenderer` with a `LineSymbol3D` symbol. More on autocast renderers below." - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "You are only limitted in your visualization options by the Javascript API: you can specify any renderer and modify any properties of said renderer. To show how powerful this really is, let's use the SimpleRenderer's [visual variables](https://developers.arcgis.com/javascript/latest/api-reference/esri-renderers-SimpleRenderer.html#visualVariables) functionality. Run the below cell to see a standard Feature Layer about Hurricane tracks in 2D mode." - ] - }, - { - "cell_type": "code", - "execution_count": 2, - "metadata": {}, - "outputs": [], - "source": [ - "from arcgis.gis import GIS\n", - "from arcgis.layers import Service" - ] - }, - { - "cell_type": "code", - "execution_count": 3, - "metadata": {}, - "outputs": [], - "source": [ - "anon_gis = GIS()" - ] - }, - { - "cell_type": "code", - "execution_count": 45, - "metadata": {}, - "outputs": [], - "source": [ - "hurricane_layer = Service(\n", - " url_or_item=\"https://sampleserver6.arcgisonline.com/arcgis/rest/services/Hurricanes/MapServer/0\"\n", - ")" - ] - }, - { - "cell_type": "code", - "execution_count": 46, - "metadata": {}, - "outputs": [], - "source": [ - "hurricane_map = anon_gis.map('Atlantic Ocean')" - ] - }, - { - "cell_type": "code", - "execution_count": 47, - "metadata": {}, - "outputs": [ - { - "data": { - "application/vnd.jupyter.widget-view+json": { - "model_id": "814ae58630a447f2bc1d7a99ede4674c", - "version_major": 2, - "version_minor": 1 - }, - "text/plain": [ - "Map(center=[3716583.6647425774, -4155920.0458218013], extent={'xmin': -8511072.484127043, 'ymin': -835007.2772…" - ] - }, - "execution_count": 47, - "metadata": {}, - "output_type": "execute_result" - } - ], - "source": [ - "hurricane_map.content.add(hurricane_layer)\n", - "hurricane_map" - ] - }, - { - "cell_type": "code", - "execution_count": 48, - "metadata": {}, - "outputs": [], - "source": [ - "hurricane_map.legend.enabled=True" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "You can represent this same information on a 3D map by specifying a SimpleRenderer using white spheres. Run the below cell, click on some points, and examine some fields:" - ] - }, - { - "cell_type": "code", - "execution_count": 9, - "metadata": {}, - "outputs": [], - "source": [ - "from arcgis.map import Scene" - ] - }, - { - "cell_type": "code", - "execution_count": 10, - "metadata": {}, - "outputs": [], - "source": [ - "hurricane_map_3D = Scene(location='Atlantic Ocean')" - ] - }, - { - "cell_type": "code", - "execution_count": 11, - "metadata": {}, - "outputs": [], - "source": [ - "from arcgis.map import renderers, symbols" - ] - }, - { - "cell_type": "code", - "execution_count": 59, - "metadata": {}, - "outputs": [], - "source": [ - "os3d_layer = symbols.ObjectSymbol3DLayer(\n", - " resource=symbols.ObjectSymbol3DLayerResource(primitive=symbols.Primitive.sphere),\n", - " material=symbols.Material(color=[255,0,0]),\n", - " type=\"Object\",\n", - " width=100\n", - ")" - ] - }, - { - "cell_type": "code", - "execution_count": 62, - "metadata": {}, - "outputs": [], - "source": [ - "pt3d_symbol = symbols.PointSymbol3D(\n", - " symbol_layers = [os3d_layer]\n", - ")" - ] - }, - { - "cell_type": "code", - "execution_count": 64, - "metadata": {}, - "outputs": [ - { - "ename": "ValidationError", - "evalue": "1 validation error for PointSymbol3D\nsymbolLayers\n Field required [type=missing, input_value={'symbol': PointSymbol3D(...'type': 'PointSymbol3D'}, input_type=dict]\n For further information visit https://errors.pydantic.dev/2.5/v/missing", - "output_type": "error", - "traceback": [ - "\u001b[0;31m---------------------------------------------------------------------------\u001b[0m", - "\u001b[0;31mValidationError\u001b[0m Traceback (most recent call last)", - "Cell \u001b[0;32mIn[64], line 1\u001b[0m\n\u001b[0;32m----> 1\u001b[0m pt3d_renderer \u001b[38;5;241m=\u001b[39m renderers\u001b[38;5;241m.\u001b[39mPointSymbol3D(\n\u001b[1;32m 2\u001b[0m symbol\u001b[38;5;241m=\u001b[39mpt3d_symbol,\n\u001b[1;32m 3\u001b[0m \u001b[38;5;28mtype\u001b[39m\u001b[38;5;241m=\u001b[39m\u001b[38;5;124m\"\u001b[39m\u001b[38;5;124mPointSymbol3D\u001b[39m\u001b[38;5;124m\"\u001b[39m\n\u001b[1;32m 4\u001b[0m )\n", - "File \u001b[0;32m~/opt/anaconda3/envs/geosaurus_dev_env/lib/python3.11/site-packages/pydantic/main.py:164\u001b[0m, in \u001b[0;36mBaseModel.__init__\u001b[0;34m(__pydantic_self__, **data)\u001b[0m\n\u001b[1;32m 162\u001b[0m \u001b[38;5;66;03m# `__tracebackhide__` tells pytest and some other tools to omit this function from tracebacks\u001b[39;00m\n\u001b[1;32m 163\u001b[0m __tracebackhide__ \u001b[38;5;241m=\u001b[39m \u001b[38;5;28;01mTrue\u001b[39;00m\n\u001b[0;32m--> 164\u001b[0m __pydantic_self__\u001b[38;5;241m.\u001b[39m__pydantic_validator__\u001b[38;5;241m.\u001b[39mvalidate_python(data, self_instance\u001b[38;5;241m=\u001b[39m__pydantic_self__)\n", - "\u001b[0;31mValidationError\u001b[0m: 1 validation error for PointSymbol3D\nsymbolLayers\n Field required [type=missing, input_value={'symbol': PointSymbol3D(...'type': 'PointSymbol3D'}, input_type=dict]\n For further information visit https://errors.pydantic.dev/2.5/v/missing" - ] - } - ], - "source": [ - "pt3d_renderer = renderers.PointSymbol3D(\n", - " symbol=pt3d_symbol,\n", - " type=\"PointSymbol3D\"\n", - ")" - ] - }, - { - "cell_type": "code", - "execution_count": 51, - "metadata": {}, - "outputs": [ - { - "name": "stderr", - "output_type": "stream", - "text": [ - "ERROR:root:Renderer of type PointSymbol3D could not be created. Error: 2 validation errors for SimpleRenderer\n", - "symbol\n", - " Field required [type=missing, input_value={'symbolLayers': [{'ancho...'type': 'PointSymbol3D'}, input_type=dict]\n", - " For further information visit https://errors.pydantic.dev/2.5/v/missing\n", - "type\n", - " Input should be 'simple' [type=literal_error, input_value='PointSymbol3D', input_type=str]\n", - " For further information visit https://errors.pydantic.dev/2.5/v/literal_error\n" - ] - }, - { - "ename": "ValidationError", - "evalue": "1 validation error for FeatureLayerArcGISFeatureLayer\nlayerDefinition.timeInfo.timeIntervalUnits\n Input should be 'esriTimeUnitsCenturies', 'esriTimeUnitsDays', 'esriTimeUnitsDecades', 'esriTimeUnitsHours', 'esriTimeUnitsMilliseconds', 'esriTimeUnitsMinutes', 'esriTimeUnitsMonths', 'esriTimeUnitsSeconds', 'esriTimeUnitsUnknown', 'esriTimeUnitsWeeks' or 'esriTimeUnitsYears' [type=enum, input_value=, input_type=TimeIntervalUnits]", - "output_type": "error", - "traceback": [ - "\u001b[0;31m---------------------------------------------------------------------------\u001b[0m", - "\u001b[0;31mValidationError\u001b[0m Traceback (most recent call last)", - "Cell \u001b[0;32mIn[51], line 1\u001b[0m\n\u001b[0;32m----> 1\u001b[0m hurricane_map_3D\u001b[38;5;241m.\u001b[39mcontent\u001b[38;5;241m.\u001b[39madd(\n\u001b[1;32m 2\u001b[0m item\u001b[38;5;241m=\u001b[39mhurricane_layer,\n\u001b[1;32m 3\u001b[0m drawing_info\u001b[38;5;241m=\u001b[39m{\n\u001b[1;32m 4\u001b[0m \u001b[38;5;124m\"\u001b[39m\u001b[38;5;124mrenderer\u001b[39m\u001b[38;5;124m\"\u001b[39m: pt3d_renderer\n\u001b[1;32m 5\u001b[0m }\n\u001b[1;32m 6\u001b[0m )\n", - "File \u001b[0;32m~/opt/anaconda3/envs/geosaurus_dev_env/lib/python3.11/site-packages/arcgis/map/scene_widget.py:920\u001b[0m, in \u001b[0;36mSceneContent.add\u001b[0;34m(self, item, drawing_info, popup_info, index)\u001b[0m\n\u001b[1;32m 917\u001b[0m \u001b[38;5;28;01mreturn\u001b[39;00m\n\u001b[1;32m 918\u001b[0m \u001b[38;5;28;01melse\u001b[39;00m:\n\u001b[1;32m 919\u001b[0m \u001b[38;5;66;03m# Only one layer, create the layer and add\u001b[39;00m\n\u001b[0;32m--> 920\u001b[0m layer \u001b[38;5;241m=\u001b[39m \u001b[38;5;28mself\u001b[39m\u001b[38;5;241m.\u001b[39m_helper\u001b[38;5;241m.\u001b[39m_create_layer_from_item(item, drawing_info, popup_info)\n\u001b[1;32m 921\u001b[0m \u001b[38;5;28mself\u001b[39m\u001b[38;5;241m.\u001b[39mlayers\u001b[38;5;241m.\u001b[39minsert(index, item)\n\u001b[1;32m 923\u001b[0m \u001b[38;5;66;03m# Check that layer is not None at this point\u001b[39;00m\n", - "File \u001b[0;32m~/opt/anaconda3/envs/geosaurus_dev_env/lib/python3.11/site-packages/arcgis/map/_utils.py:1053\u001b[0m, in \u001b[0;36m_HelperMethods._create_layer_from_item\u001b[0;34m(self, layer, drawing_info, popup_info)\u001b[0m\n\u001b[1;32m 1051\u001b[0m ld \u001b[38;5;241m=\u001b[39m \u001b[38;5;28;01mNone\u001b[39;00m\n\u001b[1;32m 1052\u001b[0m popup \u001b[38;5;241m=\u001b[39m \u001b[38;5;28mself\u001b[39m\u001b[38;5;241m.\u001b[39m_create_popup_dataclass(layer, popup_info)\n\u001b[0;32m-> 1053\u001b[0m \u001b[38;5;28;01mreturn\u001b[39;00m \u001b[38;5;28mself\u001b[39m\u001b[38;5;241m.\u001b[39mspec\u001b[38;5;241m.\u001b[39mFeatureLayerArcGISFeatureLayer(\n\u001b[1;32m 1054\u001b[0m \u001b[38;5;241m*\u001b[39m\u001b[38;5;241m*\u001b[39mproperties,\n\u001b[1;32m 1055\u001b[0m url\u001b[38;5;241m=\u001b[39mlayer\u001b[38;5;241m.\u001b[39m_url,\n\u001b[1;32m 1056\u001b[0m layerDefinition\u001b[38;5;241m=\u001b[39mld,\n\u001b[1;32m 1057\u001b[0m popupInfo\u001b[38;5;241m=\u001b[39mpopup,\n\u001b[1;32m 1058\u001b[0m itemId\u001b[38;5;241m=\u001b[39mitem_id,\n\u001b[1;32m 1059\u001b[0m title\u001b[38;5;241m=\u001b[39mproperties[\u001b[38;5;124m\"\u001b[39m\u001b[38;5;124mname\u001b[39m\u001b[38;5;124m\"\u001b[39m],\n\u001b[1;32m 1060\u001b[0m )\n\u001b[1;32m 1061\u001b[0m \u001b[38;5;28;01melif\u001b[39;00m \u001b[38;5;28misinstance\u001b[39m(layer, arcgis_layers\u001b[38;5;241m.\u001b[39mVectorTileLayer):\n\u001b[1;32m 1062\u001b[0m style_url \u001b[38;5;241m=\u001b[39m \u001b[38;5;124mf\u001b[39m\u001b[38;5;124m\"\u001b[39m\u001b[38;5;132;01m{\u001b[39;00mlayer\u001b[38;5;241m.\u001b[39m_url\u001b[38;5;132;01m}\u001b[39;00m\u001b[38;5;124m/resources/styles/root.json\u001b[39m\u001b[38;5;124m\"\u001b[39m\n", - "File \u001b[0;32m~/opt/anaconda3/envs/geosaurus_dev_env/lib/python3.11/site-packages/pydantic/main.py:164\u001b[0m, in \u001b[0;36mBaseModel.__init__\u001b[0;34m(__pydantic_self__, **data)\u001b[0m\n\u001b[1;32m 162\u001b[0m \u001b[38;5;66;03m# `__tracebackhide__` tells pytest and some other tools to omit this function from tracebacks\u001b[39;00m\n\u001b[1;32m 163\u001b[0m __tracebackhide__ \u001b[38;5;241m=\u001b[39m \u001b[38;5;28;01mTrue\u001b[39;00m\n\u001b[0;32m--> 164\u001b[0m __pydantic_self__\u001b[38;5;241m.\u001b[39m__pydantic_validator__\u001b[38;5;241m.\u001b[39mvalidate_python(data, self_instance\u001b[38;5;241m=\u001b[39m__pydantic_self__)\n", - "\u001b[0;31mValidationError\u001b[0m: 1 validation error for FeatureLayerArcGISFeatureLayer\nlayerDefinition.timeInfo.timeIntervalUnits\n Input should be 'esriTimeUnitsCenturies', 'esriTimeUnitsDays', 'esriTimeUnitsDecades', 'esriTimeUnitsHours', 'esriTimeUnitsMilliseconds', 'esriTimeUnitsMinutes', 'esriTimeUnitsMonths', 'esriTimeUnitsSeconds', 'esriTimeUnitsUnknown', 'esriTimeUnitsWeeks' or 'esriTimeUnitsYears' [type=enum, input_value=, input_type=TimeIntervalUnits]" - ] - } - ], - "source": [ - "hurricane_map_3D.content.add(\n", - " item=hurricane_layer,\n", - " drawing_info={\n", - " \"renderer\": pt3d_renderer\n", - " }\n", - ")" - ] - }, - { - "cell_type": "code", - "execution_count": 52, - "metadata": {}, - "outputs": [ - { - "data": { - "application/vnd.jupyter.widget-view+json": { - "model_id": "81ec8d571d1443c19a7a73503d3d98e4", - "version_major": 2, - "version_minor": 1 - }, - "text/plain": [ - "Scene(camera={'heading': 0.0, 'position': {'spatialReference': {'latestWkid': 3857, 'wkid': 102100}, 'x': -415…" - ] - }, - "execution_count": 52, - "metadata": {}, - "output_type": "execute_result" - } - ], - "source": [ - "hurricane_map_3D" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "Now that we have the base set up, lets specify the `visualVariables` field to vary the color of each point for the changing `PRESSURE` field, and vary the size of each point for the changing `WINDSPEED` field. Run the below cell, then try modifying the options to see different results! Maybe try tuning the `\"value\"` fields to see different color and size variations." - ] - }, - { - "cell_type": "code", - "execution_count": 17, - "metadata": {}, - "outputs": [ - { - "data": { - "text/html": [ - "" - ], - "text/plain": [ - "" - ] - }, - "execution_count": 17, - "metadata": {}, - "output_type": "execute_result" - } - ], - "source": [ - "visual_var_map = anon_gis.map('Atlantic Ocean', mode=\"3D\")\n", - "\n", - "#Update the renderer to include visual variable information\n", - "renderer[\"visualVariables\"] = [{ #JS configuration of visualVariables\n", - " \"type\": \"color\",\n", - " \"field\": \"PRESSURE\", \n", - " \"stops\": [\n", - " { \"value\": 950, \"color\": \"red\" },\n", - " { \"value\": 1020, \"color\": \"blue\" }\n", - " ]\n", - " }, {\n", - " \"type\": \"size\",\n", - " \"field\": \"WINDSPEED\",\n", - " \"stops\": [\n", - " { \"value\": 20, \"size\": 60000 },\n", - " { \"value\": 150, \"size\": 500000 }\n", - " ],\n", - " \"axis\": \"height\"\n", - " }, {\n", - " \"type\": \"size\",\n", - " \"axis\": \"width-and-depth\",\n", - " \"useSymbolValue\": True\n", - " }]\n", - "visual_var_map.content.add(hurricane_layer, renderer)\n", - "visual_var_map" - ] - }, { "cell_type": "markdown", "metadata": {}, @@ -695,14 +378,14 @@ "name": "stdout", "output_type": "stream", "text": [ - "html saved as /Users/john3092/Job/data_formats/html_pages/myHurricaneMap.html\n" + "html saved as /Users//path/data_formats/html_pages/myHurricaneMap.html\n" ] } ], "source": [ "import os\n", "\n", - "file_dir = r\"/Users/john3092/Job/data_formats/html_pages\"\n", + "file_dir = r\"/Users//path/data_formats/html_pages\"\n", "if not os.path.isdir(file_dir):\n", " os.mkdir(file_dir)\n", " \n",