Select to view content in your preferred language

Capturing a Map Image

114
1
12-03-2024 09:43 AM
jchadwich1
Emerging Contributor

I'm working on a custom geoprocessing tool using the ArcGIS API for Python that I plan to use in an ArcGIS dashboard on ArcGIS Online - Enterprise version 11.1. My goal is for the user to select a point location from a drop-down list and generate a PDF report from a template I have stored online. The report will include various bits of data from the entry they've selected and a map image. I've managed to access the data and pull what I need from it, but I can't seem to capture an image of the map. Everything I see online points me to using the arcgis.mapping module, but it looks like that one and the .widget module were refactored into the .map module earlier this year according to this page. However, I can't figure out how to capture and export an image using the .map module or any other tools within the ArcGIS API. Does anyone know how this can be done?

Edit: This doesn't have to be done within dashboards, I can use experience builder as well.

When I run the following bit of code I end up with this error:

"ImportError: cannot import name 'WebMap' from 'arcgis.mapping'"

from arcgis.gis import GIS
from arcgis.mapping import WebMap

gis = GIS("https://www.arcgis.com/home/")

web_map_item = gis.content.get("webmap-id")
web_map = WebMap(web_map_item)
image = web_map.export_to_image("png", resolution=300) 

 

 

 

 

 

 

 

 

 

 

0 Kudos
1 Reply
Jen_Zumbado-Hannibal
Frequent Contributor

It's deprecated in 2.4. 

  • WebMap - removed in 2.4.0. Use arcgis.map.Map instead. 

https://github.com/Esri/arcgis-python-api/blob/master/guide/02-api-overview/deprecation-notices.ipyn...

 

Jen Zumbado-Hannibal, GISP
GIS Coordinator
City of Forest Grove
Forest Grove, OR 97116

0 Kudos