[UW-GIS-L] way to get point XY locations to output?
Phil Hurvitz
phurvitz at u.washington.edu
Wed Dec 17 16:20:44 PST 2003
Avenue does it in a mere 71 lines, but it can be done interactively easily
with
Table > Start Editing
Edit > Add Field (X field)
Edit > Add Field (Y field)
Field > Calculate (the X field) with the expression ([Shape].GetX)
Field > Calculate (the Y field) with the expression ([Shape].GetY)
Table > Stop Editing (save changes)
-P.
******************************************************************************
Phil Hurvitz, MFR | GIS Specialist | College of Forest Resources | 355 Bloedel
Box 352100 | University of Washington, Seattle, Washington 98195-2100, USA
tel: 206.685.8179 | FAX: 206.685.3091 | e-mail: phurvitz at u.washington.edu
WWW: http://gis.washington.edu/phurvitz
******************************************************************************
On Wed, 17 Dec 2003, David Finlayson wrote:
> VBA = 144 lines
> AML = 5 lines
>
> AML is 28.8 times more efficient. (It probably executes faster too)
> Seems about normal for ArcGIS.
>
> Then again, how do you load a table of points and attributes into
> ArcInfo again?? ;)
>
> David
>
> Harvey Greenberg wrote:
> > Okay, you do it the hard way, but:
> > Arc: addxy mycover
> > Arc: tables
> > Tables: sel mycover.pat
> > Tables: items
> > Tables: unload myfile.txt /* or add arguments to select specific items
> >
> > harvey
> >
> > Sacha Vignieri wrote:
> >
> >> Hi,
> >> I have sample locations plotted on a map, in UTM units. My point data
> >> was originally converted from lat long, but I need to get a table of
> >> their locations in UTM coordinates. I know I can get these coordinates
> >> by using the identify pointer, however, I have 228 of them, so it will
> >> take some time to do point by point. My question is whether anyone
> >> knows of a way to get ArcGIS to output a table of all the point XY
> >> coordinates in UTM, is there a command? Has anyone had experience with
> >> this kind of process who might know of a shortcut?
> >>
> >> Thanks!
> >> Sacha Vignieri
> >> Department of Biology
> >> University of Washington
> >>
> >>
> >> _______________________________________________
> >> Uw-gis-l mailing list
> >> Uw-gis-l at u.washington.edu
> >> http://mailman.u.washington.edu/mailman/listinfo/uw-gis-l
> >
> >
> >
>
> --
> David Finlayson
> Marine Geology & Geophysics
> School of Oceanography
> Box 357940
> University of Washington
> Seattle, WA 98195-7940
> USA
>
> Office: Marine Sciences Building, Room 112
> Phone: (206) 616-9407
> Web: http://students.washington.edu/dfinlays
>
> _______________________________________________
> Uw-gis-l mailing list
> Uw-gis-l at u.washington.edu
> http://mailman.u.washington.edu/mailman/listinfo/uw-gis-l
>
-------------- next part --------------
theView = av.GetActiveDoc
'must be global to work in Calc exp below
_theProjection = theView.GetProjection
project_flag = _theProjection.IsNull.Not 'true if projected
theTheme = theView.GetActiveThemes.Get(0)
'Check if point or polygon theme
if (((theTheme.GetSrcName.GetSubName = "point") or
(theTheme.GetSrcName.GetSubName = "polygon")).Not) then
MsgBox.Info("Active theme must be polygon or point theme","")
return nil
end
'get the theme table and current edit state
theFTab = theTheme.GetFTab
theFields = theFTab.GetFields
edit_state = theFTab.IsEditable
'make sure table is editable and that fields can be added
if (theFtab.CanEdit) then
theFTab.SetEditable(true)
if ((theFTab.CanAddFields).Not) then
MsgBox.Info("Can't add fields to the table."+NL+"Check write permission.",
"Can't add X,Y coordinates")
return nil
end
else
MsgBox.Info("Can't modify the feature table."+NL+
"Check write permission.","Can't add X,Y coordinates")
return nil
end
'Check if fields named "X-coord" and Y-coord" exist
x_exists = (theFTab.FindField("X-coord") = NIL).Not
y_exists = (theFtab.FindField("Y-coord") = NIL).Not
if (x_exists or y_exists) then
if (MsgBox.YesNo("Overwrite existing fields?",
"X-coord, Y-coord fields already exist", false)) then
'if ok to overwrite, delete the fields as they may not be defined
'as required by this script (eg., created from another script).
if (x_exists) then
theFTab.RemoveFields({theFTab.FindField("X-coord")})
end
if (y_exists) then
theFTab.RemoveFields({theFTab.FindField("Y-coord")})
end
else
return nil
end 'if (MsgBox...)
end 'if
x = Field.Make ("X-coord",#FIELD_DECIMAL,18,5)
y = Field.Make ("Y-coord",#FIELD_DECIMAL,18,5)
theFTab.AddFields({x,y})
'Get point coordinates or polygon centroid coordinates
if (theTheme.GetSrcName.GetSubName = "point") then
if (project_flag) then
'Projection defined
theFTab.Calculate("[Shape].ReturnProjected(_theProjection).GetX", x)
theFTab.Calculate("[Shape].ReturnProjected(_theProjection).GetY", y)
else
'No projection defined
theFTab.Calculate("[Shape].GetX", x)
theFTab.Calculate("[Shape].GetY", y)
end 'if
else 'polygon case
if (project_flag) then
theFTab.Calculate("[Shape].ReturnCenter.ReturnProjected(_theProjection).GetX", x)
theFTab.Calculate("[Shape].ReturnCenter.ReturnProjected(_theProjection).GetY", y)
else
theFTab.Calculate("[Shape].ReturnCenter.GetX", x)
theFTab.Calculate("[Shape].ReturnCenter.GetY", y)
end ' if
end
'Return editing state to pre-script running state
theFTab.SetEditable(edit_state)
More information about the Uw-gis-l
mailing list