Understanding ArcPy’s MakeFeatureLayer in order to edit data of a FeatureClass in ArcGIS Pro with a standalone script in VS Studio

I’m pretty new in ArcGIS and Arcpy, but experienced in Python. At the moment, I am working on an existing Python-Code in VS Studio (not my Code). I have some trouble understanding ArcPy’s MakeFeatureLayer , in order to edit FeatureClasses in ArcGIS by using SelectLayerByAttributes. I struggle with some basics here. Here is a simple piece of code:

import arcpy

# Step 1: Import FeatureClass
inPath = arcpy.GetParameterAsText(0)  # inPath will be a FeatureClass (Polygons)

# Step 2: MakeFeatureLayer (necessary for selection)
arcpy.management.MakeFeatureLayer(inPath, inPath)

# Step 3: Select and dissolve data
arcpy.management.SelectLayerByAttribute(inPath,"NEW_SELECTION","status = 'white'")
arcpy.analysis.PairwiseDissolve(inPath,inPath + "_diss", dissolve_field="status",  statistics_fields="", multi_part="SINGLE_PART")
arcpy.management.SelectLayerByAttribute(inPath,"CLEAR_SELECTION")

# Step 4: Select and calcualte field
arcpy.management.SelectLayerByAttribute(inPath,"NEW_SELECTION","status = 'white'")
arcpy.management.CalculateField(inPath,"symbol", 1)
arcpy.management.SelectLayerByAttribute(inPath,"CLEAR_SELECTION")

# Step 5: Select and delete fields
arcpy.management.SelectLayerByAttribute(inPath,"NEW_SELECTION","status = 'red'")
arcpy.management.DeleteFeatures(inPath)
arcpy.management.SelectLayerByAttribute(inPath,"CLEAR_SELECTION")

Code steps:

  1. Load in FeatureClass (Polygons)

  2. MakeFeatureLayer: Name of FeatureClass and FeatureLayer is the same in the code.

  3. SelectLayerByAttributes: There is a field called “status” which contains several “colors” in form of a string (red, green, white, yellow, orange). I only want to select the white ones. Dissolve all selected (white) polygons and write out to new FeatureClass

  4. CalculateField: I want to calculate the field “symbol” for all selected “white” fields and write the number 1 in it.

  5. DeleteFeatures: I want to select all “red” fields in “status” and delete them.

My understanding problems here:

  • In order to do the selection, I need to MakeFeatureLayer first and pass in the FeatureClass. As I understand it right, this step is necessary, because a Layer points to the data of the FeatureClass and make this data editable. Is it a problem or even necessary, that the FeatureLayer has the same name as the FeatureClass? Does it make any difference, when the name of the Layer is different to the name of the FeatureClass as long as I pass the right named Layer to the following commands?

  • Is there a kind of “invisible link” between Layer and FeatureClass? Does any change of the data in the Layer always automatically change the “linked” FeatureClass by itself? In my code example, after each step of editing (Dissolve, CalculateField, DeleteFeatures), I loaded the FeatureClass in ArcGIS and all the changes are done perfectly. There is no need to store or export the Layer sepperatly.

  • The Layer is only temporary. For how long does the Layer “stay active” within my script in VS Studio. Is it possible to edit Layer and therefore the FeatureClass later on again and again? In my script, the MakeFeatureLayer is done several times at different locations, always with the same FeatureClass as input. It seems, that in between the temporary Layer “dissappear”.

I hope my issues are described quiete clear. Thanks for help.

Trang chủ Giới thiệu Sinh nhật bé trai Sinh nhật bé gái Tổ chức sự kiện Biểu diễn giải trí Dịch vụ khác Trang trí tiệc cưới Tổ chức khai trương Tư vấn dịch vụ Thư viện ảnh Tin tức - sự kiện Liên hệ Chú hề sinh nhật Trang trí YEAR END PARTY công ty Trang trí tất niên cuối năm Trang trí tất niên xu hướng mới nhất Trang trí sinh nhật bé trai Hải Đăng Trang trí sinh nhật bé Khánh Vân Trang trí sinh nhật Bích Ngân Trang trí sinh nhật bé Thanh Trang Thuê ông già Noel phát quà Biểu diễn xiếc khỉ Xiếc quay đĩa Dịch vụ tổ chức sự kiện 5 sao Thông tin về chúng tôi Dịch vụ sinh nhật bé trai Dịch vụ sinh nhật bé gái Sự kiện trọn gói Các tiết mục giải trí Dịch vụ bổ trợ Tiệc cưới sang trọng Dịch vụ khai trương Tư vấn tổ chức sự kiện Hình ảnh sự kiện Cập nhật tin tức Liên hệ ngay Thuê chú hề chuyên nghiệp Tiệc tất niên cho công ty Trang trí tiệc cuối năm Tiệc tất niên độc đáo Sinh nhật bé Hải Đăng Sinh nhật đáng yêu bé Khánh Vân Sinh nhật sang trọng Bích Ngân Tiệc sinh nhật bé Thanh Trang Dịch vụ ông già Noel Xiếc thú vui nhộn Biểu diễn xiếc quay đĩa Dịch vụ tổ chức tiệc uy tín Khám phá dịch vụ của chúng tôi Tiệc sinh nhật cho bé trai Trang trí tiệc cho bé gái Gói sự kiện chuyên nghiệp Chương trình giải trí hấp dẫn Dịch vụ hỗ trợ sự kiện Trang trí tiệc cưới đẹp Khởi đầu thành công với khai trương Chuyên gia tư vấn sự kiện Xem ảnh các sự kiện đẹp Tin mới về sự kiện Kết nối với đội ngũ chuyên gia Chú hề vui nhộn cho tiệc sinh nhật Ý tưởng tiệc cuối năm Tất niên độc đáo Trang trí tiệc hiện đại Tổ chức sinh nhật cho Hải Đăng Sinh nhật độc quyền Khánh Vân Phong cách tiệc Bích Ngân Trang trí tiệc bé Thanh Trang Thuê dịch vụ ông già Noel chuyên nghiệp Xem xiếc khỉ đặc sắc Xiếc quay đĩa thú vị
Trang chủ Giới thiệu Sinh nhật bé trai Sinh nhật bé gái Tổ chức sự kiện Biểu diễn giải trí Dịch vụ khác Trang trí tiệc cưới Tổ chức khai trương Tư vấn dịch vụ Thư viện ảnh Tin tức - sự kiện Liên hệ Chú hề sinh nhật Trang trí YEAR END PARTY công ty Trang trí tất niên cuối năm Trang trí tất niên xu hướng mới nhất Trang trí sinh nhật bé trai Hải Đăng Trang trí sinh nhật bé Khánh Vân Trang trí sinh nhật Bích Ngân Trang trí sinh nhật bé Thanh Trang Thuê ông già Noel phát quà Biểu diễn xiếc khỉ Xiếc quay đĩa
Thiết kế website Thiết kế website Thiết kế website Cách kháng tài khoản quảng cáo Mua bán Fanpage Facebook Dịch vụ SEO Tổ chức sinh nhật