ArcGIS Desktop

  • ArcGIS Pro
  • ArcMap

  • My Profile
  • Ayuda
  • Sign Out
ArcGIS Desktop

ArcGIS Online

La plataforma de representación cartográfica para tu organización

ArcGIS Desktop

Un completo SIG profesional

ArcGIS Enterprise

SIG en tu empresa

ArcGIS for Developers

Herramientas para crear aplicaciones basadas en la ubicación

ArcGIS Solutions

Plantillas de aplicaciones y mapas gratuitas para tu sector

ArcGIS Marketplace

Obtén aplicaciones y datos para tu organización.

  • Documentación
  • Soporte
Esri
  • Iniciar sesión
user
  • Mi perfil
  • Cerrar sesión

ArcMap

  • Inicio
  • Introducción
  • Cartografiar
  • Analizar
  • Administrar datos
  • Herramientas
  • Extensiones

RemoveLayer

  • Resumen
  • Debate
  • Sintaxis
  • Muestra de código

Resumen

Provides the ability to remove a layer within a data frame in a map document (.mxd).

Debate

RemoveLayer will remove a single layer or group layer from a specific data frame. If there is more than one layer that meets the criteria, then only the first layer will be removed unless the script iterates through each layer in a returned list.

Sintaxis

RemoveLayer (data_frame, remove_layer)
ParámetroExplicaciónTipo de datos
data_frame

A reference to a DataFrame object that contains the layer to be removed.

DataFrame
remove_layer

A reference to a Layer object representing the layer to be removed.

Layer

Muestra de código

RemoveLayer example:

The following script will remove all layers with the name Rivers from a map document.

import arcpy
mxd = arcpy.mapping.MapDocument(r"C:\Project\Project.mxd")
for df in arcpy.mapping.ListDataFrames(mxd):
    for lyr in arcpy.mapping.ListLayers(mxd, "", df):
        if lyr.name.lower() == "rivers":
            arcpy.mapping.RemoveLayer(df, lyr)
mxd.saveACopy(r"C:\Project\Project2.mxd")
del mxd
RemoveLayer example 2

The following script will remove a layer from a data frame called County Maps based on it's name and data source because other layers exist within the data frame with the same name but different source.

import arcpy
mxd = arcpy.mapping.MapDocument(r"C:\Project\Project.mxd")
df = arcpy.mapping.ListDataFrames(mxd, "County Maps")[0]
for lyr in arcpy.mapping.ListLayers(mxd, "", df):
    if lyr.name.lower() == "lakes":
        if lyr.dataSource == r"C:\Project\Data\Data.mdb\NE_Lakes":
            arcpy.mapping.RemoveLayer(df, lyr)
mxd.saveACopy(r"C:\Project\Project2.mxd")
del mxd

ArcGIS Desktop

  • Inicio
  • Documentación
  • Soporte

Plataforma ArcGIS

  • ArcGIS Online
  • ArcGIS Desktop
  • ArcGIS Enterprise
  • ArcGIS for Developers
  • ArcGIS Solutions
  • ArcGIS Marketplace

Acerca de Esri

  • Quiénes somos
  • Empleo
  • Blog de Esri
  • Conferencia de usuarios
  • Cumbre de desarrolladores
Esri
Díganos su opinión.
Copyright © 2019 Esri. | Privacidad | Legal