How do you add a basemap for ArcGIS Pro using ArcPy?
For example the Esri World Topographic Map
With this URL: https://basemaps.arcgis.com/arcgis/rest/services/World_Basemap_v2/VectorTileServer
import arcpy
aprx = arcpy.mp.ArcGISProject('CURRENT')
m = aprx.listMaps("Map")[0]
m.addBasemap("https://basemaps.arcgis.com/arcgis/rest/services/World_Basemap_v2/VectorTileServer")
--------------------------------------------------------------------------- RuntimeError Traceback (most recent call last) In [6]: Line 5:
m.addBasemap("https://basemaps.arcgis.com/arcgis/rest/services/World_Basemap_v2/VectorTileServer")File C:\Program Files\ArcGIS\Pro\Resources\ArcPy\arcpy_mp.py, in addBasemap: Line 2374: return convertArcObjectToPythonObject(self._arc_object.addBasemap(*gp_fixargs((basemap_name,), True)))
RuntimeError: Cannot find Basemap : https://basemaps.arcgis.com/arcgis/rest/services/World_Basemap_v2/VectorTileServer
1 Answer 1
You pass a name, not a URL. From the documentation:
addBasemap (basemap_name)
Parameter | Explanation | Data Type |
---|---|---|
basemap_name | The name of the basemap as it appears in the basemap gallery. | String |
If you want to add a custom basemap, use addDataFromPath
.
-
2Thanks. So, this works
m.addDataFromPath("https://basemaps.arcgis.com/arcgis/rest/services/World_Basemap_v2/VectorTileServer")
william3031– william30312023年07月14日 04:15:46 +00:00Commented Jul 14, 2023 at 4:15 -
By the way, the basemap from the url looks a bit different (when loaded) to the default ones of
["World Topographic Map", "World Hillshade"]
. Do you know how I would add those using ArcPy?william3031– william30312023年07月14日 04:23:40 +00:00Commented Jul 14, 2023 at 4:23 -
I've worked out how to not remove them in the first place by using the
dataType
inarcpy.Describe()
.william3031– william30312023年07月14日 04:51:13 +00:00Commented Jul 14, 2023 at 4:51
Explore related questions
See similar questions with these tags.