Você está na página 1de 6

TUTORIAL PARA CORREO DE ORIENTAO DE FLUXO DE

DRENAGEM NO SOFTWARE ARCGIS


Eng. Amb. Samuel Barsanelli Costa
http://lattes.cnpq.br/5485659465772353
1 INPUTS
a) Curvas de nvel
b) Pontos cotados
c) Hidrografia
2 PROCEDIMENTO
a) Produzir um modelo digital do terreno (expedito) da rea de interesse.
Recomenda-se utilizar o mtodo da Triangulao com Interpolao
Linear (3D Analyst Create/Modify TIN Create TIN from features), a
partir das curvas de nvel e pontos cotados, atribuindo Triangulate as
mass points para ambas;
b) Converter a rede de drenagem para um Feature 3D (3D Analyst
Convert Features to 3D). Utilizar a hidrografia original como input e o
resultado do item (a) como Raster or TIN surface;
c) Abrir o Visual Basic Editor (Tools Macros Visual Basic Editor), clicar
no item Project com o boto direito, Insert Module, e colar a linha de
comando abaixo na tela de edio (no colar os caracteres especiais
<<< e >>>). Caso deseje disponibilizar a macro em todos os projetos do
ArcGIS, crie o mdulo no item Normal ao invs do Project:
<<<
Option Explicit

Sub Line_flip()

'This macro was compiled by Sudarshan Karki
'with ideas borrowed from many other scripts
'in the ESRI site. (Sudarshan.Karki@nrw.qld.gov.au)

'Set an error handler method
On Error GoTo ErrorHandler

'Declare variables
Dim pMxDocument As IMxDocument
Dim pFeatureLayer As IFeatureLayer
Dim pFeatureClass As IFeatureClass
Dim pFeatureSelection As IFeatureSelection
Dim pGeometry As IGeometry
Dim pPolyline As IPolyline

'Set variables
Set pMxDocument = ThisDocument
Set pFeatureSelection = pMxDocument.SelectedLayer
Set pFeatureLayer = pFeatureSelection
Set pFeatureClass = pFeatureLayer.FeatureClass

'Check if any layer is selected or not
If pFeatureLayer Is Nothing Then
MsgBox "Please select a layer", vbInformation, "Layer not selected"
GoTo ErrorHandler
End If

'Define variable to position cursor
Dim pFeatureCursor As IFeatureCursor
Dim pFeature As IFeature
Set pFeatureCursor = pFeatureClass.Search(Nothing, False)
Set pFeature = pFeatureCursor.NextFeature

'Check if the required geometry type with Z values is selected
Dim pIZAware As IZAware
Set pIZAware = pFeature.Shape

If pFeatureClass.ShapeType <> esriGeometryPolyline Then
If Not pIZAware.ZAware Then
MsgBox "Please select a Polyline shapefile with Z values",
vbExclamation, "Required PointZ"
GoTo ErrorHandler
End If
End If

'Define variables for progress bar
Dim lNumberofFeatures As Long
Dim dInterval As Double
Dim pStatusBar As IStatusBar
Set pStatusBar = StatusBar
Dim pStepProgressor As IStepProgressor
Set pStepProgressor = pStatusBar.ProgressBar
lNumberofFeatures = pFeatureClass.FeatureCount(Nothing)
dInterval = lNumberofFeatures / 100
Static i
i = 1
pStepProgressor.MinRange = 1
pStepProgressor.MaxRange = lNumberofFeatures
pStepProgressor.StepValue = dInterval

'Define variables to store attributes
Dim SK1 As Double
Dim SK2 As Double
Dim Count As Integer
Count = 0

'Loop through the table to compute values
'until the cursor reaches the end
While Not pFeature Is Nothing
Set pGeometry = pFeature.Shape
Set pPolyline = pGeometry

SK1 = pPolyline.FromPoint.Z
SK2 = pPolyline.ToPoint.Z

If SK2 > SK1 Then
Set pPolyline = pFeature.ShapeCopy
pPolyline.ReverseOrientation
Set pFeature.Shape = pPolyline
pMxDocument.ActiveView.Refresh
Count = Count + 1
End If

pFeature.Store

'Show status bar and message on the status bar
pStepProgressor.Position = i
pStepProgressor.Message = "Please be patient...calculating " &
Str(i) & " of " & Str(lNumberofFeatures)
pStepProgressor.Step
pStepProgressor.Show
If i < lNumberofFeatures Then
DoEvents
Else
pStepProgressor.Hide
End If

'Advance the cursor to the next row
Set pFeature = pFeatureCursor.NextFeature

i = i + 1
Wend

pStepProgressor.Hide
MsgBox "No. of Features Flipped = " & Count, vbInformation, "Features
Flipped"
ErrorHandler:
Exit Sub
End Sub
>>>
d) Fechar o Visual Basic Editor, retornar ao ArcGIS, selecionar o layer da
hidrografia 3D, resultado do item (b), e abrir o prompt de Macros (Tools
Macros Macros...). Selecionar a macro recm-criada
(Module1.Line_flip, por exemplo) e ativar Run para rodar a macro;
e) Converter a hidrografia 3D de volta para 2D. O procedimento manual o
seguinte:
- Abrir o ArcToolbox e selecionar Data Management Tools - Feature
Class - Create Feature Class;
- Em Geometry Type, selecionar Polyline;
- Em Template Feature Class, selecionar a hidrografia 3D;
- Deixar os campos Has Z e Has M em Disabled;
- Em Spatial Reference, importar a referncia da hidrografia 3D;
- Selecione Ok para criar o Shapefile;
- Inicie a edio do arquivo recm criado;
- Selecione todos os vetores da hidrografia 3D (Boto direito no layer,
Selection - Select All) e copie para a rea de transferncia (Edit
Copy);
- Na guia Editor, habilite o arquivo recm-criado como Target e cole
os vetores (Edit Paste);
- Salve a edio.
f) O resultado do item (e) o Shapefile da hidrografia com a orientao de
fluxo corrigida.