diff --git a/samples/04_gis_analysts_data_scientists/safe_streets_to_schools.ipynb b/samples/04_gis_analysts_data_scientists/safe_streets_to_schools.ipynb index 28b081571..22ee07707 100644 --- a/samples/04_gis_analysts_data_scientists/safe_streets_to_schools.ipynb +++ b/samples/04_gis_analysts_data_scientists/safe_streets_to_schools.ipynb @@ -88,7 +88,7 @@ "\n", "from arcgis.gis import GIS\n", "from arcgis.features.analyze_patterns import calculate_density, find_hot_spots\n", - "from arcgis.mapping.symbol import create_symbol\n", + "from arcgis.map import renderers, symbols\n", "from arcgis.features.use_proximity import create_drive_time_areas\n", "from arcgis.features.summarize_data import summarize_within" ] @@ -104,7 +104,7 @@ "cell_type": "markdown", "metadata": {}, "source": [ - "Connect to the GIS via an existing profile or creating a new connection by e.g. gis = GIS(\"https://www.arcgis.com\", \"arcgis_python\", \"P@ssword123\")" + "Connect to the GIS via an existing profile." ] }, { @@ -113,7 +113,7 @@ "metadata": {}, "outputs": [], "source": [ - "gis = GIS('home')" + "gis = GIS(profile='your_online_profile')" ] }, { @@ -149,17 +149,17 @@ "text/html": [ "
5 rows × 57 columns
\n", + "5 rows × 57 columns
\n", "" ], "text/plain": [ @@ -909,16 +942,16 @@ "58 22517 Clear 6525309.99742721 1885626.50722028 \n", "\n", " SHAPE \n", - "1 {'x': -13151952.7988482, 'y': 4048399.24990493... \n", - "11 {'x': -13152278.024718883, 'y': 4048894.055900... \n", - "26 {'x': -13154141.264326861, 'y': 4050727.197689... \n", - "29 {'x': -13151959.551540626, 'y': 4050015.650237... \n", - "58 {'x': -13149081.688380858, 'y': 4052153.917797... \n", + "1 {\"x\": -13151952.7988482, \"y\": 4048399.24990493... \n", + "11 {\"x\": -13152278.024718883, \"y\": 4048894.055900... \n", + "26 {\"x\": -13154141.264326861, \"y\": 4050727.197689... \n", + "29 {\"x\": -13151959.551540626, \"y\": 4050015.650237... \n", + "58 {\"x\": -13149081.688380858, \"y\": 4052153.917797... \n", "\n", "[5 rows x 57 columns]" ] }, - "execution_count": 29, + "execution_count": 17, "metadata": {}, "output_type": "execute_result" } @@ -949,7 +982,7 @@ }, { "cell_type": "code", - "execution_count": 30, + "execution_count": 18, "metadata": {}, "outputs": [], "source": [ @@ -969,7 +1002,7 @@ }, { "cell_type": "code", - "execution_count": 31, + "execution_count": 19, "metadata": {}, "outputs": [ { @@ -978,7 +1011,7 @@ "\"\\nvar acc_type = $feature.InvWith;\\nvar fatal = $feature.Nokilled;\\nvar injured = $feature.NoInjured;\\nvar result = When( \\n acc_type == 'Pedestrian' && fatal == '1' , 'PedestrianFatality',\\n acc_type == 'Pedestrian' && injured != '0', 'PedestrianInjury',\\n acc_type == 'Bicycle' && injured != '0', 'BicycleInjury',\\n acc_type == 'Bicycle' && fatal == '1', 'BicycleFatality',\\n 'null');\\nreturn result;\\n\"" ] }, - "execution_count": 31, + "execution_count": 19, "metadata": {}, "output_type": "execute_result" } @@ -996,18 +1029,21 @@ }, { "cell_type": "code", - "execution_count": 32, + "execution_count": 20, "metadata": {}, "outputs": [], "source": [ "def get_symbol(color, size):\n", - " return create_symbol(geometry_type='point',\n", - " symbol_type='simple',\n", - " symbol_style='o',\n", - " colors=color,\n", - " marker_size=size,\n", - " outline_style='s',\n", - " outline_color=[153,153,153,255], line_width=0.375)\n", + " outline = symbols.SimpleLineSymbolEsriSLS(\n", + " color=[153,153,153,255],\n", + " style=symbols.SimpleLineSymbolStyle.esri_sls_solid,\n", + " width=0.375)\n", + " symbol = symbols.SimpleMarkerSymbolEsriSMS(\n", + " color=color,\n", + " style = symbols.SimpleMarkerSymbolStyle.esri_sms_circle,\n", + " size=size,\n", + " outline=outline)\n", + " return symbol\n", "\n", "\n", "def get_unique_values(color_list, values):\n", @@ -1016,37 +1052,73 @@ }, { "cell_type": "code", - "execution_count": 33, + "execution_count": 79, "metadata": {}, "outputs": [], "source": [ - "color_list = [ [255, 0, 0, 255], [0, 255, 0, 255], [0, 0, 255, 255], [0 , 255, 255, 255] ] \n", + "color_list = [ [255, 0, 0, 255], [0, 255, 0, 255], [255, 172, 28, 255], [0 , 255, 255, 255] ] \n", "values = ['PedestrianFatality', 'PedestrianInjury', 'BicycleInjury', 'BicycleFatality']\n", "sizes = [15, 3, 3, 15]\n", - "uv = get_unique_values(color_list, values)" + "unique_value_list = get_unique_values(color_list, values)" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "Let us take a look at the `unique_value_list` list that we built to generate unique values for the collision types. We will use this to build our custom `UniqueValueRenderer`." ] }, { "cell_type": "code", - "execution_count": 34, + "execution_count": 80, + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "[{'label': 'PedestrianFatality', 'symbol': SimpleMarkerSymbolEsriSMS(angle=None, color=[255, 0, 0, 255], outline=SimpleLineSymbolEsriSLS(color=[153, 153, 153, 255], marker=None, style='esriSLSSolid', type='esriSLS', width=0.375), size=15, style='esriSMSCircle', type='esriSMS', xoffset=None, yoffset=None), 'value': 'PedestrianFatality'}, {'label': 'PedestrianInjury', 'symbol': SimpleMarkerSymbolEsriSMS(angle=None, color=[0, 255, 0, 255], outline=SimpleLineSymbolEsriSLS(color=[153, 153, 153, 255], marker=None, style='esriSLSSolid', type='esriSLS', width=0.375), size=3, style='esriSMSCircle', type='esriSMS', xoffset=None, yoffset=None), 'value': 'PedestrianInjury'}, {'label': 'BicycleInjury', 'symbol': SimpleMarkerSymbolEsriSMS(angle=None, color=[255, 172, 28, 255], outline=SimpleLineSymbolEsriSLS(color=[153, 153, 153, 255], marker=None, style='esriSLSSolid', type='esriSLS', width=0.375), size=3, style='esriSMSCircle', type='esriSMS', xoffset=None, yoffset=None), 'value': 'BicycleInjury'}, {'label': 'BicycleFatality', 'symbol': SimpleMarkerSymbolEsriSMS(angle=None, color=[0, 255, 255, 255], outline=SimpleLineSymbolEsriSLS(color=[153, 153, 153, 255], marker=None, style='esriSLSSolid', type='esriSLS', width=0.375), size=15, style='esriSMSCircle', type='esriSMS', xoffset=None, yoffset=None), 'value': 'BicycleFatality'}]\n" + ] + } + ], + "source": [ + "print(unique_value_list)" + ] + }, + { + "cell_type": "code", + "execution_count": 81, + "metadata": {}, + "outputs": [], + "source": [ + "accident_renderer = renderers.UniqueValueRenderer(\n", + " valueExpression = arcade_expression,\n", + " unique_value_infos = unique_value_list)" + ] + }, + { + "cell_type": "code", + "execution_count": 88, "metadata": {}, "outputs": [ { "data": { "text/html": [ - "" + "" ], "text/plain": [ "