' This script is used for converting a polygon shapefile with ' units in seconds to a new file with units in degrees. ' It was written by Timothy S. Thomas. ' Editing began on 8/19/99, and was last edited on 8/19/99. ' Much of the script was borrowed from View.AddGenerate, written ' by Ron Wardenier (warden@cistron.nl and http://warden.www. ' cistron.nl/geo/) and View.ShapeToGenerate, written by ESRI ' ********************************************************** ' Set up basic variables ' ********************************************************** theProject = av.GetProject theDir = "c:/tim/bahia/arc view/".AsFileName ' Sets the working directory for the project theProject.SetWorkDir(theDir) theView = av.GetActiveDoc theThemeList = theView.GetActiveThemes theTheme = theThemeList.Get(0) oldFTab = theTheme.GetFTab oldFieldList = oldFTab.GetFields.Clone shapeField = oldFTab.FindField("Shape") numRecs = oldFTab.GetNumRecords newFieldList = List.Make for each i in oldFTab.GetFields newField = i.Clone newFieldList.Add(newField) end numFields = newFieldList.Count ' Removes the shape field. This is automatically created when ' a new FTab is created. newFieldList.Remove(0) ' The MakeTmp command writes new file names with numbers at the ' end of the prefix, based on what is in the directory already. ' That is, this will make decdegr1.shp, unless that file already ' exists, in which case it will make decdegr2.shp, or 3, etc., ' using the first higher number that is vacant. theNewFN = theDir.MakeTmp("decdegr","shp") newFTab = FTab.MakeNew(theNewFN,Polygon) newFTab.AddFields(newFieldList) shapeField = newFTab.FindField("Shape") areaField = newFieldList.Get(0) perimField = newFieldList.Get(1) ' ********************************************************** ' Make new shapefile ' ********************************************************** ' Shows message in message bar av.ShowMsg("Make new shapefile") av.ShowStopButton for each oldrec in oldFTab oldPoly = oldFTab.ReturnValue(shapeField,oldrec) oldPointListofLists = oldPoly.AsList oldPointList = oldPointListofLists.Get(0) newPointList = List.Make for each i in oldPointList newPointList.Add((i.GetX/3600)@(i.GetY/3600)) end newPoly = Polygon.Make({newPointList}) newrec = newFTab.AddRecord newFTab.SetValue(shapeField,newrec,newPoly) newFTab.SetValue(areaField,newrec,newPoly.ReturnArea) newFTab.SetValue(perimField,newrec,newPoly.ReturnLength) if (numFields > 3) then for each i in 3..(numFields-1) newFTab.SetValue(newFieldList.Get(i-1),newrec, oldFTab.ReturnValue(oldFieldList.Get(i),oldrec)) end end av.SetStatus(100*(oldrec+1)/numRecs) end ' Clears message in message bar av.ClearMsg newFTab.Flush ' ********************************************************** ' Open theme into new view ' ********************************************************** decimalDegreeView = View.Make newThemeName = SrcName.Make(theNewFN.AsString) newTheme = Theme.Make(newThemeName) newTheme.SetName(theTheme.GetName ++ "in Degrees") decimalDegreeView.AddTheme(newTheme) decimalDegreeView.GetWin.Activate newTheme.SetActive(true) newTheme.SetVisible(true) theProject.SetModified(true)