Load Layer di ArcGIS

1 July 2009

Ini adalah contoh Script VBA di ArcMap, gunanya adalah untuk load shapefile ke Dataframe.

Private Sub LoadMap()

‘definisikan Workspacefactory sebagai sumber data, dalam hal ini adalah shapefile
Dim pWorkspaceFactory As IWorkspaceFactory
Set pWorkspaceFactory = New ShapefileWorkspaceFactory

‘definisikan lokasi feature, bisa diganti sesuai lokasi shapefile
Dim pWorkspace As IFeatureWorkspace
‘Ganti drive dan folder tempat file shp anda
Set pWorkspace = pWorkspaceFactory.OpenFromFile(”c:\map”, 0)

‘definisikan tempat load mapnya, dalam hal ini map akan di-load ke active document
‘yaitu gis.mxd yang sedang dibuka.
Dim pMxDoc As IMxDocument
Set pMxDoc = ThisDocument

‘definisikan Geographic View
Dim pActiveView As IActiveView

‘definisikan feature dan buka
Dim pClass As IFeatureClass

‘buka parcels.shp
Set pClass = pWorkspace.OpenFeatureClass(”parcels”)

‘jadikan feature yang dibuka di atas sebagai layer baru
Dim pLayer As IFeatureLayer
Set pLayer = New FeatureLayer
Set pLayer.FeatureClass = pClass
pLayer.Name = pClass.AliasName

‘tambahkan layer ke document
pMxDoc.AddLayer pLayer

‘refresh geographic view
pMxDoc.ActiveView.Refresh

End Sub

Komentar »

URL ke posting ini: http://gis.blogsome.com/2009/07/01/load-layer-di-arcgis/trackback/

Belum ada komentar.

RSS feed komentar di posting ini.

Kirim Komentar

baris dan paragraph otomatis turun, e-mail tidak akan ditampilkan, HTML yang diijinkan: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <code> <em> <i> <strike> <strong>



Anti-spam measure: please retype the above text into the box provided.


Anti-spam measure: please retype the above text into the box provided.

Get free blog up and running in minutes with Blogsome | Theme designs available here