Viac

ArcPy prázdny tvar?


Mám malý skript na vyhľadávanie v triede funkcií a skopírovaní celého riadka do inej triedy funkcií. Funguje to dobre, pretože získavam všetky atribúty pre riadok, ale pre vrstvu neexistuje žiadna geometria a nezobrazujú sa žiadne tvary. Je to vrstva POLYLINE a všetky moje tvarové dĺžky = 0

importovať arcpy z arcpy import env arcpy.env.overwriteOutput = True env.workspace = r "C:  temp  gamma  Gamma_Survey_With_Lines.gdb" Detector_Line = env.workspace + "/Detector_Line" GammaDetectionLocation = env.workspace +/ arcpy.MakeFeatureLayer_management (GammaDetectionLocation, "GammaDetectionLocation1") # lyr2Explode = arcpy.CreateFeatureclass_management ( "in_memory", "CopyOfGammaDetectionLocation", "polyline", GammaDetectionLocation, "VYRADENY", "VYPNUTÉ", GammaDetectionLocation) lyr2Explode = arcpy.CreateFeatureclass_management (env.workspace , "CopyofDetectorLine", "POLYLINE", Detector_Line, "DISABLED", "DISABLED", Detector_Line) cur = arcpy.InsertCursor (lyr2Explode) field = "GlobalID" cursor = arcpy.SearchCursor (Detector_Line) for row in cursor: #print (#print) row.getValue (pole)) globalid = row.getValue (pole) arcpy.SelectLayerByAttribute_management ("GammaDetectionLocation1", "NEW_SELECTION", "SourceTrack = '" + globalid + "'") count = int (arcpy.GetCount_management ("GammaDet ectionLocation1 "). getOutput (0)) if (count == 0): print print feat = cur.newRow () feat.shape = row.Shape feat.setValue (" UserID "," doodie ") cur.insertRow (feat )

Zdá sa, že polia sú medzi týmito dvoma vrstvami identické. Skúsil by som vypísať všetky polia a pridať[email protected]token, aby ste sa uistili, že zachytíte geometriu.

Mozno nieco taketo:

#Fields list #Získajte všetky polia flds = [f.name for f in ListFields (Detector_Line)] #Add [email protected] token flds += ["[email protected]"] with arcpy.da.SearchCursor (Detector_Line, flds) as sCur: with arcpy.da.InsertCursor (lyr2Explode, flds) ako iCur: pre riadok v sCur: print (riadok [17]) globalid = riadok [17] arcpy.SelectLayerByAttribute_management ("GammaDetectionLocation1", "NEW_SELECTION", "SourceTrack = '" + glob + "'") count = int (arcpy.GetCount_management ("GammaDetectionLocation1"). getOutput (0)) if (count == 0): počet výtlačkov iCur.insertRow (riadok)

ak máte problémy s poľom OID, môžete ho upraviť takto:

oidFld = arcpy.Describe (Detector_Line) .OIDFieldName flds = [f.name for f in ListFields (Detector_Line) if f.name! = oidFld]…


Pozri si video: Python in ArcGIS. Основы arcpy. Новый сезон (Septembra 2021).