4

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

5

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.

3
  • 2
    Thanks. So, this works m.addDataFromPath("https://basemaps.arcgis.com/arcgis/rest/services/World_Basemap_v2/VectorTileServer") Commented 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? Commented Jul 14, 2023 at 4:23
  • I've worked out how to not remove them in the first place by using the dataType in arcpy.Describe(). Commented Jul 14, 2023 at 4:51

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.