Ko'proq

ArcPIS skriptidan ArcGIS serverida saqlanib qolmaydigan o'zgarishlar bormi?

ArcPIS skriptidan ArcGIS serverida saqlanib qolmaydigan o'zgarishlar bormi?


Ma'lumotlar bazasi ulanish katalogidagi .sde ulanish fayli orqali ArcGIS serveriga (10.0) versiyalangan geodatabase bilan bog'langan ArcPy skriptiga (10.2) Microsoft SQL-serveriga to'g'ridan-to'g'ri ulanish orqali ega bo'laman.

Juda soddalashtirilgan darajadagi vosita bitta maydonni to'ldirish uchun bitta featureclassni updatecursor bilan yangilaydi va ma'lumotlarni birinchi xususiyatli sinfdan hosil qilingan buferlarni o'z ichiga olgan mahalliy FGDB-dan boshqa xususiyatli sinfga qo'shadi. Shuningdek, u ba'zi bir qatorlarni o'chirish uchun ikkinchi darajali sinfda yangilash kursorini ishlaydi. Ushbu xususiyatli sinflarda tahrirlovchini kuzatish imkoniyati mavjud. Skript standart asboblar qutisiga biriktirilgan (* .tbx).

Mahalliy FGDB-da hamma narsa yaxshi ishlaydi. Serverga ulanishni o'zgartirganda va asbobni ishga tushirganimda, barcha o'zgarishlar atributlar jadvalida kutilganidek ko'rinadi - ammo ArcMap sessiyasini yopib, qayta ochganimdan so'ng, o'zgarishlar saqlanib qolmaganga o'xshaydi. Yangilash kursorining funktsiyalari ham, qo'shimchalari ham ishlamagan ko'rinadi. Men tahrirlash sessiyasiga yoki shunga o'xshash narsalarga kirmayman.

Python oynasida qo'shimchalar boshqaruvini bir xil parametrlarga ega bo'lgan holda qo'lda boshqarish qiziqarli o'zgarishlarga olib keladi.

Men sinab ko'rgan ba'zi boshqa usullarni sinab ko'rdim:

    - ishlaydigan skriptni jarayon sifatida belgilash
    - .sde ulanish yo'lini os.path.join bilan qurish
    - har qanday ushlab turishni bo'shatish uchun skript oxirida env.workspace = "" o'rnatilishi
    - ilova orqali ulanish (sde)
    - sinov 10.2 server muhitida ishlash

Men etishmayotgan narsa bormi? O'zgarishlarning paydo bo'lishi va keyin boshqa sessiyani ochishda tejashning aniq sababini aniqlay olmayapman.

Quyidagi kod:

