-
رد : أبحث عن طريقة آلية لتحويل مجموعة لجداول إلى راستر
بسم الله الرحمن الرحيم
تحياتي أخ محمد
من خلال VBA يمكنك تنفيذ أي سلسلة من الأوامر مهما بلغت من التعقيد
من ملفات الـ Help وجدت الأكواد التالية
كود لإنشاء شيب فايل جديد
Public Function CreateShapefile(sPath As String, sName As String) As IFeatureClass ' Dont include .shp extension
' Open the folder to contain the shapefile as a workspace
Dim pFWS As IFeatureWorkspace
Dim pWorkspaceFactory As IWorkspaceFactory
Set pWorkspaceFactory = New ShapefileWorkspaceFactory
Set pFWS = pWorkspaceFactory.OpenFromFile(sPath, 0)
' Set up a simple fields collection
Dim pFields As IFields
Dim pFieldsEdit As IFieldsEdit
Set pFields = New Fields
Set pFieldsEdit = pFields
Dim pField As IField
Dim pFieldEdit As IFieldEdit
' Make the shape field
' it will need a geometry definition, with a spatial reference
Set pField = New Field
Set pFieldEdit = pField
pFieldEdit.Name = "Shape"
pFieldEdit.Type = esriFieldTypeGeometry
Dim pGeomDef As IGeometryDef
Dim pGeomDefEdit As IGeometryDefEdit
Set pGeomDef = New GeometryDef
Set pGeomDefEdit = pGeomDef
With pGeomDefEdit
.GeometryType = esriGeometryPolygon
Set .SpatialReference = New UnknownCoordinateSystem
End With
Set pFieldEdit.GeometryDef = pGeomDef
pFieldsEdit.AddField pField
' Add another miscellaneous text field
Set pField = New Field
Set pFieldEdit = pField
With pFieldEdit
.Length = 30
.Name = "MiscText"
.Type = esriFieldTypeString
End With
pFieldsEdit.AddField pField
' Create the shapefile
' (some parameters apply to geodatabase options and can be defaulted as Nothing)
Dim pFeatClass As IFeatureClass
Set pFeatClass = pFWS.CreateFeatureClass(sName, pFields, Nothing, _
Nothing, esriFTSimple, "Shape", "")
Set CreateShapefile = pFeatClass
End Function
كود لإضافة شيب فايل إلى المشروع
Public Sub AddLayerFileToMap()
Dim filePath As String
filePath = "D:\arcgis\arcexe83\ArcObjects Developer Kit\samples\data\USA\states.lyr"
Dim pGxLayer As IGxLayer
Dim pGxFile As IGxFile
Set pGxLayer = New GxLayer
Set pGxFile = pGxLayer
pGxFile.Path = filePath
Dim pMxDoc As IMxDocument
Set pMxDoc = ThisDocument
pMxDoc.FocusMap.AddLayer pGxLayer.Layer
End Sub
وبالتالي يمكن تحويل أي عملية تقوم بها يدوياً ضمن ArcMap أو ArcCataloge إلى كود برمجي تنفذه بكبسة زر
من خلال تعديل الكود السابق ودمجه يمكن مثلاً إنشاء أي عدد تريد من الـ shapefiles وإضافتها إلى Arcmap بشكل آلي
والآن أنا أبحث عن الكود المقابل لأمر Add XY data
وكود لتحويل إلى راستر
وهكذا
ضوابط المشاركة
- لا تستطيع إضافة مواضيع جديدة
- لا تستطيع الرد على المواضيع
- لا تستطيع إرفاق ملفات
- لا تستطيع تعديل مشاركاتك
-
قوانين المنتدى