diff --git a/samples/05_content_publishers/using_and_updating_GIS_content.ipynb b/samples/05_content_publishers/using_and_updating_GIS_content.ipynb
index 7d02788b1..0f92fb452 100644
--- a/samples/05_content_publishers/using_and_updating_GIS_content.ipynb
+++ b/samples/05_content_publishers/using_and_updating_GIS_content.ipynb
@@ -6,13 +6,12 @@
"source": [
"# Using and updating GIS content\n",
"\n",
- "The GIS is a warehouse of geographic content and services. ArcGIS includes several classes to make use of this content, publish new items and update them when needed. This sample on updating the content of web maps and web scenes will demonstrate the following\n",
- " * **Replace web layers** of a web map. For instance, you can use this to update a web map when the services it points to were deleted. The sample shows how to read a web feature layer as a **FeatureService** object and inspect its properties.\n",
- " * **Drive the map widget by code**. In addition to displaying the interactive map widget, you can also set it to load at a particular extent. This is great for presentation purposes. During this process, the sample shows how to create and use a **MapView** object and a **Geocoder** object.\n",
+ "The GIS is a warehouse of geographic content and services. Arcgis includes several classes to make use of these content, publish new items and update the them when needed. This sample on updating the content of web maps and web scenes will demonstrate the following\n",
+ " * **Replace web layers** of a web map. For instance, you can use this to update a web map when the services it points to were deleted. The sample shows how to Create a web feature layer as a **FeatureService** object and perform operations on it.\n",
+ " * **Drive the map widget by code**. In addition to displaying the interactive map widget, you can also set it to load at a particular extent. This is great for presentation purposes. During this process, the sample shows how to create and use a **Map** object.\n",
" * Make a **copy of a public web scene** item into your contents and then update it.\n",
" * Edit the list of layers to remove unnecessary ones.\n",
- " * **Replace the basemap** of the web scene. In this step the sample shows how to search for **groups** and query the member items.\n",
- " * Change visibility of layers."
+ " * **Replace the basemap** of the web scene. "
]
},
{
@@ -22,20 +21,50 @@
},
"source": [
"
Table of Contents
\n",
- ""
+ "\n",
+ "
\n",
+ " - 1 Using and updating GIS content
\n",
+ " - \n",
+ " 2 Creating a web map and feature layer\n",
+ " \n",
+ "
\n",
+ " - \n",
+ " 3 Using and updating a web map\n",
+ " \n",
+ "
\n",
+ " - \n",
+ " 4 Using and updating a web scene\n",
+ " \n",
+ "
\n",
+ " - 5 Summary
\n",
+ "
\n",
+ "
"
]
},
{
"cell_type": "code",
"execution_count": 2,
"metadata": {},
- "outputs": [
- ],
+ "outputs": [],
"source": [
- "from arcgis.gis import GIS\n",
- "from arcgis.mapping import WebMap, WebScene\n",
+ "from arcgis.gis import GIS, ItemTypeEnum\n",
+ "from arcgis.map import Map, Scene\n",
"from IPython.display import display\n",
- "import json\n",
"\n",
"gis = GIS(profile=\"your_online_profile\")"
]
@@ -44,39 +73,32 @@
"cell_type": "markdown",
"metadata": {},
"source": [
- "## Creating a web map and feature layer\n",
+ "# Creating a web map and feature layer\n",
"We will will create a feature layer and a web map. We will then delete the feature layer and re-publish. This will change the service and leave us with a broken layer inside our map, don't worry we will fix this in the next steps."
]
},
{
"cell_type": "markdown",
- "metadata": {},
+ "metadata": {
+ "jp-MarkdownHeadingCollapsed": true
+ },
"source": [
"### Create a feature layer"
]
},
{
"cell_type": "code",
- "execution_count": null,
+ "execution_count": 3,
"metadata": {},
"outputs": [],
"source": [
"my_csv = 'data/updating_gis_content/capitals_1.csv'\n",
- "item_prop = {'title':'USA Capitals spreadsheet for WebMap'}\n",
- "csv_item = gis.content.add(item_properties=item_prop, data=my_csv)\n",
- "capitals_item = csv_item.publish()"
- ]
- },
- {
- "cell_type": "markdown",
- "metadata": {},
- "source": [
- "### Create WebMap, Add Layer, and Save"
+ "item_prop = {'title':'USA Capitals spreadsheet for WebMap', 'type':'CSV'}"
]
},
{
"cell_type": "code",
- "execution_count": 20,
+ "execution_count": 6,
"metadata": {},
"outputs": [
{
@@ -84,309 +106,213 @@
"text/html": [
"\n",
"
\n",
"\n",
"
\n",
- "
USA Capitals WebMap\n",
+ " USA Capitals spreadsheet for WebMap\n",
" \n",
- "
A webmap that contains USA capitals as a feature layer.
Web Map by arcgis_python\n",
- "
Last Modified: April 15, 2024\n",
+ "
CSV by python_user\n",
+ "
Last Modified: November 05, 2024\n",
"
0 comments, 0 views\n",
"
\n",
"
\n",
" "
],
"text/plain": [
- "- "
+ "
- "
]
},
- "execution_count": 20,
+ "execution_count": 6,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
- "wm = WebMap()\n",
- "wm.add_layer(capitals_item)\n",
- "wm.save(\n",
- " {\n",
- " \"title\": \"USA Capitals WebMap\", \n",
- " \"tags\": [\"python\", \"webmap\"], \n",
- " \"snippet\": \"A webmap that contains USA capitals as a feature layer.\"\n",
- " }\n",
- ")"
- ]
- },
- {
- "cell_type": "markdown",
- "metadata": {},
- "source": [
- "### Delete Feature Layer and re-publish\n",
- "Why? This seems a bit weird to put in a sample, but this demonstrates how some feature layers can get deleted without us realizing that they are part of webmaps. Below we will get the webmap and see that the layer does not show up! \n",
- "This sample can then guide you to fix this problem of missing layers."
- ]
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "metadata": {},
- "outputs": [],
- "source": [
- "capitals_item.delete()"
+ "folder = gis.content.folders.get()\n",
+ "csv_item = folder.add(item_properties = item_prop, file=my_csv).result()"
]
},
{
"cell_type": "code",
- "execution_count": 21,
+ "execution_count": 32,
"metadata": {},
"outputs": [
{
"data": {
- "text/html": [
- "
\n",
- "
\n",
- "\n",
- "
\n",
- "
\n",
- " "
- ],
"text/plain": [
- "- "
+ "[
- ,\n",
+ "
- ]"
]
},
- "execution_count": 21,
+ "execution_count": 32,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
- "# re-publish so we can find it again\n",
- "new_capitals = csv_item.publish()\n",
- "new_capitals"
- ]
- },
- {
- "cell_type": "markdown",
- "metadata": {},
- "source": [
- "## Using and updating a web map\n",
- "We will search for that web map that has broken layers, render it on the notebook and update it."
+ "gis.content.search(\"title:'USA Capitals spreadsheet for WebMap' \", outside_org=True)"
]
},
{
"cell_type": "code",
- "execution_count": null,
+ "execution_count": 34,
"metadata": {},
"outputs": [],
"source": [
- "search_result = gis.content.search(\"title:USA Capitals WebMap\", item_type = \"Web Map\")"
- ]
- },
- {
- "cell_type": "markdown",
- "metadata": {},
- "source": [
- "Read the web map as a `WebMap` object"
+ "feature_service_list = gis.content.search(\"title:'USA Capitals spreadsheet for WebMap' , type:Feature Service\")"
]
},
{
"cell_type": "code",
- "execution_count": 23,
+ "execution_count": 35,
"metadata": {},
"outputs": [],
"source": [
- "wm_item = search_result[0]\n",
- "web_map_obj = WebMap(wm_item)"
+ "capitals_item = None\n",
+ "if not feature_service_list:\n",
+ " capitals_item = csv_item.publish()\n",
+ "else:\n",
+ " capitals_item = feature_service_list[0]"
]
},
{
"cell_type": "code",
- "execution_count": 6,
+ "execution_count": 36,
"metadata": {},
"outputs": [
{
"data": {
"text/html": [
- ""
+ "
\n",
+ "
\n",
+ "\n",
+ "
\n",
+ "
\n",
+ " "
],
"text/plain": [
- ""
+ "- "
]
},
- "execution_count": 6,
+ "execution_count": 36,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
- "# display the web map obj in an interactive widget\n",
- "web_map_obj"
+ "capitals_item"
]
},
{
"cell_type": "markdown",
- "metadata": {},
+ "metadata": {
+ "jp-MarkdownHeadingCollapsed": true
+ },
"source": [
- "### Fix errors in web map\n",
- "The widget loads an empty web map with just a basemap. Let us investigate the contents of the web map to determine the issue. You can query the layers in the web map using the `layers` property."
+ "### Create WebMap, Add Layer, and Save"
]
},
{
"cell_type": "code",
- "execution_count": 26,
+ "execution_count": 17,
"metadata": {},
"outputs": [
{
"data": {
+ "text/html": [
+ "
\n",
+ "
\n",
+ "\n",
+ "
\n",
+ "
USA Capitals WebMap\n",
+ " \n",
+ "
A webmap that contains USA capitals as a feature layer.
Web Map by python_user\n",
+ "
Last Modified: October 24, 2024\n",
+ "
0 comments, 0 views\n",
+ "
\n",
+ "
\n",
+ " "
+ ],
"text/plain": [
- "[{\n",
- " \"title\": \"USA_Capitals_spreadsheet_for_WebMap\",\n",
- " \"opacity\": 1,\n",
- " \"visibility\": true,\n",
- " \"id\": \"5053d89e-4861-47a6-a4d3-3bbd9cc27bf0\",\n",
- " \"layerDefinition\": {\n",
- " \"definitionExpression\": null,\n",
- " \"drawingInfo\": {\n",
- " \"renderer\": {\n",
- " \"type\": \"simple\",\n",
- " \"symbol\": {\n",
- " \"type\": \"esriPMS\",\n",
- " \"url\": \"RedSphere.png\",\n",
- " \"imageData\": \"iVBORw0KGgoAAAANSUhEUgAAAEAAAABACAYAAACqaXHeAAAABGdBTUEAALGPC/xhBQAAACBjSFJNAAB6JgAAgIQAAPoAAACA6AAAdTAAAOpgAAA6mAAAF3CculE8AAAACXBIWXMAAA7DAAAOwwHHb6hkAAAAGXRFWHRTb2Z0d2FyZQBQYWludC5ORVQgdjMuNS4xTuc4+QAAB3VJREFUeF7tmPlTlEcexnve94U5mANQbgQSbgiHXHINlxpRIBpRI6wHorLERUmIisKCQWM8cqigESVQS1Kx1piNi4mW2YpbcZONrilE140RCTcy3DDAcL/zbJP8CYPDL+9Ufau7uqb7eZ7P+/a8PS8hwkcgIBAQCAgEBAICAYGAQEAgIBAQCAgEBAICAYGAQEAgIBAQCDx/AoowKXFMUhD3lQrioZaQRVRS+fxl51eBTZUTdZ41U1Rox13/0JF9csGJ05Qv4jSz/YPWohtvLmSKN5iTGGqTm1+rc6weICOBRbZs1UVnrv87T1PUeovxyNsUP9P6n5cpHtCxu24cbrmwKLdj+osWiqrVKhI0xzbmZ7m1SpJ+1pFpvE2DPvGTomOxAoNLLKGLscZYvB10cbYYjrJCb7A5mrxleOBqim+cWJRakZY0JfnD/LieI9V1MrKtwokbrAtU4Vm0A3TJnphJD4B+RxD0u0LA7w7FTE4oprOCMbklEGNrfdGf4IqnQTb4wc0MFTYibZqM7JgjO8ZdJkpMln/sKu16pHZGb7IfptIWg389DPp9kcChWODoMuDdBOhL1JgpisbUvghM7AqFbtNiaFP80RLnhbuBdqi0N+1dbUpWGde9gWpuhFi95yL7sS7BA93JAb+Fn8mh4QujgPeTgb9kAZf3Apd2A+fXQ38yHjOHozB1IAJjOSEY2RSIwVUv4dd4X9wJccGHNrJ7CYQ4GGjLeNNfM+dyvgpzQstKf3pbB2A6m97uBRE0/Ergcxr8hyqg7hrwn0vAtRIKIRX6Y2pMl0RhIj8co9nBGFrvh55l3ngU7YObng7IVnFvGS+BYUpmHziY/Ls2zgP9SX50by/G9N5w6I+ogYvpwK1SoOlHQNsGfWcd9Peqof88B/rTyzF9hAIopAByQzC0JQB9ST5oVnvhnt+LOGsprvUhxNIwa0aY7cGR6Cp7tr8+whkjawIxkRWC6YJI6N+lAKq3Qf/Tx+B77oGfaQc/8hB8w2Xwtw9Bf3kzZspXY/JIDEbfpAB2BKLvVV90Jvjgoac9vpRxE8kciTVCBMMkNirJ7k/tRHyjtxwjKV4Yp3t/6s+R4E+/DH3N6+BrS8E314Dvvg2+/Sb4hxfBf5sP/up2TF3ZhonK1zD6dhwGdwail26DzqgX8MRKiq9ZBpkSkmeYOyPM3m9Jjl+1Z9D8AgNtlAq6bZ70qsZi+q+bwV/7I/hbB8D/dAr8Axq89iz474p/G5++koHJy1sx/lkGdBc2YjA3HF0rHNHuboomuQj/5DgclIvOGCGCYRKFFuTMV7YUAD3VDQaLMfyqBcZORGPy01QKYSNm/rYV/Nd/Av9NHvgbueBrsjDzRQamKKDxT9Kgq1iLkbIUDOSHoiNcgnYHgnYZi+9ZExSbiSoMc2eE2flKcuJLa4KGRQz6/U0wlGaP0feiMH4uFpMXEjBVlYjp6lWY+SSZtim0kulYMiYuJEJXuhTDJ9UYPByOvoIwdCxfgE4bAo0Jh39xLAoVpMwIEQyTyFCQvGpLon9sJ0K3J4OBDDcMH1dj9FQsxkrjMPFRPCbOx2GyfLal9VEcxstioTulxjAFNfROJPqLl6Bnfyg6V7ugz5yBhuHwrZjBdiU5YJg7I8wOpifAKoVIW7uQ3rpOBH2b3ekVjYT2WCRG3o+mIGKgO0OrlIaebU/HYOQDNbQnojB4NJyGD0NPfjA0bwTRE6Q7hsUcWhkWN8yZqSQlWWGECAZLmJfJmbrvVSI8taK37xpbdB/wQW8xPee/8xIGjvlj8IQ/hk4G0JbWcX8MHPVDX4kveoq8ocn3xLM33NCZRcPHOGJYZIKfpQyq7JjHS6yJjcHujLHADgkpuC7h8F8zEVqXSNC2awE69lqhs8AamkO26HrbDt2H7dBVQov2NcW26CiwQtu+BWjdY4n2nZboTbfCmKcCnRyDO/YmyLPnDlHvjDH8G6zhS9/wlEnYR7X00fWrFYuWdVI0ZpuhcbcczW/R2qdAcz6t/bRov4mONeaaoYl+p22rHF0bVNAmKtBvweIXGxNcfFH8eNlC4m6wMWMusEnKpn5hyo48pj9gLe4SNG9QoGGLAk8z5XiaJUd99u8122/IpBA2K9BGg2vWWKAvRYVeLzEa7E1R422m2+MsSTem97nSYnfKyN6/mzATv7AUgqcMrUnmaFlLX3ysM0fj+t/b5lQLtK22QEfyAmiSLKFZpUJ7kBRPXKW4HqCYynWVHKSG2LkyZex1uO1mZM9lKem9Tx9jjY5iNEYo0bKMhn7ZAu0r6H5PpLXCAq0rKJClSjSGynE/QIkrQYqBPe6S2X+AJsY2Ped6iWZk6RlL0c2r5szofRsO9R5S1IfQLRCpQL1aifoYFerpsbkuTImaUJXuXIDiH6/Ys8vm3Mg8L2i20YqsO7fItKLcSXyn0kXccclVqv3MS6at9JU/Ox+ouns+SF6Z4cSupz7l8+z1ucs7LF1AQjOdxfGZzmx8Iu1TRcfnrioICAQEAgIBgYBAQCAgEBAICAQEAgIBgYBAQCAgEBAICAQEAv8H44b/6ZiGvGAAAAAASUVORK5CYII=\",\n",
- " \"contentType\": \"image/png\",\n",
- " \"width\": 15,\n",
- " \"height\": 15\n",
- " }\n",
- " }\n",
- " }\n",
- " },\n",
- " \"layerType\": \"ArcGISFeatureLayer\",\n",
- " \"itemId\": \"eea32f0a785948b88d612e639cfa02a1\",\n",
- " \"url\": \"https://services7.arcgis.com/JEwYeAy2cc8qOe3o/arcgis/rest/services/USA_Capitals_spreadsheet_for_WebMap/FeatureServer/0\",\n",
- " \"popupInfo\": {\n",
- " \"title\": \"USA_Capitals_spreadsheet_for_WebMap\",\n",
- " \"fieldInfos\": [\n",
- " {\n",
- " \"fieldName\": \"city_id\",\n",
- " \"label\": \"city_id\",\n",
- " \"isEditable\": true,\n",
- " \"visible\": true\n",
- " },\n",
- " {\n",
- " \"fieldName\": \"name\",\n",
- " \"label\": \"name\",\n",
- " \"isEditable\": true,\n",
- " \"visible\": true\n",
- " },\n",
- " {\n",
- " \"fieldName\": \"state\",\n",
- " \"label\": \"state\",\n",
- " \"isEditable\": true,\n",
- " \"visible\": true\n",
- " },\n",
- " {\n",
- " \"fieldName\": \"capital\",\n",
- " \"label\": \"capital\",\n",
- " \"isEditable\": true,\n",
- " \"visible\": true\n",
- " },\n",
- " {\n",
- " \"fieldName\": \"pop2000\",\n",
- " \"label\": \"pop2000\",\n",
- " \"isEditable\": true,\n",
- " \"visible\": true\n",
- " },\n",
- " {\n",
- " \"fieldName\": \"pop2007\",\n",
- " \"label\": \"pop2007\",\n",
- " \"isEditable\": true,\n",
- " \"visible\": true\n",
- " },\n",
- " {\n",
- " \"fieldName\": \"longitude\",\n",
- " \"label\": \"longitude\",\n",
- " \"isEditable\": true,\n",
- " \"visible\": true\n",
- " },\n",
- " {\n",
- " \"fieldName\": \"latitude\",\n",
- " \"label\": \"latitude\",\n",
- " \"isEditable\": true,\n",
- " \"visible\": true\n",
- " },\n",
- " {\n",
- " \"fieldName\": \"ObjectId\",\n",
- " \"label\": \"ObjectId\",\n",
- " \"isEditable\": false,\n",
- " \"visible\": true\n",
- " }\n",
- " ],\n",
- " \"description\": null,\n",
- " \"showAttachments\": true,\n",
- " \"mediaInfos\": []\n",
- " }\n",
- " }]"
+ "- "
]
},
- "execution_count": 26,
+ "execution_count": 17,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
- "web_map_obj.layers"
+ "wm = Map()\n",
+ "wm.content.add(capitals_item)\n",
+ "wm.save({\"title\": \"USA Capitals WebMap\", \"tags\": [\"python\", \"webmap\"], \"snippet\": \"A webmap that contains USA capitals as a feature layer.\"})"
+ ]
+ },
+ {
+ "cell_type": "markdown",
+ "metadata": {
+ "jp-MarkdownHeadingCollapsed": true
+ },
+ "source": [
+ "### Delete Feature Layer and re-publish\n",
+ "Why? This seems a bit weird to put in a sample, but this demonstrates how some feature layers can get deleted without us realizing that they are part of webmaps. Below we will get the webmap and see that the layer does not show up! \n",
+ "This sample can then guide you to fix this problem of missing layers."
]
},
{
"cell_type": "code",
- "execution_count": 27,
+ "execution_count": 37,
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
- "'eea32f0a785948b88d612e639cfa02a1'"
+ "True"
]
},
- "execution_count": 27,
+ "execution_count": 37,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
- "# Feature service item id for the missing layer:\n",
- "web_map_obj.layers[0][\"itemId\"]"
+ "capitals_item.delete(permanent=True)"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
- "The web map has only 1 layer and that points to a feature service named **USA_Capitals_spreadsheet_for_WebMap**. Let us verify if a feature service of that name exists on the server. If not, let us try to find the closest match."
+ "# Using and updating a web map\n",
+ "We will search for that web map that has broken layers, render it on the notebook and update it."
]
},
{
"cell_type": "code",
- "execution_count": 28,
+ "execution_count": 39,
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
- "[
- ]"
+ "[
- ]"
]
},
"metadata": {},
@@ -394,7 +320,7 @@
}
],
"source": [
- "search_result = gis.content.search('title:USA_Capitals_spreadsheet_for_WebMap', item_type = 'Feature Service')\n",
+ "search_result = gis.content.search(\"title:USA Capitals WebMap\", item_type = \"Web Map\")\n",
"display(search_result)"
]
},
@@ -402,131 +328,190 @@
"cell_type": "markdown",
"metadata": {},
"source": [
- "Let's check the itemId to make sure it is different. This means we have re-published it and the service was changed."
+ "Read the web map as a `WebMap` object"
]
},
{
"cell_type": "code",
- "execution_count": 29,
+ "execution_count": 40,
+ "metadata": {},
+ "outputs": [],
+ "source": [
+ "wm_item = search_result[0]\n",
+ "web_map_obj = Map(wm_item)"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": 24,
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
- "'62cf777b13ab4693897fccc5a00d76f7'"
+ "['satellite',\n",
+ " 'hybrid',\n",
+ " 'terrain',\n",
+ " 'oceans',\n",
+ " 'osm',\n",
+ " 'dark-gray-vector',\n",
+ " 'gray-vector',\n",
+ " 'streets-vector',\n",
+ " 'topo-vector',\n",
+ " 'streets-night-vector',\n",
+ " 'streets-relief-vector',\n",
+ " 'streets-navigation-vector',\n",
+ " 'arcgis-imagery',\n",
+ " 'arcgis-imagery-standard',\n",
+ " 'arcgis-imagery-labels',\n",
+ " 'arcgis-light-gray',\n",
+ " 'arcgis-dark-gray',\n",
+ " 'arcgis-navigation',\n",
+ " 'arcgis-navigation-night',\n",
+ " 'arcgis-streets',\n",
+ " 'arcgis-streets-night',\n",
+ " 'arcgis-streets-relief',\n",
+ " 'arcgis-topographic',\n",
+ " 'arcgis-oceans',\n",
+ " 'osm-standard',\n",
+ " 'osm-standard-relief',\n",
+ " 'osm-streets',\n",
+ " 'osm-streets-relief',\n",
+ " 'osm-light-gray',\n",
+ " 'osm-dark-gray',\n",
+ " 'arcgis-terrain',\n",
+ " 'arcgis-community',\n",
+ " 'arcgis-charted-territory',\n",
+ " 'arcgis-colored-pencil',\n",
+ " 'arcgis-nova',\n",
+ " 'arcgis-modern-antique',\n",
+ " 'arcgis-midcentury',\n",
+ " 'arcgis-newspaper',\n",
+ " 'arcgis-hillshade-light',\n",
+ " 'arcgis-hillshade-dark',\n",
+ " 'arcgis-human-geography',\n",
+ " 'arcgis-human-geography-dark']"
]
},
- "execution_count": 29,
+ "execution_count": 24,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
- "search_result[0].id"
+ "web_map_obj.basemap.basemaps"
]
},
{
- "cell_type": "markdown",
+ "cell_type": "code",
+ "execution_count": 28,
"metadata": {},
+ "outputs": [],
"source": [
- "It is likely the old service was deleted and a new one was published. Let us update the web map with the new feature layer"
+ "web_map_obj.basemap.basemap = 'topo-vector'"
]
},
{
"cell_type": "code",
- "execution_count": 30,
+ "execution_count": 46,
"metadata": {},
"outputs": [
{
"data": {
+ "text/html": [
+ ""
+ ],
"text/plain": [
- "[]"
+ ""
]
},
- "execution_count": 30,
+ "execution_count": 46,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
- "capitals = search_result[0]\n",
- "capitals.layers"
+ "web_map_obj"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
- "The new feature service does have a layer with id `0`. Hence we can use the same layer id while switching the url. To remove the old layer, call `remove_layer()` method. Then add the correct `FeatureLayer` object by calling the `add_layer()` method on the `WebMap` object."
- ]
- },
- {
- "cell_type": "code",
- "execution_count": 31,
- "metadata": {},
- "outputs": [],
- "source": [
- "# remove the old layer from the web map\n",
- "web_map_obj.remove_layer(web_map_obj.layers[0])"
+ "## Fix errors in web map\n",
+ "The widget loads an empty web map with just a basemap. Let us investigate the contents of the web map to determine the issue. You can query the layers in the web map using the `layers` property of `MapContent` class"
]
},
{
"cell_type": "code",
- "execution_count": 32,
+ "execution_count": 41,
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
- "True"
+ "[]"
]
},
- "execution_count": 32,
+ "execution_count": 41,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
- "# add the correct layer. While adding you can customize the title\n",
- "web_map_obj.add_layer(capitals.layers[0], options={'title':'USA Capitals'})"
+ "web_map_obj.content.layers"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
- "Check the layers on the web map"
+ "## Update the web map\n",
+ "To update the web map, we call the `update()` method. You have the option to update the thumbnail or any other item properties at this time."
]
},
{
"cell_type": "code",
- "execution_count": 33,
+ "execution_count": 43,
"metadata": {},
"outputs": [
{
- "name": "stdout",
- "output_type": "stream",
- "text": [
- "USA Capitals https://services7.arcgis.com/JEwYeAy2cc8qOe3o/arcgis/rest/services/USA_Capitals_spreadsheet_for_WebMap/FeatureServer/0\n"
- ]
+ "data": {
+ "text/html": [
+ "
\n",
+ "
\n",
+ "\n",
+ "
\n",
+ "
\n",
+ " "
+ ],
+ "text/plain": [
+ "- "
+ ]
+ },
+ "execution_count": 43,
+ "metadata": {},
+ "output_type": "execute_result"
}
],
"source": [
- "for lyr in web_map_obj.layers:\n",
- " print(lyr.title + \" \" + lyr.url)"
- ]
- },
- {
- "cell_type": "markdown",
- "metadata": {},
- "source": [
- "### Update the web map\n",
- "Now the web map should be fixed as it points to a live service. To update the web map, we call the `update()` method. You have the option to update the thumbnail or any other item properties at this time."
+ "new_capitals = csv_item.publish()\n",
+ "new_capitals "
]
},
{
"cell_type": "code",
- "execution_count": 34,
+ "execution_count": 44,
"metadata": {},
"outputs": [
{
@@ -535,7 +520,7 @@
"True"
]
},
- "execution_count": 34,
+ "execution_count": 44,
"metadata": {},
"output_type": "execute_result"
}
@@ -549,24 +534,24 @@
"cell_type": "markdown",
"metadata": {},
"source": [
- "Query the web map object to visualize it in the notebook"
+ "Now we see that the web map is is rendering the layer properly after re-publishing the item"
]
},
{
"cell_type": "code",
- "execution_count": 36,
+ "execution_count": 47,
"metadata": {},
"outputs": [
{
"data": {
"text/html": [
- ""
+ ""
],
"text/plain": [
""
]
},
- "execution_count": 36,
+ "execution_count": 47,
"metadata": {},
"output_type": "execute_result"
}
@@ -575,36 +560,39 @@
"web_map_obj"
]
},
- {
- "cell_type": "markdown",
- "metadata": {},
- "source": [
- "The web map was sucessfully overwritten with correct operational layers. You can interact with the widget and zoom into the USA to observe the locations of capitals."
- ]
- },
{
"cell_type": "code",
- "execution_count": null,
+ "execution_count": 48,
"metadata": {},
- "outputs": [],
+ "outputs": [
+ {
+ "data": {
+ "text/plain": [
+ "True"
+ ]
+ },
+ "execution_count": 37,
+ "metadata": {},
+ "output_type": "execute_result"
+ }
+ ],
"source": [
- "# Let's clean it up so we can always run this notebook again\n",
- "wm_item.delete()\n",
- "new_capitals.delete()\n",
- "csv_item.delete()"
+ "wm_item.delete(permanent=True)\n",
+ "new_capitals.delete(permanent=True)\n",
+ "csv_item.delete(permanent=True)"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
- "## Using and updating a web scene\n",
- "In the sample above we observed how to update a web map. Updating the web scene is similar, we use the `update()` method. Let us look at the example of a web scene that displays tropical cyclones over the Pacific ocean."
+ "# Using and updating a web scene\n",
+ "In the sample above we observed how to use and update a web map. Updating the web scene is similar, we use the `Scene` class. Let us look at the example of a web scene that displays tropical cyclones over the Pacific ocean."
]
},
{
"cell_type": "code",
- "execution_count": 38,
+ "execution_count": 3,
"metadata": {},
"outputs": [
{
@@ -612,34 +600,35 @@
"text/html": [
"
\n",
"
\n",
"\n",
"
\n",
- "
Western Pacific Typhoons (2005)\n",
+ " Western Pacific Typhoons (2005) by esri_3d\n",
" \n",
- "
A thematic global scene showing the 23 typhoons that meandered through the western Pacific in 2005
Web Scene by esri_3d\n",
- "
Last Modified: May 01, 2020\n",
- "
1 comments, 21096 views\n",
+ "
A thematic global scene showing the 23 typhoons that meandered through the western Pacific in 2005
Web Scene by python_user\n",
+ "
Last Modified: November 07, 2024\n",
+ "
0 comments, 94 views\n",
"
\n",
"
\n",
" "
],
"text/plain": [
- "- "
+ "
- "
]
},
- "execution_count": 38,
+ "execution_count": 3,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
- "search_result = gis.content.search('title:Western Pacific Typhoons (2005)', \n",
- " item_type = 'Web Scene', outside_org = True)\n",
- "search_result[0]"
+ "search_result = gis.content.search('title:Western Pacific Typhoons (2005) by esri_3d', \n",
+ " item_type = 'Web Scene')\n",
+ "web_scene_item = search_result[0]\n",
+ "web_scene_item"
]
},
{
@@ -651,35 +640,35 @@
},
{
"cell_type": "code",
- "execution_count": 56,
+ "execution_count": 43,
"metadata": {},
"outputs": [
{
"data": {
"text/html": [
- ""
+ ""
],
"text/plain": [
""
]
},
- "execution_count": 56,
+ "execution_count": 43,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
- "web_scene_item = search_result[0]\n",
- "web_scene_obj = WebScene(web_scene_item)\n",
- "\n",
- "# display web scene in the notebook\n",
+ "web_scene_obj = Scene(item=web_scene_item)\n",
"web_scene_obj"
]
},
{
"cell_type": "markdown",
"metadata": {
- "collapsed": true
+ "collapsed": true,
+ "jupyter": {
+ "outputs_hidden": true
+ }
},
"source": [
"This is a great web scene and it displays a lot of hurricane tracks. However, we want to create a new one with only a particular subset of data and customize the basemaps. To modify this web scene, let us first make a copy of it and publish it into your portal."
@@ -689,638 +678,105 @@
"cell_type": "markdown",
"metadata": {},
"source": [
- "### Make a copy of the public web scene item\n",
- "To make a copy, we essentially download the content of the web scene JSON, remove the parts we don't want, add the layers that we want and publish a new item using that information. The publishing steps are similar to what is described earlier in the **data preparation** section and in detail in the sample titled **Publishing web maps and web scenes**.\n",
- "\n",
- "Let's say, we are only interested in the storms that occur in summer. Summer in tropical Asia is around April-June and that matches with a layer in the existing web scene. Let us query the `operationalLayers` section of the web scene to understand what the layers look like.\n",
+ "## Make a copy of the public web scene item\n",
+ "Let's say, we are only interested in the storms that occur in summer. Summer in tropical Asia is around April-June and that matches with a layer in the existing web scene. We will use the `layers` property of `SceneContent` class to understand how the layers look like.\n",
"\n",
- "### Update operational layers of new web scene"
+ "### Update layers of new web scene"
]
},
{
"cell_type": "code",
- "execution_count": 40,
+ "execution_count": 7,
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
- "[{'id': '882ce65eceda4e2ba2ad65f9e2c0632f',\n",
- " 'opacity': 1,\n",
- " 'title': 'Typhoon Paths',\n",
- " 'url': 'https://services.arcgis.com/P3ePLMYs2RVChkJx/arcgis/rest/services/PacificTyphoons2005_WFL/FeatureServer/18',\n",
- " 'visibility': True,\n",
- " 'layerType': 'ArcGISFeatureLayer',\n",
- " 'layerDefinition': {'minScale': 120000000,\n",
- " 'maxScale': 0,\n",
- " 'elevationInfo': {'mode': 'onTheGround'},\n",
- " 'drawingInfo': {'renderer': {'type': 'simple',\n",
- " 'description': '',\n",
- " 'label': '',\n",
- " 'symbol': {'type': 'LineSymbol3D',\n",
- " 'symbolLayers': [{'material': {'color': [0, 169, 230]},\n",
- " 'type': 'Line',\n",
- " 'size': 5}]}}}},\n",
- " 'popupInfo': {'showAttachments': False,\n",
- " 'title': '{name}',\n",
- " 'popupElements': [{'type': 'text'}],\n",
- " 'description': \"
Typhoon {name}
Started: {datedescription}
\"}},\n",
- " {'id': '14a37c86f84-layer21',\n",
- " 'listMode': 'hide-children',\n",
- " 'opacity': 1,\n",
- " 'title': 'October - December',\n",
- " 'visibility': False,\n",
- " 'layers': [{'id': '7a24e304d2474d7eb29a712c95202140',\n",
- " 'opacity': 1,\n",
- " 'title': 'Labels Q4',\n",
- " 'url': 'https://services.arcgis.com/P3ePLMYs2RVChkJx/arcgis/rest/services/PacificTyphoons2005_WFL/FeatureServer/17',\n",
- " 'visibility': False,\n",
- " 'layerType': 'ArcGISFeatureLayer',\n",
- " 'layerDefinition': {'elevationInfo': {'mode': 'absoluteHeight'},\n",
- " 'drawingInfo': {'renderer': {'type': 'simple',\n",
- " 'visualVariables': [{'type': 'sizeInfo',\n",
- " 'minSize': 25,\n",
- " 'axis': 'all',\n",
- " 'valueUnit': 'unknown'}],\n",
- " 'description': '',\n",
- " 'label': '',\n",
- " 'symbol': {'type': 'styleSymbolReference',\n",
- " 'styleName': 'EsriIconsStyle',\n",
- " 'name': 'Pushpin 1'}}}},\n",
- " 'showLabels': True,\n",
- " 'popupInfo': {'showAttachments': True,\n",
- " 'title': 'Labels Q4: {name}',\n",
- " 'fieldInfos': [{'fieldName': 'typhoonid',\n",
- " 'label': 'typhoonid',\n",
- " 'visible': True},\n",
- " {'fieldName': 'name', 'label': 'name', 'visible': True},\n",
- " {'fieldName': 'datedescription',\n",
- " 'label': 'datedescription',\n",
- " 'visible': True},\n",
- " {'fieldName': 'ORIG_FID',\n",
- " 'label': 'ORIG_FID',\n",
- " 'visible': True,\n",
- " 'format': {'digitSeparator': True, 'places': 0}}],\n",
- " 'popupElements': [{'type': 'fields'}, {'type': 'attachments'}]}},\n",
- " {'id': '10944e27c9f04bc39b5821c0046523a5',\n",
- " 'opacity': 1,\n",
- " 'title': 'Typhoons Q4',\n",
- " 'url': 'https://services.arcgis.com/P3ePLMYs2RVChkJx/arcgis/rest/services/PacificTyphoons2005_WFL/FeatureServer/16',\n",
- " 'visibility': False,\n",
- " 'layerType': 'ArcGISFeatureLayer',\n",
- " 'layerDefinition': {'elevationInfo': {'mode': 'absoluteHeight'},\n",
- " 'drawingInfo': {'renderer': {'type': 'simple',\n",
- " 'visualVariables': [{'type': 'sizeInfo',\n",
- " 'field': 'windspeed',\n",
- " 'minSize': 1,\n",
- " 'minDataValue': 0.0001,\n",
- " 'axis': 'height'},\n",
- " {'type': 'sizeInfo',\n",
- " 'minSize': 100000,\n",
- " 'axis': 'widthAndDepth',\n",
- " 'valueUnit': 'meters'},\n",
- " {'type': 'colorInfo',\n",
- " 'field': 'airpressure',\n",
- " 'stops': [{'value': 920, 'color': [245, 0, 0, 255]},\n",
- " {'value': 1014, 'color': [245, 245, 0, 255]}]}],\n",
- " 'description': '',\n",
- " 'label': '',\n",
- " 'symbol': {'type': 'styleSymbolReference',\n",
- " 'styleName': 'EsriThematicShapesStyle',\n",
- " 'name': 'Standing Cylinder'}}}},\n",
- " 'popupInfo': {'showAttachments': False,\n",
- " 'title': '{typhoon}',\n",
- " 'popupElements': [{'type': 'fields'}, {'type': 'media'}],\n",
- " 'mediaInfos': [{'type': 'image',\n",
- " 'title': \"\",\n",
- " 'caption': \"Pressure: {airpressure} hPa
Wind speed: {wind_mph} mph / {wind_kph} kph
Date: {timedescription}
\",\n",
- " 'value': {'sourceURL': '{image}'}}]}}],\n",
- " 'layerType': 'GroupLayer',\n",
- " 'visibilityMode': 'inherited'},\n",
- " {'id': '14a37c7f247-layer20',\n",
- " 'listMode': 'hide-children',\n",
- " 'opacity': 1,\n",
- " 'title': 'September',\n",
- " 'visibility': False,\n",
- " 'layers': [{'id': '90eba5af0b084c569a55ebc9b3bfc21e',\n",
- " 'opacity': 1,\n",
- " 'title': 'Labels Q3_3',\n",
- " 'url': 'https://services.arcgis.com/P3ePLMYs2RVChkJx/arcgis/rest/services/PacificTyphoons2005_WFL/FeatureServer/14',\n",
- " 'visibility': False,\n",
- " 'layerType': 'ArcGISFeatureLayer',\n",
- " 'layerDefinition': {'elevationInfo': {'mode': 'absoluteHeight'},\n",
- " 'drawingInfo': {'renderer': {'type': 'simple',\n",
- " 'visualVariables': [{'type': 'sizeInfo',\n",
- " 'minSize': 25,\n",
- " 'axis': 'all',\n",
- " 'valueUnit': 'unknown'}],\n",
- " 'description': '',\n",
- " 'label': '',\n",
- " 'symbol': {'type': 'styleSymbolReference',\n",
- " 'styleName': 'EsriIconsStyle',\n",
- " 'name': 'Pushpin 1'}}}},\n",
- " 'showLabels': True,\n",
- " 'popupInfo': {'showAttachments': True,\n",
- " 'title': 'Labels Q3_3: {name}',\n",
- " 'fieldInfos': [{'fieldName': 'typhoonid',\n",
- " 'label': 'typhoonid',\n",
- " 'visible': True},\n",
- " {'fieldName': 'name', 'label': 'name', 'visible': True},\n",
- " {'fieldName': 'datedescription',\n",
- " 'label': 'datedescription',\n",
- " 'visible': True},\n",
- " {'fieldName': 'ORIG_FID',\n",
- " 'label': 'ORIG_FID',\n",
- " 'visible': True,\n",
- " 'format': {'digitSeparator': True, 'places': 0}}],\n",
- " 'popupElements': [{'type': 'fields'}, {'type': 'attachments'}]}},\n",
- " {'id': '341d7b380907439990e4c238147b46ce',\n",
- " 'opacity': 1,\n",
- " 'title': 'Typhoons Q3_3',\n",
- " 'url': 'https://services.arcgis.com/P3ePLMYs2RVChkJx/arcgis/rest/services/PacificTyphoons2005_WFL/FeatureServer/13',\n",
- " 'visibility': False,\n",
- " 'layerType': 'ArcGISFeatureLayer',\n",
- " 'layerDefinition': {'elevationInfo': {'mode': 'absoluteHeight'},\n",
- " 'drawingInfo': {'renderer': {'type': 'simple',\n",
- " 'visualVariables': [{'type': 'sizeInfo',\n",
- " 'field': 'windspeed',\n",
- " 'minSize': 1,\n",
- " 'minDataValue': 0.0001,\n",
- " 'axis': 'height'},\n",
- " {'type': 'sizeInfo',\n",
- " 'minSize': 100000,\n",
- " 'axis': 'widthAndDepth',\n",
- " 'valueUnit': 'meters'},\n",
- " {'type': 'colorInfo',\n",
- " 'field': 'airpressure',\n",
- " 'stops': [{'value': 920, 'color': [245, 0, 0, 255]},\n",
- " {'value': 1014, 'color': [245, 245, 0, 255]}]}],\n",
- " 'description': '',\n",
- " 'label': '',\n",
- " 'symbol': {'type': 'styleSymbolReference',\n",
- " 'styleName': 'EsriThematicShapesStyle',\n",
- " 'name': 'Standing Cylinder'}}}},\n",
- " 'popupInfo': {'showAttachments': False,\n",
- " 'title': '{typhoon}',\n",
- " 'popupElements': [{'type': 'fields'}, {'type': 'media'}],\n",
- " 'mediaInfos': [{'type': 'image',\n",
- " 'title': \"\",\n",
- " 'caption': \"Pressure: {airpressure} hPa
Wind speed: {wind_mph} mph / {wind_kph} kph
Date: {timedescription}
\",\n",
- " 'value': {'sourceURL': '{image}'}}]}}],\n",
- " 'layerType': 'GroupLayer',\n",
- " 'visibilityMode': 'inherited'},\n",
- " {'id': '14a37c78bc8-layer19',\n",
- " 'listMode': 'hide-children',\n",
- " 'opacity': 1,\n",
- " 'title': 'August',\n",
- " 'visibility': False,\n",
- " 'layers': [{'id': '6e54f2736388480ab0a214cb468d48f9',\n",
- " 'opacity': 1,\n",
- " 'title': 'Labels Q3_2',\n",
- " 'url': 'https://services.arcgis.com/P3ePLMYs2RVChkJx/arcgis/rest/services/PacificTyphoons2005_WFL/FeatureServer/11',\n",
- " 'visibility': False,\n",
- " 'layerType': 'ArcGISFeatureLayer',\n",
- " 'layerDefinition': {'elevationInfo': {'mode': 'absoluteHeight'},\n",
- " 'drawingInfo': {'renderer': {'type': 'simple',\n",
- " 'visualVariables': [{'type': 'sizeInfo',\n",
- " 'minSize': 25,\n",
- " 'axis': 'all',\n",
- " 'valueUnit': 'unknown'}],\n",
- " 'description': '',\n",
- " 'label': '',\n",
- " 'symbol': {'type': 'styleSymbolReference',\n",
- " 'styleName': 'EsriIconsStyle',\n",
- " 'name': 'Pushpin 1'}}}},\n",
- " 'showLabels': True,\n",
- " 'popupInfo': {'showAttachments': True,\n",
- " 'title': 'Labels Q3_2: {name}',\n",
- " 'fieldInfos': [{'fieldName': 'typhoonid',\n",
- " 'label': 'typhoonid',\n",
- " 'visible': True},\n",
- " {'fieldName': 'name', 'label': 'name', 'visible': True},\n",
- " {'fieldName': 'datedescription',\n",
- " 'label': 'datedescription',\n",
- " 'visible': True},\n",
- " {'fieldName': 'ORIG_FID',\n",
- " 'label': 'ORIG_FID',\n",
- " 'visible': True,\n",
- " 'format': {'digitSeparator': True, 'places': 0}}],\n",
- " 'popupElements': [{'type': 'fields'}, {'type': 'attachments'}]}},\n",
- " {'id': '6b549bb78d824b4c8d24f5c90b93c4f6',\n",
- " 'opacity': 1,\n",
- " 'title': 'Typhoons Q3_2',\n",
- " 'url': 'https://services.arcgis.com/P3ePLMYs2RVChkJx/arcgis/rest/services/PacificTyphoons2005_WFL/FeatureServer/10',\n",
- " 'visibility': False,\n",
- " 'layerType': 'ArcGISFeatureLayer',\n",
- " 'layerDefinition': {'elevationInfo': {'mode': 'absoluteHeight'},\n",
- " 'drawingInfo': {'renderer': {'type': 'simple',\n",
- " 'visualVariables': [{'type': 'sizeInfo',\n",
- " 'field': 'windspeed',\n",
- " 'minSize': 1,\n",
- " 'minDataValue': 0.0001,\n",
- " 'axis': 'height'},\n",
- " {'type': 'sizeInfo',\n",
- " 'minSize': 100000,\n",
- " 'axis': 'widthAndDepth',\n",
- " 'valueUnit': 'meters'},\n",
- " {'type': 'colorInfo',\n",
- " 'field': 'airpressure',\n",
- " 'stops': [{'value': 920, 'color': [245, 0, 0, 255]},\n",
- " {'value': 1014, 'color': [245, 245, 0, 255]}]}],\n",
- " 'description': '',\n",
- " 'label': '',\n",
- " 'symbol': {'type': 'styleSymbolReference',\n",
- " 'styleName': 'EsriThematicShapesStyle',\n",
- " 'name': 'Standing Cylinder'}}}},\n",
- " 'popupInfo': {'showAttachments': False,\n",
- " 'title': '{typhoon}',\n",
- " 'popupElements': [{'type': 'fields'}, {'type': 'media'}],\n",
- " 'mediaInfos': [{'type': 'image',\n",
- " 'title': \"\",\n",
- " 'caption': \"Pressure: {airpressure} hPa
Wind speed: {wind_mph} mph / {wind_kph} kph
Date: {timedescription}
\",\n",
- " 'value': {'sourceURL': '{image}'}}]}}],\n",
- " 'layerType': 'GroupLayer',\n",
- " 'visibilityMode': 'inherited'},\n",
- " {'id': '14a37c4590b-layer18',\n",
- " 'listMode': 'hide-children',\n",
- " 'opacity': 1,\n",
- " 'title': 'July',\n",
- " 'visibility': False,\n",
- " 'layers': [{'id': 'b8cc403be27e475ca93db04a34845e89',\n",
- " 'opacity': 1,\n",
- " 'title': 'Labels Q3_1',\n",
- " 'url': 'https://services.arcgis.com/P3ePLMYs2RVChkJx/arcgis/rest/services/PacificTyphoons2005_WFL/FeatureServer/8',\n",
- " 'visibility': False,\n",
- " 'layerType': 'ArcGISFeatureLayer',\n",
- " 'layerDefinition': {'elevationInfo': {'mode': 'absoluteHeight'},\n",
- " 'drawingInfo': {'renderer': {'type': 'simple',\n",
- " 'visualVariables': [{'type': 'sizeInfo',\n",
- " 'minSize': 25,\n",
- " 'axis': 'all',\n",
- " 'valueUnit': 'unknown'}],\n",
- " 'description': '',\n",
- " 'label': '',\n",
- " 'symbol': {'type': 'styleSymbolReference',\n",
- " 'styleName': 'EsriIconsStyle',\n",
- " 'name': 'Pushpin 1'}}}},\n",
- " 'showLabels': True,\n",
- " 'popupInfo': {'showAttachments': True,\n",
- " 'title': 'Labels Q3_1: {name}',\n",
- " 'fieldInfos': [{'fieldName': 'typhoonid',\n",
- " 'label': 'typhoonid',\n",
- " 'visible': True},\n",
- " {'fieldName': 'name', 'label': 'name', 'visible': True},\n",
- " {'fieldName': 'datedescription',\n",
- " 'label': 'datedescription',\n",
- " 'visible': True},\n",
- " {'fieldName': 'ORIG_FID',\n",
- " 'label': 'ORIG_FID',\n",
- " 'visible': True,\n",
- " 'format': {'digitSeparator': True, 'places': 0}}],\n",
- " 'popupElements': [{'type': 'fields'}, {'type': 'attachments'}]}},\n",
- " {'id': 'e60bd6abdb094bf2b9daacd8bb57495c',\n",
- " 'opacity': 1,\n",
- " 'title': 'Typhoons Q3_1',\n",
- " 'url': 'https://services.arcgis.com/P3ePLMYs2RVChkJx/arcgis/rest/services/PacificTyphoons2005_WFL/FeatureServer/7',\n",
- " 'visibility': False,\n",
- " 'layerType': 'ArcGISFeatureLayer',\n",
- " 'layerDefinition': {'elevationInfo': {'mode': 'absoluteHeight'},\n",
- " 'drawingInfo': {'renderer': {'type': 'simple',\n",
- " 'visualVariables': [{'type': 'sizeInfo',\n",
- " 'field': 'windspeed',\n",
- " 'minSize': 1,\n",
- " 'minDataValue': 0.0001,\n",
- " 'axis': 'height'},\n",
- " {'type': 'sizeInfo',\n",
- " 'minSize': 100000,\n",
- " 'axis': 'widthAndDepth',\n",
- " 'valueUnit': 'meters'},\n",
- " {'type': 'colorInfo',\n",
- " 'field': 'airpressure',\n",
- " 'stops': [{'value': 920, 'color': [245, 0, 0, 255]},\n",
- " {'value': 1014, 'color': [245, 245, 0, 255]}]}],\n",
- " 'description': '',\n",
- " 'label': '',\n",
- " 'symbol': {'type': 'styleSymbolReference',\n",
- " 'styleName': 'EsriThematicShapesStyle',\n",
- " 'name': 'Standing Cylinder'}}}},\n",
- " 'popupInfo': {'showAttachments': False,\n",
- " 'title': '{typhoon}',\n",
- " 'popupElements': [{'type': 'fields'}, {'type': 'media'}],\n",
- " 'mediaInfos': [{'type': 'image',\n",
- " 'title': \"\",\n",
- " 'caption': \"Pressure: {airpressure} hPa
Wind speed: {wind_mph} mph / {wind_kph} kph
Date: {timedescription}
\",\n",
- " 'value': {'sourceURL': '{image}'}}]}}],\n",
- " 'layerType': 'GroupLayer',\n",
- " 'visibilityMode': 'inherited'},\n",
- " {'id': '14a37c397dc-layer17',\n",
- " 'listMode': 'hide-children',\n",
- " 'opacity': 1,\n",
- " 'title': 'April - June',\n",
- " 'visibility': False,\n",
- " 'layers': [{'id': '56803f3d64184140950f0ef1256a0603',\n",
- " 'opacity': 1,\n",
- " 'title': 'Labels Q2',\n",
- " 'url': 'https://services.arcgis.com/P3ePLMYs2RVChkJx/arcgis/rest/services/PacificTyphoons2005_WFL/FeatureServer/5',\n",
- " 'visibility': False,\n",
- " 'layerType': 'ArcGISFeatureLayer',\n",
- " 'layerDefinition': {'elevationInfo': {'mode': 'absoluteHeight'},\n",
- " 'drawingInfo': {'renderer': {'type': 'simple',\n",
- " 'visualVariables': [{'type': 'sizeInfo',\n",
- " 'minSize': 25,\n",
- " 'axis': 'all',\n",
- " 'valueUnit': 'unknown'}],\n",
- " 'description': '',\n",
- " 'label': '',\n",
- " 'symbol': {'type': 'styleSymbolReference',\n",
- " 'styleName': 'EsriIconsStyle',\n",
- " 'name': 'Pushpin 1'}}}},\n",
- " 'showLabels': True,\n",
- " 'popupInfo': {'showAttachments': True,\n",
- " 'title': 'Labels Q2: {name}',\n",
- " 'fieldInfos': [{'fieldName': 'typhoonid',\n",
- " 'label': 'typhoonid',\n",
- " 'visible': True},\n",
- " {'fieldName': 'name', 'label': 'name', 'visible': True},\n",
- " {'fieldName': 'datedescription',\n",
- " 'label': 'datedescription',\n",
- " 'visible': True},\n",
- " {'fieldName': 'ORIG_FID',\n",
- " 'label': 'ORIG_FID',\n",
- " 'visible': True,\n",
- " 'format': {'digitSeparator': True, 'places': 0}}],\n",
- " 'popupElements': [{'type': 'fields'}, {'type': 'attachments'}]}},\n",
- " {'id': '72668fcc8a904bd6a1444bef2e72f420',\n",
- " 'opacity': 1,\n",
- " 'title': 'Typhoons Q2',\n",
- " 'url': 'https://services.arcgis.com/P3ePLMYs2RVChkJx/arcgis/rest/services/PacificTyphoons2005_WFL/FeatureServer/4',\n",
- " 'visibility': False,\n",
- " 'layerType': 'ArcGISFeatureLayer',\n",
- " 'layerDefinition': {'elevationInfo': {'mode': 'absoluteHeight'},\n",
- " 'drawingInfo': {'renderer': {'type': 'simple',\n",
- " 'visualVariables': [{'type': 'sizeInfo',\n",
- " 'field': 'windspeed',\n",
- " 'minSize': 1,\n",
- " 'minDataValue': 0.0001,\n",
- " 'axis': 'height'},\n",
- " {'type': 'sizeInfo',\n",
- " 'minSize': 100000,\n",
- " 'axis': 'widthAndDepth',\n",
- " 'valueUnit': 'meters'},\n",
- " {'type': 'colorInfo',\n",
- " 'field': 'airpressure',\n",
- " 'stops': [{'value': 920, 'color': [245, 0, 0, 255]},\n",
- " {'value': 1014, 'color': [245, 245, 0, 255]}]}],\n",
- " 'description': '',\n",
- " 'label': '',\n",
- " 'symbol': {'type': 'styleSymbolReference',\n",
- " 'styleName': 'EsriThematicShapesStyle',\n",
- " 'name': 'Standing Cylinder'}}}},\n",
- " 'popupInfo': {'showAttachments': False,\n",
- " 'title': '{typhoon}',\n",
- " 'popupElements': [{'type': 'fields'}, {'type': 'media'}],\n",
- " 'mediaInfos': [{'type': 'image',\n",
- " 'title': \"\",\n",
- " 'caption': \"Pressure: {airpressure} hPa
Wind speed: {wind_mph} mph / {wind_kph} kph
Date: {timedescription}
\",\n",
- " 'value': {'sourceURL': '{image}'}}]}}],\n",
- " 'layerType': 'GroupLayer',\n",
- " 'visibilityMode': 'inherited'},\n",
- " {'id': '14a37c2a1a7-layer16',\n",
- " 'listMode': 'hide-children',\n",
- " 'opacity': 1,\n",
- " 'title': 'January - March',\n",
- " 'visibility': True,\n",
- " 'layers': [{'id': '16c9bf0e374443d394f0b77980171499',\n",
- " 'opacity': 1,\n",
- " 'title': 'Labels Q1',\n",
- " 'url': 'https://services.arcgis.com/P3ePLMYs2RVChkJx/arcgis/rest/services/PacificTyphoons2005_WFL/FeatureServer/2',\n",
- " 'visibility': True,\n",
- " 'layerType': 'ArcGISFeatureLayer',\n",
- " 'layerDefinition': {'elevationInfo': {'mode': 'absoluteHeight'},\n",
- " 'drawingInfo': {'renderer': {'type': 'simple',\n",
- " 'visualVariables': [{'type': 'sizeInfo',\n",
- " 'minSize': 25,\n",
- " 'axis': 'all',\n",
- " 'valueUnit': 'unknown'}],\n",
- " 'description': '',\n",
- " 'label': '',\n",
- " 'symbol': {'type': 'styleSymbolReference',\n",
- " 'styleName': 'EsriIconsStyle',\n",
- " 'name': 'Pushpin 1'}}}},\n",
- " 'showLabels': True,\n",
- " 'popupInfo': {'showAttachments': True,\n",
- " 'title': 'Labels Q1: {name}',\n",
- " 'fieldInfos': [{'fieldName': 'typhoonid',\n",
- " 'label': 'typhoonid',\n",
- " 'visible': True},\n",
- " {'fieldName': 'name', 'label': 'name', 'visible': True},\n",
- " {'fieldName': 'datedescription',\n",
- " 'label': 'datedescription',\n",
- " 'visible': True},\n",
- " {'fieldName': 'ORIG_FID',\n",
- " 'label': 'ORIG_FID',\n",
- " 'visible': True,\n",
- " 'format': {'digitSeparator': True, 'places': 0}}],\n",
- " 'popupElements': [{'type': 'fields'}, {'type': 'attachments'}]}},\n",
- " {'id': '3921d1e5c45c41b4a0b498df8fab4e2c',\n",
- " 'opacity': 1,\n",
- " 'title': 'Typhoons Q1',\n",
- " 'url': 'https://services.arcgis.com/P3ePLMYs2RVChkJx/arcgis/rest/services/PacificTyphoons2005_WFL/FeatureServer/1',\n",
- " 'visibility': True,\n",
- " 'layerType': 'ArcGISFeatureLayer',\n",
- " 'layerDefinition': {'elevationInfo': {'mode': 'absoluteHeight'},\n",
- " 'drawingInfo': {'renderer': {'type': 'simple',\n",
- " 'visualVariables': [{'type': 'sizeInfo',\n",
- " 'field': 'windspeed',\n",
- " 'minSize': 1,\n",
- " 'minDataValue': 0.0001,\n",
- " 'axis': 'height'},\n",
- " {'type': 'sizeInfo',\n",
- " 'minSize': 100000,\n",
- " 'axis': 'widthAndDepth',\n",
- " 'valueUnit': 'meters'},\n",
- " {'type': 'colorInfo',\n",
- " 'field': 'airpressure',\n",
- " 'stops': [{'value': 920, 'color': [245, 0, 0, 255]},\n",
- " {'value': 1014, 'color': [245, 245, 0, 255]}]}],\n",
- " 'description': '',\n",
- " 'label': '',\n",
- " 'symbol': {'type': 'styleSymbolReference',\n",
- " 'styleName': 'EsriThematicShapesStyle',\n",
- " 'name': 'Standing Cylinder'}}}},\n",
- " 'popupInfo': {'showAttachments': False,\n",
- " 'title': '{typhoon}',\n",
- " 'popupElements': [{'type': 'fields'}, {'type': 'media'}],\n",
- " 'mediaInfos': [{'type': 'image',\n",
- " 'title': \"\",\n",
- " 'caption': \"Pressure: {airpressure} hPa
Wind speed: {wind_mph} mph / {wind_kph} kph
Date: {timedescription}
\",\n",
- " 'value': {'sourceURL': '{image}'}}]}}],\n",
- " 'layerType': 'GroupLayer',\n",
- " 'visibilityMode': 'inherited'}]"
+ "[,\n",
+ " Group Layer: October - December,\n",
+ " Group Layer: September,\n",
+ " Group Layer: August,\n",
+ " Group Layer: July,\n",
+ " Group Layer: April - June,\n",
+ " Group Layer: January - March]"
]
},
+ "execution_count": 7,
"metadata": {},
- "output_type": "display_data"
+ "output_type": "execute_result"
}
],
"source": [
- "display(web_scene_obj['operationalLayers'])"
+ "layers_list = web_scene_obj.content.layers\n",
+ "layers_list"
+ ]
+ },
+ {
+ "attachments": {},
+ "cell_type": "markdown",
+ "metadata": {},
+ "source": [
+ "If you notice, some of the layers above are group layers, meaning, they contain sub layers."
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
- "There is a lot of information displayed above. Let us drill into this and display only layer names and their urls. If you notice, some of the layers above are group layers, meaning, they contain sub layers. So let us write a loop like below and print some details."
+ "We are only interested in the layers that correspond to cyclones in summer. We will overwrite the `layers` property of `SceneContent` class to update the layers of the new web scene"
]
},
{
"cell_type": "code",
- "execution_count": 41,
+ "execution_count": 9,
"metadata": {},
"outputs": [
{
- "name": "stdout",
- "output_type": "stream",
- "text": [
- "Typhoon Paths :: ArcGISFeatureLayer\n",
- "October - December :: GroupLayer\n",
- "\tLabels Q4 :: https://services.arcgis.com/P3ePLMYs2RVChkJx/arcgis/rest/services/PacificTyphoons2005_WFL/FeatureServer/17\n",
- "\tTyphoons Q4 :: https://services.arcgis.com/P3ePLMYs2RVChkJx/arcgis/rest/services/PacificTyphoons2005_WFL/FeatureServer/16\n",
- "September :: GroupLayer\n",
- "\tLabels Q3_3 :: https://services.arcgis.com/P3ePLMYs2RVChkJx/arcgis/rest/services/PacificTyphoons2005_WFL/FeatureServer/14\n",
- "\tTyphoons Q3_3 :: https://services.arcgis.com/P3ePLMYs2RVChkJx/arcgis/rest/services/PacificTyphoons2005_WFL/FeatureServer/13\n",
- "August :: GroupLayer\n",
- "\tLabels Q3_2 :: https://services.arcgis.com/P3ePLMYs2RVChkJx/arcgis/rest/services/PacificTyphoons2005_WFL/FeatureServer/11\n",
- "\tTyphoons Q3_2 :: https://services.arcgis.com/P3ePLMYs2RVChkJx/arcgis/rest/services/PacificTyphoons2005_WFL/FeatureServer/10\n",
- "July :: GroupLayer\n",
- "\tLabels Q3_1 :: https://services.arcgis.com/P3ePLMYs2RVChkJx/arcgis/rest/services/PacificTyphoons2005_WFL/FeatureServer/8\n",
- "\tTyphoons Q3_1 :: https://services.arcgis.com/P3ePLMYs2RVChkJx/arcgis/rest/services/PacificTyphoons2005_WFL/FeatureServer/7\n",
- "April - June :: GroupLayer\n",
- "\tLabels Q2 :: https://services.arcgis.com/P3ePLMYs2RVChkJx/arcgis/rest/services/PacificTyphoons2005_WFL/FeatureServer/5\n",
- "\tTyphoons Q2 :: https://services.arcgis.com/P3ePLMYs2RVChkJx/arcgis/rest/services/PacificTyphoons2005_WFL/FeatureServer/4\n",
- "January - March :: GroupLayer\n",
- "\tLabels Q1 :: https://services.arcgis.com/P3ePLMYs2RVChkJx/arcgis/rest/services/PacificTyphoons2005_WFL/FeatureServer/2\n",
- "\tTyphoons Q1 :: https://services.arcgis.com/P3ePLMYs2RVChkJx/arcgis/rest/services/PacificTyphoons2005_WFL/FeatureServer/1\n"
- ]
+ "data": {
+ "text/plain": [
+ "[,\n",
+ " Group Layer: April - June]"
+ ]
+ },
+ "execution_count": 9,
+ "metadata": {},
+ "output_type": "execute_result"
}
],
"source": [
- "for layer in web_scene_obj['operationalLayers']:\n",
- " print(layer['title'] + \" :: \" + layer['layerType'])\n",
- " if layer['layerType'] == 'GroupLayer':\n",
- " for sub_layer in layer['layers']:\n",
- " print(\"\\t\" + sub_layer['title'] + \" :: \"+ sub_layer['url'])"
+ "subset_op_layers = [layers_list[0],layers_list[5]]\n",
+ "subset_op_layers"
]
},
{
- "cell_type": "markdown",
+ "cell_type": "code",
+ "execution_count": 29,
"metadata": {},
+ "outputs": [],
"source": [
- "We are only interested in the layers that correspond to cyclones in summer. From the above report, we understand that information is in a group layer with two sub layers. Let us extract just that dictionary and compose a new web scene data."
+ "new_web_scene_obj = web_scene_obj\n",
+ "new_web_scene_obj.content.layers = subset_op_layers"
]
},
{
"cell_type": "code",
- "execution_count": 42,
+ "execution_count": 20,
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
- "[{'id': '14a37c397dc-layer17',\n",
- " 'listMode': 'hide-children',\n",
- " 'opacity': 1,\n",
- " 'title': 'April - June',\n",
- " 'visibility': False,\n",
- " 'layers': [{'id': '56803f3d64184140950f0ef1256a0603',\n",
- " 'opacity': 1,\n",
- " 'title': 'Labels Q2',\n",
- " 'url': 'https://services.arcgis.com/P3ePLMYs2RVChkJx/arcgis/rest/services/PacificTyphoons2005_WFL/FeatureServer/5',\n",
- " 'visibility': False,\n",
- " 'layerType': 'ArcGISFeatureLayer',\n",
- " 'layerDefinition': {'elevationInfo': {'mode': 'absoluteHeight'},\n",
- " 'drawingInfo': {'renderer': {'type': 'simple',\n",
- " 'visualVariables': [{'type': 'sizeInfo',\n",
- " 'minSize': 25,\n",
- " 'axis': 'all',\n",
- " 'valueUnit': 'unknown'}],\n",
- " 'description': '',\n",
- " 'label': '',\n",
- " 'symbol': {'type': 'styleSymbolReference',\n",
- " 'styleName': 'EsriIconsStyle',\n",
- " 'name': 'Pushpin 1'}}}},\n",
- " 'showLabels': True,\n",
- " 'popupInfo': {'showAttachments': True,\n",
- " 'title': 'Labels Q2: {name}',\n",
- " 'fieldInfos': [{'fieldName': 'typhoonid',\n",
- " 'label': 'typhoonid',\n",
- " 'visible': True},\n",
- " {'fieldName': 'name', 'label': 'name', 'visible': True},\n",
- " {'fieldName': 'datedescription',\n",
- " 'label': 'datedescription',\n",
- " 'visible': True},\n",
- " {'fieldName': 'ORIG_FID',\n",
- " 'label': 'ORIG_FID',\n",
- " 'visible': True,\n",
- " 'format': {'digitSeparator': True, 'places': 0}}],\n",
- " 'popupElements': [{'type': 'fields'}, {'type': 'attachments'}]}},\n",
- " {'id': '72668fcc8a904bd6a1444bef2e72f420',\n",
- " 'opacity': 1,\n",
- " 'title': 'Typhoons Q2',\n",
- " 'url': 'https://services.arcgis.com/P3ePLMYs2RVChkJx/arcgis/rest/services/PacificTyphoons2005_WFL/FeatureServer/4',\n",
- " 'visibility': False,\n",
- " 'layerType': 'ArcGISFeatureLayer',\n",
- " 'layerDefinition': {'elevationInfo': {'mode': 'absoluteHeight'},\n",
- " 'drawingInfo': {'renderer': {'type': 'simple',\n",
- " 'visualVariables': [{'type': 'sizeInfo',\n",
- " 'field': 'windspeed',\n",
- " 'minSize': 1,\n",
- " 'minDataValue': 0.0001,\n",
- " 'axis': 'height'},\n",
- " {'type': 'sizeInfo',\n",
- " 'minSize': 100000,\n",
- " 'axis': 'widthAndDepth',\n",
- " 'valueUnit': 'meters'},\n",
- " {'type': 'colorInfo',\n",
- " 'field': 'airpressure',\n",
- " 'stops': [{'value': 920, 'color': [245, 0, 0, 255]},\n",
- " {'value': 1014, 'color': [245, 245, 0, 255]}]}],\n",
- " 'description': '',\n",
- " 'label': '',\n",
- " 'symbol': {'type': 'styleSymbolReference',\n",
- " 'styleName': 'EsriThematicShapesStyle',\n",
- " 'name': 'Standing Cylinder'}}}},\n",
- " 'popupInfo': {'showAttachments': False,\n",
- " 'title': '{typhoon}',\n",
- " 'popupElements': [{'type': 'fields'}, {'type': 'media'}],\n",
- " 'mediaInfos': [{'type': 'image',\n",
- " 'title': \"\",\n",
- " 'caption': \"Pressure: {airpressure} hPa
Wind speed: {wind_mph} mph / {wind_kph} kph
Date: {timedescription}
\",\n",
- " 'value': {'sourceURL': '{image}'}}]}}],\n",
- " 'layerType': 'GroupLayer',\n",
- " 'visibilityMode': 'inherited'}]"
+ "[,\n",
+ " Group Layer: April - June]"
]
},
+ "execution_count": 20,
"metadata": {},
- "output_type": "display_data"
+ "output_type": "execute_result"
}
],
"source": [
- "# Let us construct a list comprehension and mine out that group layer.\n",
- "subset_op_layers = [subset for subset in web_scene_obj['operationalLayers'] if subset['title'] == 'April - June']\n",
- "display(subset_op_layers)"
- ]
- },
- {
- "cell_type": "code",
- "execution_count": 43,
- "metadata": {},
- "outputs": [],
- "source": [
- "# Let us apply the changes to a new web scene object.\n",
- "new_web_scene_obj = web_scene_obj\n",
- "new_web_scene_obj['operationalLayers'] = subset_op_layers"
+ "new_web_scene_obj.content.layers"
]
},
{
@@ -1328,485 +784,167 @@
"metadata": {},
"source": [
"### Update basemap of new web scene\n",
- "We now have the necessary `operationalLayers` information. Let us also try to change the basemap to a darker shade. First let us search the basemaps available in the current portal. If no suitable one is found, we can widen the search outside the organization and use a basemap published by Esri.\n",
+ "We now have the necessary `layers` information. Let us also try to change the basemap to a darker shade. \n",
"\n",
- "**Basemaps** are web maps that are stored in a **group** usually called **Basemaps**. Thus to get the list of basemaps available on a portal, we can find the basemaps group and list all web maps that are a part of it.\n",
- "\n",
- "To get the list of groups on the portal, we use `groups` property of the `GIS` class."
+ "**Basemaps** are web maps that are stored in a **group** usually called **Basemaps**. Thus to get the list of basemaps available we use the `basemaps` property of `BasemapManager` class"
]
},
{
"cell_type": "code",
- "execution_count": 44,
+ "execution_count": 12,
"metadata": {},
"outputs": [
{
"data": {
- "text/html": [
- "\n",
- "
\n",
- "\n",
- "
\n",
- "
Dark Gray Canvas\n",
- " \n",
- "
This web map provides a detailed vector basemap for the world featuring a neutral background style with minimal colors, labels, and features.
Web Map by esri\n",
- "
Last Modified: February 29, 2024\n",
- "
0 comments, 6999552 views\n",
- "
\n",
- "
\n",
- " "
- ],
- "text/plain": [
- "- "
- ]
- },
- "metadata": {},
- "output_type": "display_data"
- },
- {
- "name": "stdout",
- "output_type": "stream",
- "text": [
- "['basemap', 'esri_basemap', 'vector', 'canvas', 'dark', 'esri_vector', 'v2', 'general availability', 'basemaps', 'wma', 'World_Basemap_v2']\n"
- ]
- },
- {
- "data": {
- "text/html": [
- "
\n",
- "
\n",
- "\n",
- "
\n",
- "
Human Geography Dark Map\n",
- " \n",
- "
This web map consists of vector tile layers that form a detailed basemap for the world, featuring a dark monochromatic style with content adjusted to support Human Geography information.
Web Map by esri\n",
- "
Last Modified: February 29, 2024\n",
- "
2 comments, 255878218 views\n",
- "
\n",
- "
\n",
- " "
- ],
- "text/plain": [
- "- "
- ]
- },
- "metadata": {},
- "output_type": "display_data"
- },
- {
- "name": "stdout",
- "output_type": "stream",
- "text": [
- "['vector', 'basemap', 'esri_vector', 'style', 'sample', 'web map', 'human geography', 'dark', 'human geography dark', 'esri_basemap', 'Andrew Skinner', 'creative']\n"
- ]
- },
- {
- "data": {
- "text/html": [
- "
\n",
- "
\n",
- "\n",
- "
\n",
- "
NZ Dark Grey Canvas (Classic) (Mature Support) \n",
- " \n",
- "
NZ Canvas Dark Basemap draws attention to your thematic content by providing a dark, neutral background with minimal colors, labels, and features.
Web Map by eaglegis\n",
- "
Last Modified: September 29, 2022\n",
- "
0 comments, 1245055 views\n",
- "
\n",
- "
\n",
- " "
- ],
- "text/plain": [
- "- "
- ]
- },
- "metadata": {},
- "output_type": "display_data"
- },
- {
- "name": "stdout",
- "output_type": "stream",
- "text": [
- "['NZ', 'New zealand', 'Basemap', 'Dark Canvas', 'Basemaps', 'esri_basemap', 'parcels', 'urban', 'public', 'Dark Grey', 'Canvas', 'New Zealand', 'Kiwi', 'Map', 'Background', 'Layer', 'topographic', 'topography', 'content', 'living atlas', 'basemaps', 'esri_basemaps', 'detailed', 'digital map', 'KiwiRail', 'Linz', 'NZTA', 'current', 'open data', 'data sets', 'mature support', 'deprecated', 'eaglegis']\n"
- ]
- },
- {
- "data": {
- "text/html": [
- "
\n",
- "
\n",
- "\n",
- "
\n",
- "
Dark Gray Canvas (WGS84)\n",
- " \n",
- "
This web map provides a detailed vector basemap for the world featuring a neutral background style with minimal colors, labels, and features. It uses WGS84 Geographic, version 2 tiling scheme.
Web Map by esri\n",
- "
Last Modified: February 29, 2024\n",
- "
2 comments, 745017 views\n",
- "
\n",
- "
\n",
- " "
- ],
- "text/plain": [
- "- "
- ]
- },
- "metadata": {},
- "output_type": "display_data"
- },
- {
- "name": "stdout",
- "output_type": "stream",
- "text": [
- "['esri_basemap', 'esri_vector', 'GCS', 'WGS84', 'canvas', 'dark gray', 'v2', 'general availability', 'basemaps', 'World_Basemap_GCS_v2', 'vector', 'basemap', 'gcs', 'wkid 4326']\n"
- ]
- },
- {
- "data": {
- "text/html": [
- "
\n",
- "
\n",
- "\n",
- "
\n",
- "
Enhanced Contrast Dark Map\n",
- " \n",
- "
This web map provides a detailed vector basemap for the world with dark colors and enhanced contrast that aim to meet the standards for WCAG and US Government Section 508 compliance. The map detail is built with higher contrast and color-vision-deficient-safe colors.
Web Map by esri_vector\n",
- "
Last Modified: February 29, 2024\n",
- "
0 comments, 87230682 views\n",
- "
\n",
- "
\n",
- " "
- ],
- "text/plain": [
- "- "
- ]
- },
- "metadata": {},
- "output_type": "display_data"
- },
- {
- "name": "stdout",
- "output_type": "stream",
- "text": [
- "['enhanced contrast', 'dark', 'night', 'base', 'basemap', 'basemaps', 'esri_vector', 'Esri Vector Basemaps', 'esri_basemap', 'esri_basemaps', 'WGAC', 'Section 508', 'accessibility', 'reference', 'web map', 'wma', 'World_Basemap_v2', 'general availability']\n"
- ]
- },
- {
- "data": {
- "text/html": [
- "
\n",
- "
\n",
- "\n",
- "
\n",
- "
Navigation (Dark)\n",
- " \n",
- "
This web map provides a detailed basemap for the world featuring a 'dark mode' version of the Navigation vector basemap, using the same content.
Web Map by esri\n",
- "
Last Modified: February 29, 2024\n",
- "
0 comments, 256254519 views\n",
- "
\n",
- "
\n",
- " "
- ],
- "text/plain": [
- "- "
- ]
- },
- "metadata": {},
- "output_type": "display_data"
- },
- {
- "name": "stdout",
- "output_type": "stream",
- "text": [
- "['v2', 'wma', 'World_Basemap_v2', 'global', 'basemaps', 'vector', 'basemap', 'esri_basemap', 'general availability', 'navigation', 'dark', 'dark mode', 'esri_vector']\n"
- ]
- },
- {
- "data": {
- "text/html": [
- "
\n",
- "
\n",
- "\n",
- "
\n",
- "
\n",
- " "
- ],
- "text/plain": [
- "- "
- ]
- },
- "metadata": {},
- "output_type": "display_data"
- },
- {
- "name": "stdout",
- "output_type": "stream",
- "text": [
- "['Portland', 'PDX', 'Basemap', 'Gray', 'Dark']\n"
- ]
- },
- {
- "data": {
- "text/html": [
- "
\n",
- "
\n",
- "\n",
- "
\n",
- "
Dark Gray Canvas\n",
- " \n",
- "
This map is designed to focus attention on your thematic content by providing a neutral background with minimal colors, labels, and features.
Web Map by esri_en\n",
- "
Last Modified: October 25, 2023\n",
- "
1 comments, 338665885 views\n",
- "
\n",
- "
\n",
- " "
- ],
- "text/plain": [
- "- "
- ]
- },
- "metadata": {},
- "output_type": "display_data"
- },
- {
- "name": "stdout",
- "output_type": "stream",
- "text": [
- "['basemap', 'vector']\n"
- ]
- },
- {
- "data": {
- "text/html": [
- "
\n",
- "
\n",
- "\n",
- "
\n",
- "
Dark Gray Canvas\n",
- " \n",
- "
This item is in mature support.
Web Map by esri_en\n",
- "
Last Modified: September 21, 2021\n",
- "
6 comments, 74630977 views\n",
- "
\n",
- "
\n",
- " "
- ],
"text/plain": [
- "- "
- ]
- },
- "metadata": {},
- "output_type": "display_data"
- },
- {
- "name": "stdout",
- "output_type": "stream",
- "text": [
- "['basemap']\n"
- ]
- },
- {
- "data": {
- "text/html": [
- "
\n",
- "
\n",
- "\n",
- "
\n",
- "
Dark Gray Canvas\n",
- " \n",
- "
Dark gray canvas basemap from esri
Web Map by karmstrongSEEM\n",
- "
Last Modified: January 13, 2015\n",
- "
0 comments, 271 views\n",
- "
\n",
- "
\n",
- " "
- ],
- "text/plain": [
- "- "
+ "{'baseMapLayers': [{'id': '73e9780a7d6f413f8547abbd19ec786c',\n",
+ " 'layerType': 'ArcGISTiledMapServiceLayer',\n",
+ " 'listMode': 'show',\n",
+ " 'opacity': 1.0,\n",
+ " 'refreshInterval': 0.0,\n",
+ " 'title': 'World Topo Map',\n",
+ " 'url': 'https://services.arcgisonline.com/ArcGIS/rest/services/World_Topo_Map/MapServer',\n",
+ " 'visibility': True}],\n",
+ " 'title': 'Topographic'}"
]
},
+ "execution_count": 12,
"metadata": {},
- "output_type": "display_data"
- },
- {
- "name": "stdout",
- "output_type": "stream",
- "text": [
- "['basemap']\n"
- ]
+ "output_type": "execute_result"
}
],
"source": [
- "basemap_search = gis.content.search('title:dark', \n",
- " outside_org=True, item_type='web map')\n",
- "for item in basemap_search:\n",
- " display(item)\n",
- " print(item.tags)"
- ]
- },
- {
- "cell_type": "markdown",
- "metadata": {},
- "source": [
- "We have found the basemap of our choice. Let us read it as a **`WebMap`** object and query the `baseMap` dictionary."
+ "new_web_scene_obj.basemap.basemap"
]
},
{
"cell_type": "code",
- "execution_count": 45,
- "metadata": {
- "scrolled": true
- },
+ "execution_count": 13,
+ "metadata": {},
"outputs": [
{
"data": {
"text/plain": [
- "{\n",
- " \"baseMapLayers\": [\n",
- " {\n",
- " \"opacity\": 1,\n",
- " \"title\": \"World Dark Gray Canvas Base\",\n",
- " \"url\": \"https://services.arcgisonline.com/arcgis/rest/services/Canvas/World_Dark_Gray_Base/MapServer\",\n",
- " \"visibility\": true,\n",
- " \"layerType\": \"ArcGISTiledMapServiceLayer\",\n",
- " \"id\": \"layer0\"\n",
- " },\n",
- " {\n",
- " \"opacity\": 1,\n",
- " \"title\": \"World Dark Gray Reference\",\n",
- " \"url\": \"https://services.arcgisonline.com/arcgis/rest/services/Canvas/World_Dark_Gray_Reference/MapServer\",\n",
- " \"visibility\": true,\n",
- " \"layerType\": \"ArcGISTiledMapServiceLayer\",\n",
- " \"isReference\": true,\n",
- " \"id\": \"World_Dark_Gray_Reference_8618\"\n",
- " }\n",
- " ],\n",
- " \"title\": \"Dark Gray Canvas\"\n",
- "}"
+ "['satellite',\n",
+ " 'hybrid',\n",
+ " 'terrain',\n",
+ " 'oceans',\n",
+ " 'osm',\n",
+ " 'dark-gray-vector',\n",
+ " 'gray-vector',\n",
+ " 'streets-vector',\n",
+ " 'topo-vector',\n",
+ " 'streets-night-vector',\n",
+ " 'streets-relief-vector',\n",
+ " 'streets-navigation-vector',\n",
+ " 'arcgis-imagery',\n",
+ " 'arcgis-imagery-standard',\n",
+ " 'arcgis-imagery-labels',\n",
+ " 'arcgis-light-gray',\n",
+ " 'arcgis-dark-gray',\n",
+ " 'arcgis-navigation',\n",
+ " 'arcgis-navigation-night',\n",
+ " 'arcgis-streets',\n",
+ " 'arcgis-streets-night',\n",
+ " 'arcgis-streets-relief',\n",
+ " 'arcgis-topographic',\n",
+ " 'arcgis-oceans',\n",
+ " 'osm-standard',\n",
+ " 'osm-standard-relief',\n",
+ " 'osm-streets',\n",
+ " 'osm-streets-relief',\n",
+ " 'osm-light-gray',\n",
+ " 'osm-dark-gray',\n",
+ " 'arcgis-terrain',\n",
+ " 'arcgis-community',\n",
+ " 'arcgis-charted-territory',\n",
+ " 'arcgis-colored-pencil',\n",
+ " 'arcgis-nova',\n",
+ " 'arcgis-modern-antique',\n",
+ " 'arcgis-midcentury',\n",
+ " 'arcgis-newspaper',\n",
+ " 'arcgis-hillshade-light',\n",
+ " 'arcgis-hillshade-dark',\n",
+ " 'arcgis-human-geography',\n",
+ " 'arcgis-human-geography-dark']"
]
},
- "execution_count": 45,
+ "execution_count": 13,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
- "dark_basemap_item = basemap_search[-2]\n",
- "dark_basemap_obj = WebMap(dark_basemap_item)\n",
- "dark_basemap_obj.basemap"
+ "new_web_scene_obj.basemap.basemaps"
]
},
{
- "cell_type": "markdown",
+ "cell_type": "code",
+ "execution_count": 14,
"metadata": {},
+ "outputs": [],
"source": [
- "Now let us explore what the `baseMap` dictionary of the **web scene** looks like."
+ "new_web_scene_obj.basemap.basemap = new_web_scene_obj.basemap.basemaps[5]"
]
},
{
"cell_type": "code",
- "execution_count": 46,
+ "execution_count": 15,
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
- "{'baseMapLayers': [{'id': '73e9780a7d6f413f8547abbd19ec786c',\n",
- " 'opacity': 1,\n",
- " 'title': 'World Topo Map',\n",
- " 'url': 'https://services.arcgisonline.com/ArcGIS/rest/services/World_Topo_Map/MapServer',\n",
- " 'visibility': True,\n",
- " 'layerType': 'ArcGISTiledMapServiceLayer'}],\n",
- " 'id': 'basemap',\n",
- " 'title': 'Topographic',\n",
- " 'elevationLayers': [{'id': 'globalElevation_0',\n",
- " 'listMode': 'hide',\n",
- " 'title': 'Terrain3D',\n",
- " 'url': 'https://elevation3d.arcgis.com/arcgis/rest/services/WorldElevation3D/Terrain3D/ImageServer',\n",
- " 'visibility': True,\n",
- " 'layerType': 'ArcGISTiledElevationServiceLayer'}]}"
+ "{'baseMapLayers': [{'id': 'dark-gray-base-layer',\n",
+ " 'layerType': 'VectorTileLayer',\n",
+ " 'opacity': 1.0,\n",
+ " 'styleUrl': 'https://www.arcgis.com/sharing/rest/content/items/5e9b3685f4c24d8781073dd928ebda50/resources/styles/root.json',\n",
+ " 'title': 'Dark Gray Base',\n",
+ " 'visibility': True},\n",
+ " {'id': 'dark-gray-reference-layer',\n",
+ " 'isReference': True,\n",
+ " 'layerType': 'VectorTileLayer',\n",
+ " 'opacity': 1.0,\n",
+ " 'styleUrl': 'https://www.arcgis.com/sharing/rest/content/items/747cb7a5329c478cbe6981076cc879c5/resources/styles/root.json',\n",
+ " 'title': 'Dark Gray Reference',\n",
+ " 'visibility': True}],\n",
+ " 'title': 'Dark Gray Vector'}"
]
},
- "execution_count": 46,
+ "execution_count": 15,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
- "new_web_scene_obj['baseMap']"
+ "new_web_scene_obj.basemap.basemap"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
- "To get the desired basemap, we need to update the `url` key-value pair of the web scene's `baseMap` dictionary. Here we will pick the first layer of the dark basemap web map."
+ "Now that we have performed the necessary updates, we can go ahead and publish this as a new web scene item on our portal. We will do this using the `save()` method of the `Scene` class"
]
},
{
"cell_type": "code",
- "execution_count": 47,
+ "execution_count": 59,
"metadata": {},
"outputs": [],
"source": [
- "new_web_scene_obj['baseMap']['baseMapLayers'][0]['url'] = dark_basemap_obj.basemap['baseMapLayers'][0]['url']"
- ]
- },
- {
- "cell_type": "markdown",
- "metadata": {},
- "source": [
- "Now that we have performed the necessary updates, we can go ahead and publish this as a new web scene item on our portal."
+ "web_scene_data_item_prop = {'title':'Tropical Cyclones - Summer',\n",
+ " 'tags' : 'ArcGIS Python API',\n",
+ " 'snippet' : str.format('Subset of {0} published by {1}',\n",
+ " web_scene_item.title, web_scene_item.owner,\n",
+ " \"https://www.arcgis.com/home/item.html?id=\" + web_scene_item.id),\n",
+ " }\n",
+ "\n"
]
},
{
"cell_type": "code",
- "execution_count": 48,
+ "execution_count": 60,
"metadata": {},
"outputs": [
{
@@ -1814,41 +952,33 @@
"text/html": [
"
\n",
"
\n",
"\n",
"
\n",
- "
Toprical Cyclones - Summer\n",
+ " Tropical Cyclones - Summer\n",
" \n",
- "
Subset of
Western Pacific Typhoons (2005) published by esri_3d
Web Scene by arcgis_python\n",
- "
Last Modified: April 15, 2024\n",
+ "
Subset of
Western Pacific Typhoons (2005) by esri_3d published by python_user
Web Scene by python_user\n",
+ "
Last Modified: November 12, 2024\n",
"
0 comments, 0 views\n",
"
\n",
"
\n",
" "
],
"text/plain": [
- "- "
+ "
- "
]
},
- "execution_count": 48,
+ "execution_count": 60,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
- "new_web_scene_properties= {'title':'Toprical Cyclones - Summer',\n",
- " 'type' : 'Web Scene',\n",
- " 'tags' : 'ArcGIS Python API',\n",
- " 'snippet' : str.format('Subset of {0} published by {1}',\n",
- " web_scene_item.title, web_scene_item.owner,\n",
- " \"https://www.arcgis.com/home/item.html?id=\" + web_scene_item.id),\n",
- " 'text' : json.dumps(new_web_scene_obj)}\n",
- "\n",
- "new_item = gis.content.add(new_web_scene_properties)\n",
- "new_item"
+ "web_scene_data_item = new_web_scene_obj.save(item_properties=web_scene_data_item_prop)\n",
+ "web_scene_data_item"
]
},
{
@@ -1860,101 +990,25 @@
},
{
"cell_type": "code",
- "execution_count": 54,
- "metadata": {},
- "outputs": [
- {
- "data": {
- "text/html": [
- ""
- ],
- "text/plain": [
- ""
- ]
- },
- "execution_count": 54,
- "metadata": {},
- "output_type": "execute_result"
- }
- ],
- "source": [
- "new_item.share(True)\n",
- "new_web_scene_obj = WebScene(new_item)\n",
- "new_web_scene_obj"
- ]
- },
- {
- "cell_type": "markdown",
- "metadata": {},
- "source": [
- "Our required updates have been applied to the new web scene. However notice the **April - June** layer is **turned off** by default. Let us fix that and update the web scene.\n",
- "\n",
- "Let us query the `operationalLayer` dictionary of the new web scene and look for a key called `visibility`."
- ]
- },
- {
- "cell_type": "code",
- "execution_count": 51,
- "metadata": {},
- "outputs": [
- {
- "name": "stdout",
- "output_type": "stream",
- "text": [
- "False\n"
- ]
- }
- ],
- "source": [
- "for layer in new_web_scene_obj['operationalLayers']:\n",
- " print(layer['visibility'])"
- ]
- },
- {
- "cell_type": "markdown",
- "metadata": {},
- "source": [
- "As we know, there is just 1 group layer and it is turned off. Let us change that and update the web scene."
- ]
- },
- {
- "cell_type": "code",
- "execution_count": 52,
- "metadata": {},
- "outputs": [],
- "source": [
- "for layer in new_web_scene_obj['operationalLayers']:\n",
- " layer['visibility'] = True"
- ]
- },
- {
- "cell_type": "markdown",
- "metadata": {},
- "source": [
- "To update the web scene call the `update()` method on the web scene object."
- ]
- },
- {
- "cell_type": "code",
- "execution_count": 55,
+ "execution_count": 56,
"metadata": {},
"outputs": [
{
"data": {
"text/html": [
- ""
+ ""
],
"text/plain": [
""
]
},
- "execution_count": 55,
+ "execution_count": 56,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
- "new_web_scene_obj.update()\n",
+ "new_web_scene_obj = Scene(item = web_scene_data_item)\n",
"new_web_scene_obj"
]
},
@@ -1962,8 +1016,8 @@
"cell_type": "markdown",
"metadata": {},
"source": [
- "## Summary\n",
- "In this sample, we observed how to consume web maps, web scenes and how to update them. During this process, the sample showed how to read a web feature layers, how to use geocoding to get co-ordinates of a point of interest, how to modify the map widget using code, how to make copy of an existing item into your account, how to look for basemaps and finally, how to update layer properties within a web scene."
+ "# Summary\n",
+ "In this sample, we observed how to consume web maps, web scenes and how to update them. During this process, the sample showed how to read a web feature layers, how to modify the map widget using code, how to make copy of an existing item into your account, how to look for basemaps"
]
}
],
@@ -1988,7 +1042,7 @@
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
- "version": "3.11.9"
+ "version": "3.11.10"
},
"toc": {
"base_numbering": 1,
@@ -2005,5 +1059,5 @@
}
},
"nbformat": 4,
- "nbformat_minor": 1
+ "nbformat_minor": 4
}