رد: لماذا خيار field calculator غير مفعل عندما اضيف جدول اكسيل
وهذا شرح اخر :
HowTo: Convert a file with coordinates in Degrees, Minutes and Seconds to a shapefile using ArcMap
Article ID: 27548
Software: ArcGIS - ArcEditor 8.1, 8.1.2, 8.2, 8.3, 9.0, 9.1, 9.2, 9.3, 9.3.1 ArcGIS - ArcInfo 8.0.1, 8.0.2, 8.1, 8.1.2, 8.2, 8.3, 9.0, 9.1, 9.2, 9.3, 9.3.1 ArcGIS - ArcView 8.1, 8.1.2, 8.2, 8.3, 9.0, 9.1, 9.2, 9.3, 9.3.1
Platforms: N/A
Summary
Instructions provided describe the process for converting point data in degrees, minutes and seconds (DMS) to a shapefile using ArcMap.
Procedure
Follow the steps below.
1. Format the coordinate values for ArcGIS to correctly interpret the data.
A. Coordinates in DMS from a file need to be formatted with spaces separating the degree, minute and second values, as shown in the example below:
80 37 40,35 00 48
B. For data in North America, the Longitude values must be negative. Note the example:
-80 37 40,35 00 48
C. Each column in the table must have a heading, that describes the data entered into that column of the table:
Longitude,Latitude
-80 37 40,35 00 48
D. The table needs a field that contains a unique identifying number for each record in the table.
ID,Longitude,Latitude
1,-80 37 59,35 00 38
2. Start ArcMap with a new, empty map once the table is correctly formatted.
3. Save the script below as 'conv_DMS2DD.cal' in ArcMap with the following steps.
4. Dim sField
5.
Dim sDMS As String, sS As String, sSuf As String, sPre as string
6.
Dim sList
7.
Dim i As Integer, j As Integer
8.
Dim iDec As Integer, iNum As Integer
9.
Dim dD As Double, dM As Double, dS As Double, dDD As Double
10.
Dim bReplace As Boolean
11.
'=============================
12.
'Change the source field name bellow
13.
sField = [dms]
14.
'=============================
15.
sDMS = sField
16.
If Len(Trim(sDMS)) = 0 Then
17.
dDD = 0
18.
Else
19.
iDec = 0
20.
iNum = 0
21.
For i = 1 To Len(sDMS)
22.
sS = Mid(sDMS, i, 1)
23.
If Not IsNumeric(sS) Then
24.
If sS = "." Then
25.
If Not iDec = 0 Then
26.
bReplace = True
27.
Else
28.
bReplace = False
29.
End If
30.
iDec = iDec + 1
31.
ElseIf sS = "-" Then
32.
sPre = "-"
33.
bReplace = True
34.
Else
35.
bReplace = True
36.
End If
37.
If bReplace Then
38.
If iNum > 0 Then
39.
Mid(sDMS, i, 1) = ","
40.
Else
41.
Mid(sDMS, i, 1) = " "
42.
End If
43.
End If
44.
Else
45.
iNum = iNum + 1
46.
End If
47.
Next i
48.
sList = Split(sDMS, ",")
49.
Dim iLen As Integer
50.
If UBound(sList) = 0 Then
51.
sDMS = sList(0)
52.
iLen = Len(sDMS)
53.
If iLen >= 4 Then
54.
dS = CDbl(Mid(sDMS, iLen - 1, 2))
55.
dM = CDbl(Mid(sDMS, iLen - 3, 2))
56.
sDMS = Left(sDMS, (iLen - 4))
57.
If (Len(sDMS) > 2) Then
58.
dD = CDbl(Right(sDMS, 3))
59.
ElseIf (Len(sDMS) = 0) Then
60.
dD = 0#
61.
Else
62.
dD = CDbl(sDMS)
63.
End If
64.
Else
65.
dDD = 0
66.
End If
67.
dDD = dD + dM / 60# + dS / 3600#
68.
Else
69.
j = 0
70.
dD = 0#
71.
dM = 0#
72.
dS = 0#
73.
For i = 0 To UBound(sList)
74.
If IsNumeric(sList(i)) Then
75.
If j = 0 Then
76.
dD = CDbl(sList(i))
77.
j = j + 1
78.
ElseIf j = 1 Then
79.
dM = CDbl(sList(i))
80.
j = j + 1
81.
ElseIf j = 2 Then
82.
dS = CDbl(sList(i))
83.
j = j + 1
84.
End If
85.
End If
86.
Next i
87.
dDD = dD + dM / 60# + dS / 3600#
88.
End If
89.
If dDD < -180# Or dDD > 180# Then
90.
dDD = 0#
91.
End If
92.
If sPre = "-" Then
93.
dDD = dDD * -1#
94.
End If
End If
A. Open a table in ArcMap.
B. Right-click a field and select Calculate Values.
C. Check the Advanced check box.
D. Copy the code above into the Pre-Logic VBA Script Code section of the field calculator.
E. Type dDD into the bottom section of the Field Calculator.
F. Click Save to save the script to a .cal file and name the file 'conv_DMS2DD.cal'.
95. Follow these steps to run the code above in the Field Calculator:
A. Add the table containing the DMS coordinates to ArcMap through the Add Data button.
B. Right-click on the table name > Data > Export and export the table to a DBF file.
C. Open the DBF table and add items named 'longDD' and 'latDD' to the table, defining these as Double, Precision 18, and Scale 13.
D. Calculate the field values for 'longDD' and 'latDD' by starting a load of the conv_DMS2DD.cal script to the field calculator.
Change the name of the field in the script to that of the original DMS fields:
'Change the source field name below
sField = [Long]
96. Right-click the DBF table and select Display XY Data after the coordinates have been converted from DMS to DD.
Define the projection for the event layer by clicking the Edit button in the 'Spatial Reference of Input Coordinates' section of the dialog box.
Defining the projection permits the data to display in the correct location in ArcMap as an Event layer.
97. Convert the Event layer to a shapefile.
A. Right-click the Event layer and select Data > Export data.
B. Select the output location for the shapefile and type in the name.
C. Click Save and OK on the Export Data dialog box to create the shapefile.
صلى الله عليك ياسيدي يارسول الله فصلوا عليه