From 8d0b8ff96ac9999bcaab34c9713c35e3bcba7f11 Mon Sep 17 00:00:00 2001 From: NANAE AUBRY Date: Wed, 23 Oct 2024 11:21:48 +0200 Subject: [PATCH 1/2] update table to pdf --- .../pdf_table_to_pdf_map.ipynb | 123 ++---------------- 1 file changed, 14 insertions(+), 109 deletions(-) diff --git a/samples/05_content_publishers/pdf_table_to_pdf_map.ipynb b/samples/05_content_publishers/pdf_table_to_pdf_map.ipynb index 58c2d28f1b..bd88a39a80 100644 --- a/samples/05_content_publishers/pdf_table_to_pdf_map.ipynb +++ b/samples/05_content_publishers/pdf_table_to_pdf_map.ipynb @@ -1246,8 +1246,7 @@ ], "source": [ "map1 = gis.map('California, USA')\n", - "map1.layout.height = '650px'\n", - "map1.legend = True\n", + "map1.legend.enabled = True\n", "map1" ] }, @@ -1268,15 +1267,17 @@ } ], "source": [ - "map1.clear_graphics()\n", - "overlap_rows.spatial.plot(kind='map', map_widget=map1,\n", - " renderer_type='c', # for class breaks renderer\n", - " method='esriClassifyNaturalBreaks', # classification algorithm\n", - " class_count=7, # choose the number of classes\n", - " col='ACRES', # numeric column to classify\n", - " cmap='hot', # color map to pick colors from for each class\n", - " alpha=0.7 # specify opacity\n", - " )" + "overlap_rows.spatial.plot(map_widget=map1)" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "smm = map1.content.renderer(0).smart_mapping()\n", + "smm.class_breaks_renderer(break_type=\"color\", classification_method='natural-breaks', num_classes=7, field=\"ACRES\")" ] }, { @@ -1342,101 +1343,7 @@ "cell_type": "markdown", "metadata": {}, "source": [ - "If you would also like to export the fire impacting counties into a PDF map, the required steps are: (1) obtain the web map json via the `Item.get_data()` API method, (2) modify the web map json to also include `exportOptions` and `mapOptions`, and (3) use `arcgis.mapping.export_map()` to get the PDF deliverable of the web map." - ] - }, - { - "cell_type": "code", - "execution_count": 25, - "metadata": {}, - "outputs": [ - { - "data": { - "text/plain": [ - "dict_keys(['operationalLayers', 'baseMap', 'spatialReference', 'version', 'authoringApp', 'authoringAppVersion'])" - ] - }, - "execution_count": 25, - "metadata": {}, - "output_type": "execute_result" - } - ], - "source": [ - "webmap_json = item.get_data()\n", - "webmap_json.keys()" - ] - }, - { - "cell_type": "code", - "execution_count": 26, - "metadata": {}, - "outputs": [ - { - "data": { - "text/plain": [ - "{'spatialReference': {'latestWkid': 3857, 'wkid': 102100},\n", - " 'xmin': -14383204.412078053,\n", - " 'ymin': 3664734.601863475,\n", - " 'xmax': -11976355.265435062,\n", - " 'ymax': 5254624.790194718}" - ] - }, - "execution_count": 26, - "metadata": {}, - "output_type": "execute_result" - } - ], - "source": [ - "map1.extent" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "Based on webmap spec, the `mapOptions` and `exportOptions` also need to be specified for the json input. Here, the `extent` and `scale` are chosen based on the extents of the California State [2]." - ] - }, - { - "cell_type": "code", - "execution_count": 27, - "metadata": {}, - "outputs": [], - "source": [ - "webmap_json['mapOptions'] = {\n", - " \"extent\" : {\n", - " \"xmin\": -14383204.412078043,\n", - " \"ymin\": 3664734.6018634685,\n", - " \"xmax\": -11976355.2654350533,\n", - " \"ymax\": 5254624.790194712,\n", - " \"spatialReference\": {\n", - " \"latestWkid\": 3857,\n", - " \"wkid\": 102100\n", - " }\n", - " },\n", - " \"scale\" : 9244648.868618,\n", - " \"spatialReference\" : {\n", - " \"wkid\" : 102100\n", - " }\n", - "}" - ] - }, - { - "cell_type": "code", - "execution_count": 28, - "metadata": {}, - "outputs": [], - "source": [ - "webmap_json['exportOptions'] = { \"dpi\" : 96,\n", - " \"outputSize\" : [746, 575]\n", - " }" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "Finally, we used `export_map` method to create a PDF output of the web map item [3]." + "Finally, we used `print` method to create a PDF output of the web map item [3]." ] }, { @@ -1456,9 +1363,7 @@ } ], "source": [ - "from arcgis.mapping import export_map\n", - "res = export_map(web_map_as_json=webmap_json, format='PDF', layout_template='MAP_ONLY')\n", - "#res[\"url\"]\n", + "res = map1.print(file_format='PDF', layout_template='MAP_ONLY')\n", "res.url" ] }, From c6f1257ac7b0379d495c1c0c2e4054ae27d941e1 Mon Sep 17 00:00:00 2001 From: NANAE AUBRY Date: Thu, 24 Oct 2024 16:57:02 +0200 Subject: [PATCH 2/2] update resource --- samples/05_content_publishers/pdf_table_to_pdf_map.ipynb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/samples/05_content_publishers/pdf_table_to_pdf_map.ipynb b/samples/05_content_publishers/pdf_table_to_pdf_map.ipynb index bd88a39a80..dcecac8ada 100644 --- a/samples/05_content_publishers/pdf_table_to_pdf_map.ipynb +++ b/samples/05_content_publishers/pdf_table_to_pdf_map.ipynb @@ -1384,7 +1384,7 @@ "\n", "[2] https://enterprise.arcgis.com/en/server/latest/create-web-apps/windows/exportwebmap-specification.htm\n", "\n", - "[3] https://developers.arcgis.com/python/api-reference/arcgis.mapping.toc.html?highlight=export#arcgis.mapping.export_map" + "[3] https://developers.arcgis.com/python/latest/api-reference/arcgis.map.toc.html#arcgis.map.Map.print" ] } ],