HOW TO
To overlay Decimal Degree data with Decimal Second data, i.e. ESRI sample data stored in Decimal Degrees and USGS DEM stored in Decimal Seconds, you must convert one of the theme's map units to be the same as the other.
Run the following script on the vector data. It will create a new shapefile theme, converting the decimal degree points/vertices into decimal seconds. All input attribute tables are copied over into the new shapefile.
Code:
'----------------------------------------
'Name: DD2DS.AVE
'
'Title: Converts DD vector theme into DS shapefile theme.
'
'Description: Converts an unprojected vector theme from the
'Decimal Degrees coordinate system into the Decimal Seconds
'coordinate system. Only the selected features will be moved.
'If there are no selected features then all features in the
'theme will be moved. This is accomplished by reading
'every point or every shape vertex, multiplying it by
'3600, and populating a new shapefile FTab. All of the fields
'from the input vector theme are copied over into the new
'shapefile theme.
'
'Requires: A View with one active vector
'Theme. It will work on point, polyline, or polygon themes.
'It will not work on annotation themes or multi-point themes.
'-----------------------------------------
theView = av.GetActiveDoc
theTheme = theView.GetActiveThemes.Get(0)
' Specify the output shapefile...
'
defaultName = FN.Make("$HOME").MakeTmp("theme","shp")
shpFileName = FileDialog.Put( defaultName,"*.shp","Output Shape File" )
if (shpFileName = Nil) then
exit
end
' Ensure a .shp extension...
shpFileName.SetExtension("shp")
' Create the appropriate kind of FTab...
'
shapeType = theTheme.GetFtab.FindField("Shape").GetType
if (shapeType = #FIELD_SHAPELINE) then
outFTab = FTab.MakeNew(shpFileName, Polyline)
elseif (shapeType=#FIELD_SHAPEMULTIPOINT) then
MsgBox.Info("Cannot process multipoint shapes","Stop")
return nil
elseif (shapeType = #FIELD_SHAPEPOINT) then
outFTab = FTab.MakeNew(shpFileName, Point)
elseif (shapeType = #FIELD_SHAPEPOLY) then
outFTab = FTab.MakeNew(shpFileName, Polygon)
end
inShapeField = theTheme.GetFtab.FindField("Shape")
outShapeField = outFTab.FindField("Shape")
' Clone the fields in the inFTab for inclusion in the outFTab...
'
inFTab = theTheme.GetFTab
inFieldList = inFTab.GetFields
outFieldList = inFieldList.DeepClone
outFieldList.Remove(0) ' omit the shape field...
outFTab.AddFields(outFieldList)
' If there are no selected features, apply conversion to all,
' otherwise just apply the conversion to the selected features...
'
if (inFTab.GetSelection.Count = 0) then
theRecordsToShift = inFTab
numRecs = inFTab.GetNumRecords
else
theRecordsToShift = inFTab.GetSelection
numRecs = theRecordsToShift.Count
end
av.ShowMsg("Converting...")
counter = 0
for each rec in theRecordsToShift
counter = counter + 1
av.SetStatus((counter/numrecs) * 100)
theShape = theTheme.GetFtab.ReturnValue(inShapeField, rec)
if (shapeType = #FIELD_SHAPEPOINT) then
theShape.SetX(theShape.GetX * 3600)
theShape.SetY(theShape.GetY * 3600)
newShape = theShape
end
if ((shapeType = #FIELD_SHAPEPOLY) or (shapeType = #FIELD_SHAPELINE)) then
lolop = {}
for each shppart in theShape.AsList
lop = {}
for each vtx in shppart
newX = (vtx.GetX * 3600)
newY = (vtx.GetY * 3600)
lop.Add(Point.Make(newX,newY))
end
lolop.Add(lop)
end
if (shapeType = #FIELD_SHAPEPOLY) then
newShape = Polygon.Make(lolop)
end
if (shapeType = #FIELD_SHAPELINE) then
newShape = Polyline.Make(lolop)
end
end
newRec = outFtab.AddRecord
outFTab.SetValue(outShapeField, newRec, newShape)
' Copy the rest of the attributes for this record. The inFieldList
' and outFieldList are offset by 1 since the inFieldList includes
' the shape field, the outFieldList does not. The lists are used
' to traverse the fields since field name properties may change when
' the .dbf file is created, i.e. FNODE# may become FNODE_, etc...
'
fieldPtr = 0
for each fOut in outFieldList
fieldPtr = fieldPtr + 1
fIn = inFieldList.Get( fieldPtr )
outFTab.SetValue( fOut, newRec, inFTab.ReturnValue( fIn, rec ) )
end
end
outFtab.Flush
av.ClearMsg
av.ClearStatus
' Allow the user to add the new shapefile as a theme to a View of choice.
'
if (MsgBox.YesNo("Add shapefile as theme to a view?", "DD 2 DS", true).Not) then
exit
end
' Create a list of views and allow the user to choose which view to
' add the new theme to...
viewList = {}
for each d in av.GetProject.GetDocs
if (d.Is(View)) then
viewList.Add( d )
end
end
' Include a choice for a new view...
viewList.Add("<New View>")
addToView = MsgBox.ListAsString( viewList,"Add Theme to:", "DD to DS" )
' Get the specified view, make the theme, and add it...
if (addToView <> nil) then
if (addToView = "<New View>") then
addToView = View.Make
addToView.GetWin.Open
end
shiftedTheme = FTheme.Make( outFTab )
addToView.AddTheme( shiftedTheme )
' Bring the View to the front...
addToView.GetWin.Activate
end
'
'END OF SCRIPT: DD2DS.AVE
Article ID:000002344
Get help from ArcGIS experts
Download the Esri Support App