Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update table to pdf #2133

Open
wants to merge 5 commits into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
125 changes: 15 additions & 110 deletions samples/05_content_publishers/pdf_table_to_pdf_map.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -1246,8 +1246,7 @@
],
Copy link
Contributor

@cariashuang0417 cariashuang0417 Oct 24, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

reference 3 needs to be updated to the new doc :)


Reply via ReviewNB

"source": [
"map1 = gis.map('California, USA')\n",
"map1.layout.height = '650px'\n",
"map1.legend = True\n",
"map1.legend.enabled = True\n",
"map1"
]
},
Expand All @@ -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\")"
]
},
{
Expand Down Expand Up @@ -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 <a href=\"https://enterprise.arcgis.com/en/server/latest/create-web-apps/windows/exportwebmap-specification.htm\">webmap spec</a>, 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 <a href=\"#References\">[2]</a>."
]
},
{
"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 <a href=\"https://developers.arcgis.com/python/api-reference/arcgis.mapping.toc.html?highlight=export#arcgis.mapping.export_map\">`export_map`</a> method to create a PDF output of the web map item <a href=\"#References\">[3]</a>."
"Finally, we used <a href=\"https://developers.arcgis.com/python/latest/api-reference/arcgis.map.toc.html#arcgis.map.Map.print\">`print`</a> method to create a PDF output of the web map item <a href=\"#References\">[3]</a>."
]
},
{
Expand All @@ -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"
]
},
Expand All @@ -1479,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"
]
}
],
Expand Down