import arcpy import os import time import uuid from Datetime import datetime, timedelta from configuration import * # Python dictning maxsus subklassi, RES_ID xususiyatlarini sinfi NestedDict (dict) ni tayinlash uchun osonlikcha kengaytirilgan joylashish imkoniyatini yaratishga imkon beradi: def __getitem __ (self, key): if in self: return self.get (key) return self.setdefault (key, NestedDict ()) def checkResourcesUpdate (): "" "Yangi yoki yangilangan shakllarni tekshiradi. RES_ID shakllarini tanlab, qayta yaratiladigan (tamponlangan) resurslarni himoya qilish qatlami va mavjud bo'lgan resurslarni himoya qilish qatlamida o'chirilishi kerak bo'lgan RES_ID ro'yxatini to'playdi. "" "rowsResources = arcpy.UpdateCursor (resourcesLayer) rowsProtection = arcpy.UpdateCursor (resourcesProtectionLayer) resourcesProtectionDelete = [] resourcesSelectList = [] [] protectionIds = [] resourceInfo = restedResources-dagi rowResources uchun NestedDict (): if rowResources.RES_ID == "" or rowResources.RES_ID None: rowResources.RES_ID = "R" + time.strftime ("% Y% m% d ") + str (uuid.uui d4 (). get_hex (). upper () [0: 6]) rowsResources.updateRow (rowResources) arcpy.AddMessage ("Res ID identifikatori {0} yangi manbaga tayinlangan" .format (rowResources.RES_ID)) agar satrResources.PROTECT_TERM protectConfig.keys (): if rowResources.SHAPE.area == 0: arcpy.AddWarning ("O'tkazib yuborish {0}, fazoviy etishmayotgan, himoya maydoni (lar) yaratilmagan") .format (rowResources.RES_ID)) else: resourceInfo [str (rowResources.RES_ID)] ['protectTerm'] = rowResources.PROTECT_TERM resourceIds.append (rowResources.RES_ID), agar rowResources.EDITED_DATE None bo'lmasa yoki rowResources.EDITED_DATE! = "": resourceInfo [str (rowResources.R_) ['recentDate'] = rowResources.EDITED_DATE, agar rowResources.CREATED_DATE None bo'lmasa yoki rowResources.CREATED_DATE! = "": ifourceInfo [str (rowResources.RES_ID)] ['recentDate']: if rowResources.CREATED_DATE> resourceIn rowResources.RES_ID)] ['recentDate']: resourceInfo [str (rowResources.RES_ID)] ['recentDate'] = rowResources.CREATED_DATE for rowProtection in rowsProtection: if rowProtection.PROTECT _TERM in protectConfig.keys (): protectionIds.append (rowProtection.RES_ID) if resourceInfo [str (rowProtection.RES_ID)] ['recentDate']: if rowProtection.CREATED_DATE  , str (protectConfig [prot.) ectTerm] [bufferType + 'Dist']) + "Meters", sideType, "ROUND") arcpy.CalculateField_management (protectTermLayerBuffered, 'PROTECT_TYPE', "'" + bufferType.title () + "area'", 'PYTHON') arcpy.CalculateField_management (protectTermLayerBuffered, 'PROTECT_DISTANCE', protectConfig [protectTerm] [bufferType + 'Dist'], 'PYTHON') arcpy.AddMessage ("GDA94 WA Al maydonlaridan {0} {1} m {2}" buferlarni yaratish yangi yoki yangilangan manbalar ".format (protectConfig [protectTerm] ['protectTerm'], protectConfig [protectTerm] [bufferType + 'Dist'], bufferType)) def appendBuffers (): arcpy.env.workspace = processingDir featureDatasets = arcpy.ListDatasets () arcpy.AddMessage ("Yangi ajratish maydoni va bildirishnoma sohasidagi buferlarni birlashtirish ..."). DataSet-dagi dataSet uchun: agar dataSet == 'notification_buffer' yoki dataSet == 'separation_buffer': arcpy.ListFeatureClasses ("*", "uchun ALL ", str (dataSet)): appendAll (str (dataSet) +"  "+ featureClass) # arcpy.env.workspace = resourceDataLocation def appendAll (mergeFeature): arcpy.env.workspace = processingDir mergeFeature = ProcessDir + "" + mergeFeature arcpy.AddWarning ("Birlashtirish {0}". format (mergeFeature)) arcpy.Append_management (mergeFeature, protectionTemplate, "NO_TEST") def cleanProcessingData () arcpy.env.workspace = ProcessingDir featureDatasets = arcpy.ListDatasets () arcpy.AddMessage ("Vaqtinchalik ishlov berish ma'lumotlarini avvalgi bajarilishdan olib tashlash ...") dataSet in featureDatasets: processFeature in arcpy.ListFeatureClasses ("*", "ALL", dataSet ): arcpy.Delete_management (processFeature) arcpy.AddWarning ("O'chirilgan {0}". format (processFeature)) arcpy.Delete_management (selectOutLayer) arcpy.Delete_management (selectOutLayerAlbers) arcpy.Delete_manage_Temptions (himoya) AddMessage ("Oldingi ishlov berish ma'lumotlari muvaffaqiyatli o'chirildi") # arcpy.env.workspace = resourceDataLocation def pushUpdates (): arcpy.env.workspace = "" arcpy.AddMessage ("GDA94 kenglik / uzunlik bo'yicha loyihalash ...") arcpy.P roject_management (protectionTemplate, protectionTemplateDegrees, градусProjFile) arcpy.AddMessage ("SDIDIVga yangi himoya zonalarini qo'shish ...") arcpy.AddWarning ("Appending: {0}, {1}". format (protectionTemplateDegrees, resourcesProtectionLayer)). Append_management (protectionTemplateDegrees, resourcesProtectionLayer, "NO_TEST") def protectConfigDisplay (d, indent = 0): arcpy.AddWarning ("{0}". Format ("*" * 45)) uchun kalit, qiymat d.iteritems (): if key! = 'protectTerm': arcpy.AddWarning ("{0}". format (str (key) .replace ("Dist", "distance:"))) if isinstance (value, dict): protectConfigDisplay (value, indent + 1) else: arcpy.AddWarning ("{0} {1} metr" .format (" t" * 5, str (value))) arcpy.AddWarning ("{0}". format ("*") * 45)) def main (): arcpy.env.workspace = ProcessingDir initMsg = " n  n {0}  n {1} Landuse geoscience - jarayonlarni himoya qilish joylari  n {0}". Format ('*' * 90, time.asctime ()) arcpy.AddMessage (initMsg) arcpy.AddMessage ("ArcGIS {3} versiya {0}, qurish {1} (o'rnatilgan {2})". Format (arcpy.GetInstallInfo () ["Version "], arcpy.GetInstallInfo () ["BuildNumber"], arcpy.GetInstallInfo () ["InstallDate"], arcpy.GetInstallInfo () ["ProductName"])) arcpy.AddMessage (" nKuyidagi konfiguratsiyani yuklash (konfiguratsiyani o'zgartirish mumkin). py)… ") protectConfigDisplay (protectConfig) cleanProcessingData () checkResourcesUpdate () pushUpdates () if __name__ ==" __main__ ": main () arcpy.AddMessage (" Muvaffaqiyatli yakunlandi ")

