ArcGIS for Desktop

  • Documentation
  • Tarification
  • Support

  • My Profile
  • Aide
  • Sign Out
ArcGIS for Desktop

ArcGIS Online

La plateforme cartographique de votre organisation

ArcGIS for Desktop

Un SIG professionnel complet

ArcGIS for Server

SIG dans votre entreprise

ArcGIS for Developers

Outils de création d'applications de localisation

ArcGIS Solutions

Modèles d'applications et de cartes gratuits pour votre secteur d'activité

ArcGIS Marketplace

Téléchargez des applications et des données pour votre organisation.

  • Documentation
  • Tarification
  • Support
Esri
  • Se connecter
user
  • Mon profil
  • Déconnexion

Help

  • Accueil
  • Commencer
  • Carte
  • Analyser
  • Gérer les données
  • Outils
  • Plus...

RemoveLayer

  • Récapitulatif
  • Discussion
  • Syntaxe
  • Exemple de code

Récapitulatif

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

Discussion

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.

Syntaxe

RemoveLayer (data_frame, remove_layer)
ParamètreExplicationType de données
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

Exemple de code

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
Vous avez un commentaire à formuler concernant cette rubrique ?

ArcGIS for Desktop

  • Accueil
  • Documentation
  • Tarification
  • Support

ArcGIS Platform

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

A propos d'Esri

  • A propos de la société
  • Carrières
  • Blog des initiés
  • Conférence des utilisateurs
  • Sommet des développeurs
Esri
© Copyright 2016 Environmental Systems Research Institute, Inc. | Confidentialité | Légal