0% found this document useful (0 votes)
26 views2 pages

Visual Basic Program - Now It Is Working

This Visual Basic program: 1. Reads coordinate data from a file and converts longitude and latitude coordinates to UTM coordinates. 2. Allows the user to input longitude and latitude values which are then converted to UTM coordinates and displayed. 3. Determines land cover class values from 1 to 18 at given coordinates by reading values from a raster file and displays the class name.

Uploaded by

Elego13th
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
26 views2 pages

Visual Basic Program - Now It Is Working

This Visual Basic program: 1. Reads coordinate data from a file and converts longitude and latitude coordinates to UTM coordinates. 2. Allows the user to input longitude and latitude values which are then converted to UTM coordinates and displayed. 3. Determines land cover class values from 1 to 18 at given coordinates by reading values from a raster file and displays the class name.

Uploaded by

Elego13th
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 2

Visual Basic Program

- Now it is working

' BENGHAZI_clut_1_1 964170.0 1009590.0 3539550.0 3584030.0 10.0


Dim XU
Dim YU
Const A = 6378137
Const B = 6356752.3142
'Const f = 3.35281066474748E-03
'Const f1 = 298.257223563
Const Pi = 3.14159265358979

Private Sub CmdRead_Click()


Open "C:\Benghazi Digital Map\Clutter Classes\BENGHAZI_clut_1_1" For Binary As #1
Xaxis = (((CDbl(XTex.Text) - CDbl(XminTex.Text))) / CDbl(ResolutionTex.Text))
Yaxis = (((CDbl(YmaxTex.Text) - CDbl(YTex.Text))) / CDbl(ResolutionTex.Text))
NBcol = (CDbl(XmaxTex.Text) - CDbl(XminTex.Text)) / CDbl(ResolutionTex.Text)

Pos = 2 * Round(Xaxis + (Yaxis) * (NBcol))

PosTex.Text = Pos
If Pos > 0 Then
Dim Pa As Byte
Dim Pb As Byte
Get #1, Pos, Pa
Get #1, Pos + 1, Pb
result = Pa + Pb
Label1.Caption = result
' From Menu file
'1 sea
'2 inland water
'3 wetland
'4 barren
'5 grass/agriculture
'6 rangeland
'7 woodland
'8 forest
'9 village
'10 suburban
'11 dense suburban
'12 urban
'13 dense urban
'14 core urban
'15 building blocks
'16 industrial
'17 airport
'18 open in urban

If Val(result) = 1 Then LaResult.Caption = "Sea"


If Val(result) = 2 Then LaResult.Caption = "Inland water"
If Val(result) = 3 Then LaResult.Caption = "Wetlan"
If Val(result) = 4 Then LaResult.Caption = "Barren"
If Val(result) = 5 Then LaResult.Caption = "Grass/Agriculture"
If Val(result) = 6 Then LaResult.Caption = "Rangeland"
If Val(result) = 7 Then LaResult.Caption = "Woodland"
If Val(result) = 8 Then LaResult.Caption = "Forest"
If Val(result) = 9 Then LaResult.Caption = "Village"
If Val(result) = 10 Then LaResult.Caption = "Suburban"
If Val(result) = 11 Then LaResult.Caption = "Dense-Suburban"
If Val(result) = 12 Then LaResult.Caption = "Urban"
If Val(result) = 13 Then LaResult.Caption = "Dense-Urban"
If Val(result) = 14 Then LaResult.Caption = "Core-Urban"
If Val(result) = 15 Then LaResult.Caption = "Building-Blocks"
If Val(result) = 16 Then LaResult.Caption = "Industrial"
If Val(result) = 17 Then LaResult.Caption = "Airport"
If Val(result) = 18 Then LaResult.Caption = "Open in urban"

Else
LaResult.Caption = "Out of Range"
End If
Close #1
End Sub

Private Sub CmdConvert_Click()


LonLat2UTM CDbl(LoTex.Text), CDbl(LaTex.Text), CDbl(CoUTM)
XTex.Text = Int((Round(XU, 0) - XminTex.Text) / 10) * 10 + XminTex.Text
YTex.Text = Int((Round(YU, 0) - YminTex.Text) / 10) * 10 + YminTex.Text
End Sub

Public Sub LonLat2UTM(Longitude As Double, Latitude As Double, Zone As Double)


XU = 0
DR = Pi / 180
RD = 180 / Pi
f = (A - B) / A
f1 = 1 / f
rm = (A * B) ^ (0.5)
k0 = 0.9996
e = (1 - (B / A) ^ 2) ^ 0.5
ee = (e ^ 2) / (1 - e ^ 2)
N = A / ((1 - e * e * (Sin(Latitude * Pi / 180) ^ 2)) ^ 0.5)
T = (Tan(Latitude * Pi / 180)) ^ 2
C0 = ee * (Cos(Latitude * Pi / 180)) ^ 2
zcm = 6 * Zone - 183
dL = (Longitude - zcm) * Pi / 180
A0 = dL * Cos(Latitude * Pi / 180)
M = A * ((1 - (e * e / 4) - 3 * e ^ 4 / 64 - 5 * e ^ 6 / 256) * (Latitude * Pi / 180) - (3 * e * e / 8 + 3 * e ^ 4 / 32 + 45 * e ^ 6 / 1024) * Sin(2
* Latitude * Pi / 180) + (15 * e ^ 4 / 256 + 45 * e ^ 6 / 1024) * Sin(4 * Latitude * Pi / 180) - (35 * e ^ 6 / 3072) * Sin(6 * Latitude * Pi /
180))
XU = k0 * N * (A0 + (1 - T + C0) * A0 ^ 3 / 6 + (5 - 18 * T + T * T + 72 * C0 - 58 * ee) * A0 ^ 5 / 120)
YU = k0 * (M + N * Tan(Latitude * Pi / 180) * (A0 * A0 / 2 + (5 - T + 9 * C0 + 4 * C0 * C0) * A0 ^ 4 / 24 + (61 - 148 * T + 16 * T * T) * A0
^ 6 / 720))
k = k0 * (1 + (1 + C0) * A0 * A0 / 2 + (5 - 4 * T + 42 * C0 + 13 * C0 * C0 - 28 * ee) * A0 ^ 4 / 24 + (61 - 148 * T + 16 * T * T) * A0 ^ 6 /
720)
XU = 500000 + XU
End Sub

You might also like