Va konfiguratsiya fayli:

protectConfig = {'blast1': {'protectTerm': 'blast1', 'separationDist': '1000', 'notificationDist': '2000'}, 'blast2': {'protectTerm': 'blast2', 'separationDist': '1200', 'notificationDist': '1200'}, 'noblast1': {'protectTerm': 'noblast1', 'separationDist': '500', 'notificationDist': '500'}, 'noblast2': {'protectTerm ':' noblast2 ',' separationDist ':' 500 ',' notificationDist ':' 1000 '},' noblast3 ': {' protectTerm ':' noblast3 ',' separationDist ':' 500 '}} # SDIDIV LUG xususiyatlar to'plami arcpy.env.overwriteOutput = 1 currentDir = os.path.dirname (os.path.abspath (__ file__)) processingDir = currentDir + r " Processing_data.gdb" protectionTemplate = processingDir + r " LUG_resources_protection_template" protectionTemplateDegrees = "# Ma'lumotlarni qayta ishlash albersProjFile = currentDir + r"  projeksiyonlar  wa_alb94.prj "градусProjFile = currentDir + r"  projeksiyonlar  gda94.prj "selectOutLayerAlbers = processingDir + r"  select_resources_processing "selectOut Layer = ProcessDir + r " select_resources" # SDIDIV LUG xususiyat sinflari resourcesProtectionLayer = r "Ma'lumotlar bazasi ulanishlari  SDIDIV_DEV.sde  SDIDIV.GSD.LUG  SDIDIV.GSD.LUG_resources_protection" resourcesLayer = r "Database Connections  SDIDIV_EV GSD.LUG  SDIDIV.GSD.LUG_resources "

Mashg'ulotlarni tahrir qilishni talab qiladigan holatlar:

  • Topologiyada qatnashadigan badiiy darslar
  • Geometrik tarmoqda qatnashadigan badiiy darslar
  • ArcSDE geodatabases-da ma'lumotlar to'plamlari
  • Sinf kengaytmalari bo'lgan ba'zi bir ob'ekt va xususiyatlar sinflari

Men tahrirlash sessiyasini boshlashingiz va qo'shimchani bajarishdan oldin tahrirlarni saqlashingiz kerakligini aytmoqchiman.

Tahrirlovchilar sinfi tahrirlash seanslari va ma'lumotlar bazasi operatsiyalarini boshqarish operatsiyalaridan foydalanishga imkon beradi. O'zgarishlar saqlanib qolguncha vaqtinchalik bo'lib, ma'lumotlaringizga doimiy tatbiq etiladi. O'zgarishlaringizni saqlamasdan, tahrirlash sessiyasidan chiqishingiz mumkin.

Ushbu misoldan kodni o'zgartiring va u ishlayotganligini tekshiring:

edit = arcpy.da.Editor (ish maydoni) edit.startEditing (False, True) edit.startOperation () #update kursor edit.stopOperation () edit.stopEditing (True)

Videoni tomosha qiling: GIS Python: Count shape files and Select by Location 2 Real world ArcPy examples