diff --git a/guide/04-feature-data-and-analysis/performing-proximity-analysis-on-feature-data.ipynb b/guide/04-feature-data-and-analysis/performing-proximity-analysis-on-feature-data.ipynb index c2bde53c24..724c3f319b 100644 --- a/guide/04-feature-data-and-analysis/performing-proximity-analysis-on-feature-data.ipynb +++ b/guide/04-feature-data-and-analysis/performing-proximity-analysis-on-feature-data.ipynb @@ -34,7 +34,7 @@ }, { "cell_type": "code", - "execution_count": 2, + "execution_count": 1, "metadata": {}, "outputs": [ { @@ -52,7 +52,7 @@ " \n", "
Locations of various ports along the West Coast of the United States.Feature Layer Collection by api_data_owner\n", "
Last Modified: July 18, 2023\n", - "
0 comments, 5 views\n", + "
0 comments, 27 views\n", " \n", " \n", " " @@ -61,7 +61,7 @@ "" ] }, - "execution_count": 2, + "execution_count": 1, "metadata": {}, "output_type": "execute_result" } @@ -83,13 +83,13 @@ }, { "cell_type": "code", - "execution_count": 33, + "execution_count": 5, "metadata": {}, "outputs": [ { "data": { "text/html": [ - "" + "" ], "text/plain": [ "" @@ -106,7 +106,7 @@ }, { "cell_type": "code", - "execution_count": 31, + "execution_count": 3, "metadata": {}, "outputs": [], "source": [ @@ -116,7 +116,7 @@ }, { "cell_type": "code", - "execution_count": 32, + "execution_count": 4, "metadata": {}, "outputs": [], "source": [ @@ -133,29 +133,7 @@ }, { "cell_type": "code", - "execution_count": null, - "metadata": {}, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "Submitted.\n", - "Executing...\n" - ] - } - ], - "source": [ - "from arcgis.features import use_proximity\n", - "\n", - "#access the first layer in ports_item\n", - "ports_layer1 = ports_item.layers[0]\n", - "ports_buffer50 = use_proximity.create_buffers(ports_layer1, distances=[50], units = 'Miles')" - ] - }, - { - "cell_type": "code", - "execution_count": 4, + "execution_count": 6, "metadata": {}, "outputs": [ { @@ -164,6 +142,34 @@ "text": [ "{\"cost\": 0.021}\n" ] + }, + { + "data": { + "text/html": [ + "
\n", + "
\n", + " \n", + " \n", + " \n", + "
\n", + "\n", + "
\n", + " Buffers_around_ports\n", + " \n", + "
Feature Layer Collection by arcgis_python\n", + "
Last Modified: April 11, 2024\n", + "
0 comments, 0 views\n", + "
\n", + "
\n", + " " + ], + "text/plain": [ + "" + ] + }, + "execution_count": 6, + "metadata": {}, + "output_type": "execute_result" } ], "source": [ @@ -171,7 +177,8 @@ "\n", "#access the first layer in ports_item\n", "ports_layer1 = ports_item.layers[0]\n", - "ports_buffer50 = use_proximity.create_buffers(ports_layer1, distances=[50], units = 'Miles')" + "ports_buffer50 = use_proximity.create_buffers(ports_layer1, distances=[50], units = 'Miles', output_name='Buffers around ports')\n", + "ports_buffer50" ] }, { @@ -183,16 +190,16 @@ }, { "cell_type": "code", - "execution_count": null, + "execution_count": 7, "metadata": {}, "outputs": [ { "data": { "text/plain": [ - "arcgis.features.feature.FeatureCollection" + "arcgis.gis.Item" ] }, - "execution_count": null, + "execution_count": 7, "metadata": {}, "output_type": "execute_result" } @@ -205,20 +212,20 @@ "cell_type": "markdown", "metadata": {}, "source": [ - "`ports_buffer50` is an in memory feature collection and has not been persisted as an item on the portal because we did not specify `output_name` parameter to the tool.\n", + "`ports_buffer50` is a new Feature Collection Item in portal. Had we not specified the `output_name` parameter while running the tool, `ports_buffer50` would be an in memory Feature Collection object and would not be saved as an item on the portal.\n", "\n", - "Let us add the result to a new map" + "Let us add the result to a new map." ] }, { "cell_type": "code", - "execution_count": 23, + "execution_count": 10, "metadata": {}, "outputs": [ { "data": { "text/html": [ - "" + "" ], "text/plain": [ "" @@ -235,7 +242,7 @@ }, { "cell_type": "code", - "execution_count": 21, + "execution_count": 8, "metadata": {}, "outputs": [], "source": [ @@ -245,11 +252,11 @@ }, { "cell_type": "code", - "execution_count": 22, + "execution_count": 9, "metadata": {}, "outputs": [], "source": [ - "map2.add_layer(ports_buffer50)" + "map2.add_layer(ports_buffer50.layers[0])" ] }, { @@ -263,85 +270,155 @@ }, { "cell_type": "code", - "execution_count": null, - "metadata": {}, + "execution_count": 11, + "metadata": { + "scrolled": false + }, "outputs": [ { "data": { "text/plain": [ "[{\n", - " \"nullable\": false,\n", - " \"name\": \"objectid\",\n", - " \"alias\": \"objectid\",\n", - " \"type\": \"esriFieldTypeOID\",\n", - " \"domain\": null,\n", - " \"editable\": false\n", - " }, {\n", - " \"nullable\": true,\n", - " \"name\": \"port_name\",\n", - " \"alias\": \"port_name\",\n", - " \"type\": \"esriFieldTypeString\",\n", - " \"domain\": null,\n", - " \"length\": 8000,\n", - " \"editable\": true\n", - " }, {\n", - " \"nullable\": true,\n", " \"name\": \"country\",\n", + " \"type\": \"esriFieldTypeString\",\n", + " \"actualType\": \"nvarchar\",\n", " \"alias\": \"country\",\n", + " \"sqlType\": \"sqlTypeNVarchar\",\n", + " \"length\": 4000,\n", + " \"nullable\": true,\n", + " \"editable\": true,\n", + " \"domain\": null,\n", + " \"defaultValue\": null\n", + " },\n", + " {\n", + " \"name\": \"globalid\",\n", " \"type\": \"esriFieldTypeString\",\n", + " \"actualType\": \"nvarchar\",\n", + " \"alias\": \"globalid\",\n", + " \"sqlType\": \"sqlTypeNVarchar\",\n", + " \"length\": 4000,\n", + " \"nullable\": true,\n", + " \"editable\": true,\n", " \"domain\": null,\n", - " \"length\": 8000,\n", - " \"editable\": true\n", - " }, {\n", + " \"defaultValue\": null\n", + " },\n", + " {\n", + " \"name\": \"harborsize\",\n", + " \"type\": \"esriFieldTypeString\",\n", + " \"actualType\": \"nvarchar\",\n", + " \"alias\": \"harborsize\",\n", + " \"sqlType\": \"sqlTypeNVarchar\",\n", + " \"length\": 4000,\n", " \"nullable\": true,\n", - " \"name\": \"longitude\",\n", - " \"alias\": \"longitude\",\n", - " \"type\": \"esriFieldTypeDouble\",\n", + " \"editable\": true,\n", " \"domain\": null,\n", - " \"editable\": true\n", - " }, {\n", + " \"defaultValue\": null\n", + " },\n", + " {\n", + " \"name\": \"label_position\",\n", + " \"type\": \"esriFieldTypeString\",\n", + " \"actualType\": \"nvarchar\",\n", + " \"alias\": \"label_position\",\n", + " \"sqlType\": \"sqlTypeNVarchar\",\n", + " \"length\": 4000,\n", " \"nullable\": true,\n", + " \"editable\": true,\n", + " \"domain\": null,\n", + " \"defaultValue\": null\n", + " },\n", + " {\n", " \"name\": \"latitude\",\n", + " \"type\": \"esriFieldTypeDouble\",\n", + " \"actualType\": \"float\",\n", " \"alias\": \"latitude\",\n", + " \"sqlType\": \"sqlTypeFloat\",\n", + " \"nullable\": true,\n", + " \"editable\": true,\n", + " \"domain\": null,\n", + " \"defaultValue\": null\n", + " },\n", + " {\n", + " \"name\": \"longitude\",\n", " \"type\": \"esriFieldTypeDouble\",\n", + " \"actualType\": \"float\",\n", + " \"alias\": \"longitude\",\n", + " \"sqlType\": \"sqlTypeFloat\",\n", + " \"nullable\": true,\n", + " \"editable\": true,\n", " \"domain\": null,\n", - " \"editable\": true\n", - " }, {\n", + " \"defaultValue\": null\n", + " },\n", + " {\n", + " \"name\": \"port_name\",\n", + " \"type\": \"esriFieldTypeString\",\n", + " \"actualType\": \"nvarchar\",\n", + " \"alias\": \"port_name\",\n", + " \"sqlType\": \"sqlTypeNVarchar\",\n", + " \"length\": 4000,\n", " \"nullable\": true,\n", - " \"name\": \"harborsize\",\n", - " \"alias\": \"harborsize\",\n", + " \"editable\": true,\n", + " \"domain\": null,\n", + " \"defaultValue\": null\n", + " },\n", + " {\n", + " \"name\": \"short_form\",\n", " \"type\": \"esriFieldTypeString\",\n", + " \"actualType\": \"nvarchar\",\n", + " \"alias\": \"short_form\",\n", + " \"sqlType\": \"sqlTypeNVarchar\",\n", + " \"length\": 4000,\n", + " \"nullable\": true,\n", + " \"editable\": true,\n", " \"domain\": null,\n", - " \"length\": 8000,\n", - " \"editable\": true\n", - " }, {\n", + " \"defaultValue\": null\n", + " },\n", + " {\n", + " \"name\": \"geometry_x\",\n", + " \"type\": \"esriFieldTypeInteger\",\n", + " \"actualType\": \"int\",\n", + " \"alias\": \"geometry.x\",\n", + " \"sqlType\": \"sqlTypeInteger\",\n", " \"nullable\": true,\n", - " \"name\": \"label_position\",\n", - " \"alias\": \"label_position\",\n", - " \"type\": \"esriFieldTypeString\",\n", + " \"editable\": true,\n", " \"domain\": null,\n", - " \"length\": 8000,\n", - " \"editable\": true\n", - " }, {\n", + " \"defaultValue\": null\n", + " },\n", + " {\n", + " \"name\": \"geometry_y\",\n", + " \"type\": \"esriFieldTypeInteger\",\n", + " \"actualType\": \"int\",\n", + " \"alias\": \"geometry.y\",\n", + " \"sqlType\": \"sqlTypeInteger\",\n", " \"nullable\": true,\n", - " \"name\": \"short_form\",\n", - " \"alias\": \"short_form\",\n", - " \"type\": \"esriFieldTypeString\",\n", + " \"editable\": true,\n", " \"domain\": null,\n", - " \"length\": 8000,\n", - " \"editable\": true\n", - " }, {\n", + " \"defaultValue\": null\n", + " },\n", + " {\n", + " \"name\": \"ObjectId\",\n", + " \"type\": \"esriFieldTypeOID\",\n", + " \"actualType\": \"int\",\n", + " \"alias\": \"ObjectId\",\n", + " \"sqlType\": \"sqlTypeInteger\",\n", " \"nullable\": false,\n", - " \"length\": 38,\n", - " \"alias\": \"globalid\",\n", + " \"editable\": false,\n", + " \"domain\": null,\n", + " \"defaultValue\": null\n", + " },\n", + " {\n", + " \"name\": \"GlobalID_2\",\n", " \"type\": \"esriFieldTypeGlobalID\",\n", + " \"alias\": \"GlobalID_2\",\n", + " \"sqlType\": \"sqlTypeOther\",\n", + " \"length\": 38,\n", + " \"nullable\": false,\n", + " \"editable\": false,\n", " \"domain\": null,\n", - " \"name\": \"globalid\",\n", - " \"editable\": false\n", + " \"defaultValue\": \"NEWID() WITH VALUES\"\n", " }]" ] }, - "execution_count": null, + "execution_count": 11, "metadata": {}, "output_type": "execute_result" } @@ -354,12 +431,12 @@ "cell_type": "markdown", "metadata": {}, "source": [ - "`latitude` seems to be a suitable field. This time, let us store the result on the portal" + "`latitude` seems to be a suitable field. We will now use this field while creating buffers." ] }, { "cell_type": "code", - "execution_count": 34, + "execution_count": 12, "metadata": {}, "outputs": [ { @@ -374,32 +451,12 @@ "ports_buffer_lat = use_proximity.create_buffers(ports_layer1,\n", " field='latitude',\n", " units='kilometers',\n", - " output_name='ports_buffers_lat1')" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": {}, - "outputs": [ - { - "data": { - "text/plain": [ - "arcgis.gis.Item" - ] - }, - "execution_count": null, - "metadata": {}, - "output_type": "execute_result" - } - ], - "source": [ - "type(ports_buffer_lat)" + " output_name='ports_buffers_with_lat')" ] }, { "cell_type": "code", - "execution_count": 35, + "execution_count": 13, "metadata": {}, "outputs": [ { @@ -407,26 +464,26 @@ "text/html": [ "
\n", "
\n", - " \n", + " \n", " \n", " \n", "
\n", "\n", "
\n", - " ports_buffers_lat1\n", + " ports_buffers_with_lat\n", " \n", "
Feature Layer Collection by arcgis_python\n", - "
Last Modified: July 18, 2023\n", + "
Last Modified: April 11, 2024\n", "
0 comments, 0 views\n", "
\n", "
\n", " " ], "text/plain": [ - "" + "" ] }, - "execution_count": 35, + "execution_count": 13, "metadata": {}, "output_type": "execute_result" } @@ -439,18 +496,18 @@ "cell_type": "markdown", "metadata": {}, "source": [ - "Thus, an item has been created on the portal storing the result. Let us add this back to the map. Scroll above to see the result" + "We will add this result to the map." ] }, { "cell_type": "code", - "execution_count": 39, + "execution_count": 18, "metadata": {}, "outputs": [ { "data": { "text/html": [ - "" + "" ], "text/plain": [ "" @@ -467,7 +524,7 @@ }, { "cell_type": "code", - "execution_count": 37, + "execution_count": 15, "metadata": {}, "outputs": [], "source": [ @@ -477,11 +534,11 @@ }, { "cell_type": "code", - "execution_count": 38, + "execution_count": 16, "metadata": {}, "outputs": [], "source": [ - "map3.add_layer(ports_buffer_lat)" + "map3.add_layer(ports_buffer_lat.layers[0])" ] }, { @@ -498,7 +555,7 @@ }, { "cell_type": "code", - "execution_count": 103, + "execution_count": 19, "metadata": {}, "outputs": [], "source": [ @@ -516,21 +573,20 @@ }, { "cell_type": "code", - "execution_count": 132, + "execution_count": 23, "metadata": {}, "outputs": [ { "data": { "text/html": [ - "" + "" ], "text/plain": [ - "" + "" ] }, - "execution_count": 132, "metadata": {}, - "output_type": "execute_result" + "output_type": "display_data" } ], "source": [ @@ -540,7 +596,7 @@ }, { "cell_type": "code", - "execution_count": 126, + "execution_count": 21, "metadata": {}, "outputs": [], "source": [ @@ -549,7 +605,7 @@ }, { "cell_type": "code", - "execution_count": 127, + "execution_count": 22, "metadata": {}, "outputs": [], "source": [ @@ -565,7 +621,7 @@ }, { "cell_type": "code", - "execution_count": 108, + "execution_count": 24, "metadata": {}, "outputs": [], "source": [ @@ -574,7 +630,7 @@ }, { "cell_type": "code", - "execution_count": 118, + "execution_count": 25, "metadata": {}, "outputs": [], "source": [ @@ -591,16 +647,28 @@ }, { "cell_type": "code", - "execution_count": 122, + "execution_count": 26, "metadata": {}, "outputs": [ { "name": "stderr", "output_type": "stream", "text": [ + "Travel mode not set, using default travel mode\n", "Network elements with avoid-restrictions are traversed in the output (restriction attribute names: \"Through Traffic Prohibited\").\n", "{\"cost\": 1.0}\n" ] + }, + { + "data": { + "text/plain": [ + "{'routes_layer': ,\n", + " 'assigned_stops_layer': }" + ] + }, + "execution_count": 26, + "metadata": {}, + "output_type": "execute_result" } ], "source": [ @@ -608,7 +676,8 @@ "route1 = use_proximity.plan_routes(stops_fc, route_count=1,\n", " max_stops_per_route=5,\n", " route_start_time = time.time(),\n", - " start_layer = airport_fc)" + " start_layer = airport_fc)\n", + "route1" ] }, { @@ -620,12 +689,33 @@ }, { "cell_type": "code", - "execution_count": 128, + "execution_count": 29, "metadata": {}, - "outputs": [], + "outputs": [ + { + "data": { + "text/html": [ + "" + ], + "text/plain": [ + "" + ] + }, + "metadata": {}, + "output_type": "display_data" + } + ], "source": [ - "map4.add_layer(route1['routes_layer'])" + "map4.add_layer(route1['routes_layer'])\n", + "map4" ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [] } ], "metadata": { @@ -644,7 +734,7 @@ "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", - "version": "3.9.16" + "version": "3.11.5" }, "toc": { "base_numbering": 1,