[Mapserver-users] OT: ArcView Line Theme
Kieran J. Ames
kames at keyspanenergy.com
Wed Jan 28 05:07:49 PST 2004
--------------5472D2CD0BFEA022A822166E
Content-Type: text/plain; charset=us-ascii
Content-Transfer-Encoding: 7bit
Many thanks to all for your help
I ended up using a script called pt_ln_pl.ave
While heavy on the processing time (making straight polylines from about 1,500 definitions took about 10 minutes and 100%
cpu), this script did everything I needed.
I include it here since finding it again was quite a task.
Kieran
'PT_LN_PL.AVE
'Original author Daniel Nielsen August 31, 1998
'Modified by Dan Patterson Jan 28, 1999
'
'This script must be run on a Table document. The output will be a polyline shapefile.
'This script will convert a table of points to a polyline shapefile with the option of
'creating line segments between point pairs (as a polyline) or by creating a continuous
'polyline from a sequenced list of points.
'You also have the option of creating a closed-loop polyline which can be used to create polygons
'using the ESRI sample script 'Convert polylines to polygons'.
'
'The input point table must have four fields containing numeric data
' 1 an x-coordinate
' 2 a y-coordinate
' 3 a polyline identifier field (i.e. all points in the same polyline must have the same ID)
' 4 a vertex ID field which designates the order of the vertices (points) for each polyline.
' 5 an attribute field which contains the attributes that you want to assign to the polylines.
' Note, the attribute from the first point that is used to form the polyline is used
' This can be modified in the script if you so choose
'
'*******************************************************************************************************************
' Get the active table and choose the coordinate, ID and the attribute fields.
theVTab = av.GetActiveDoc.GetVTab
theFields = theVTab.GetFields
chosenfields={}
'
XField = MsgBox.List(theFields, "Longitude or Easting values", "Select X-coordinates field")
chosenfields.add(Xfield)
YField = MsgBox.List(theFields, "Latitude or Northing values", "Select Y-coordinates field")
chosenfields.add(YField)
IDField = MsgBox.List(theFields, "Each polyline 'event' must be identified by a unique number", "Select Unique polyline ID field in table")
chosenfields.add(IDField)
VertField = MsgBox.List(theFields, "These are the points that define each polyline", "Select the Vertice ID field")
chosenfields.add(VertField)
AttribField=MsgBox.List(theFields, "The attribute will be added to the polyline", "Select the Value to add to polyline")
chosenfields.add(AttribField)
' check to make sure that the x, y, ID and vertex fields are numeric, the attributes can be anything
'
for each i in 0 .. (chosenfields.count-2)
stringTest=chosenfields.get(i)
if (stringTest.IsTypeNumber.Not) then
MsgBox.Info(stringTest.asstring++" field must be numeric!","Correct Point Table")
exit
end
end
'*******************************************************************************************************************
' ** Create the new shapefile
'
fnDefault = FileName.Make("$HOME").MakeTmp("shape","shp")
fnOutput = FileDialog.Put( fnDefault,"*.shp","Output Shape File" )
if (fnOutput = nil) then exit end
fnOutput.SetExtension("shp")
'
' Create the field list and see if fields from the input table are to be appended to the output table
'
ftbOutput = FTab.MakeNew( fnOutput, POLYLINE )
'
X=chosenFields.get(4) 'get the name of the attribute field in the source table
FldList={"Shape","ID","Attribute"} 'create the field names in the output table
'
ftbOutput.AddFields({Field.Make("ID", #FIELD_LONG, 8, 0)})
ftbOutput.AddFields({Field.make("Attribute", X.gettype, X.getwidth, X.getprecision)})
' ** Get a list of all unique polyline ID values. These are the polylines that you are going to create
' The ID number will be assigned to the ID field of each polyline that is created.
' Also checks to see if there are selected records in the source table.
IDList = List.Make
if (theVTab.GetSelection.Count = 0) then
theSet = theVTab
else
theSet = theVTab.GetSelection
end
for each rec in theSet
IDList.Add(theVTab.ReturnValueString(IDField, rec))
end
'*******************************************************************************************************************
' Check for errors, remove duplicate ID numbers, and sorts the list.
'
if (IDList.Count > 0) then
IDList.RemoveDuplicates
IDList.Sort(true)
else
exit
end
theBitMap = theVTab.GetSelection
theBitMap.Clearall
theVTab.SetSelection(theBitMap)
'*******************************************************************************************************************
' Choose the feature type
'
' Select whether individual line segments or a continuous polyline is required (i.e. more than 2 points)
' For example, you could have 4 points delineating the bounds of a rectangle. You
' are given the option of creating 4 line segments, 1 polyline connecting points 1 through 4, or
' a closed-loop polyline which connects points 1 through 4 then closes back on 1 again.
SnapLine=(FALSE)
ChoiceList={"Segmented", "Continuous","Closed-loop"}
FeatureType=msgbox.ListAsString(ChoiceList,"Choose output format of polylines", "Feature Type to Create")
if (FeatureType <> "Segmented") then
if(FeatureType<> "Continuous") then
SnapLine = (TRUE)
end
end
'*******************************************************************************************************************
'
for each ID in IDList
theVTab.query("[" ++ IDField.AsString ++ "] = " ++ ID.asString, theBitMap, #VTAB_SELTYPE_NEW)
theVTab.UpdateSelection
'**Gets a sorted list of all vertice ID values
vertList = {}
for each rec in theVTab.GetSelection
vertList.add(theVTab.ReturnValue(VertField, rec))
end
vertList.Sort(TRUE)
' **Create a point list and an attribute list and sorts the points by the verticeID numbers.
pointList = {}
dataList={}
for each vertNum in vertList
theVTab.query("[" ++ IDField.AsString ++ "] = " ++ ID.asString, theBitMap, #VTAB_SELTYPE_NEW)
theVTab.query("[" ++ VertField.AsString ++ "] = " ++ vertNum.asString, theBitMap, #VTAB_SELTYPE_AND)
' ** Make the point and get the attributes
for each rec in theVTab.GetSelection
aPoint = point.make( theVTab.ReturnValue (XField, rec), theVTab.ReturnValue (YField, rec) )
pointList.Add(aPoint)
dataList.add(theVTab.ReturnValue(AttribField, rec))
end
end
'
'*******************************************************************************************************************
' ** Optionally create Line segments from points in the polyline theme
if (FeatureType = "Segmented") then
i=0
smallList={}
' ** Add a new polyline record to the output shapefile and get the data for the point
' Note in this application, it assigns the attributes for the first point which makes up the polyline segment
' Change the get(?) option to specify another point to use. For individual line segments, this can be 0 or 1.
for each j in 0 .. (pointList.count -2)
data=dataList.get(j)
newRec = ftbOutput.AddRecord
smallList={pointList.get(i), pointlist.get(i+1)}
newline = Polyline.make({smallList})
fldShapeOut=ftbOutput.FindField("shape")
fldIDOut=ftbOutput.findField("id")
fldDataOut=ftbOutput.findField("attribute")
ftbOutput.SetValue(fldShapeOut, newRec, newLine) '.AsPolyLine)
ftbOutput.SetValue(fldIDOut, newRec, ID.AsString)
ftbOutput.SetValue(fldDataOut, newRec, data)
i=i+1
end
else
' ** Optionally create a continuous polyline from the points in the polyline theme.
' Specify whether you want a closed loop polyline
'
If (SnapLine) then
pointList.Add(pointList.get(0))
end
' ** add a new polyline record to the output shapefile
' Note in this application, it assigns the attributes for the first point which makes up the polyline segment
' Change the get(?) option to specify another point to use.
data=dataList.get(0)
newRec = ftbOutput.AddRecord
newline = Polyline.make({pointList})
fldShapeOut=ftbOutput.FindField("shape")
fldIDOut=ftbOutput.findField("id")
fldDataOut=ftbOutput.findField("attribute")
ftbOutput.SetValue(fldShapeOut, newRec, newLine) '.AsPolyLine)
ftbOutput.SetValue(fldIDOut, newRec, ID.AsString)
ftbOutput.SetValue(fldDataOut, newRec, data)
end
end
theBitMap.Clearall
theVTab.UpdateSelection
'
'*******************************************************************************************************************
' ** Add the output shapefile to a View
'
viewList = list.make
for each d in av.GetProject.GetDocs
if (d.Is(View)) then
viewList.Add(d)
end
end
viewList.Add("")
addToView = MsgBox.ListAsString( viewList,"Add Theme to:", "Convert Points to Polylines" )
'
' ** Get the specified view, make the theme, and add it...
if (addToView <> nil) then
if (addToView = "") then
addToView = View.Make
addToView.GetWin.Open
end
newTheme = FTheme.Make( ftbOutput )
addToView.AddTheme( newTheme )
addToView.GetWin.Activate
end
Howard Mark wrote:
> Kieran,
>
> You'll need to know a bit of avenue script to do this. First you'll need to create a new LINE theme.
> Using an avenue script, you'll need to create a new line shape from the points, and add the shape to the line theme.
> This explanation is a bit simplistic.
> There are sample scripts online at the esri site www.esri.com
>
> Mark
>
> -----Original Message-----
> From: mapserver-users-admin at lists.gis.umn.edu [mailto:mapserver-users-admin at lists.gis.umn.edu]On Behalf Of Kieran J. Ames
> Sent: Monday, January 26, 2004 2:38 PM
> To: mapserver list
> Subject: [Mapserver-users] OT: ArcView Line Theme
>
> List,
> Sorry for the Off-Topic, but...
> I know how to import an event theme (points) into ArcView from text or
> dbf.
> I want to create a line theme (have 2 sets of points... the nodes).
> Can anyone point me to some documentation on how I'd get this
> information into ArcView?
>
> Thanks in advance.
> Kieran
>
> _______________________________________________
> Mapserver-users mailing list
> Mapserver-users at lists.gis.umn.edu
> http://lists.gis.umn.edu/mailman/listinfo/mapserver-users
>
> ********************************************************************************
> This message is intended only for the use of the Addressee and may
> contain information that is PRIVILEGED and CONFIDENTIAL.
>
> If you are not the intended recipient, you are hereby notified that any
> dissemination of this communication is strictly prohibited. If you have
> received this communication in error, please erase all copies of the
> message and its attachments and notify Space Imaging immediately.
> ********************************************************************************
--------------5472D2CD0BFEA022A822166E
Content-Type: text/html; charset=us-ascii
Content-Transfer-Encoding: 7bit
<!doctype html public "-//w3c//dtd html 4.0 transitional//en">
<html>
Many thanks to all for your help
<br>I ended up using a script called pt_ln_pl.ave
<br>While heavy on the processing time (making straight polylines from
about 1,500 definitions took about 10 minutes and 100% cpu), this script
did everything I needed.
<br>I include it here since finding it again was quite a task.
<br>Kieran
<br>
<pre>'PT_LN_PL.AVE
'Original author Daniel Nielsen August 31, 1998
'Modified by Dan Patterson Jan 28, 1999
'
'This script must be run on a Table document. The output will be a polyline shapefile.
'This script will convert a table of points to a polyline shapefile with the option of
'creating line segments between point pairs (as a polyline) or by creating a continuous
'polyline from a sequenced list of points.
'You also have the option of creating a closed-loop polyline which can be used to create polygons
'using the ESRI sample script 'Convert polylines to polygons'.
'
'The input point table must have four fields containing numeric data
' 1 an x-coordinate
' 2 a y-coordinate
' 3 a polyline identifier field (i.e. all points in the same polyline must have the same ID)
' 4 a vertex ID field which designates the order of the vertices (points) for each polyline.
' 5 an attribute field which contains the attributes that you want to assign to the polylines.
' Note, the attribute from the first point that is used to form the polyline is used
' This can be modified in the script if you so choose
'
'*******************************************************************************************************************
' Get the active table and choose the coordinate, ID and the attribute fields.
theVTab = av.GetActiveDoc.GetVTab
theFields = theVTab.GetFields
chosenfields={}
'
XField = MsgBox.List(theFields, "Longitude or Easting values", "Select X-coordinates field")
chosenfields.add(Xfield)
YField = MsgBox.List(theFields, "Latitude or Northing values", "Select Y-coordinates field")
chosenfields.add(YField)
IDField = MsgBox.List(theFields, "Each polyline 'event' must be identified by a unique number", "Select Unique polyline ID field in table")
chosenfields.add(IDField)
VertField = MsgBox.List(theFields, "These are the points that define each polyline", "Select the Vertice ID field")
chosenfields.add(VertField)
AttribField=MsgBox.List(theFields, "The attribute will be added to the polyline", "Select the Value to add to polyline")
chosenfields.add(AttribField)
' check to make sure that the x, y, ID and vertex fields are numeric, the attributes can be anything
'
for each i in 0 .. (chosenfields.count-2)
stringTest=chosenfields.get(i)
if (stringTest.IsTypeNumber.Not) then
MsgBox.Info(stringTest.asstring++" field must be numeric!","Correct Point Table")
exit
end
end
'*******************************************************************************************************************
' ** Create the new shapefile
'
fnDefault = FileName.Make("$HOME").MakeTmp("shape","shp")
fnOutput = FileDialog.Put( fnDefault,"*.shp","Output Shape File" )
if (fnOutput = nil) then exit end
fnOutput.SetExtension("shp")
'
' Create the field list and see if fields from the input table are to be appended to the output table
'
ftbOutput = FTab.MakeNew( fnOutput, POLYLINE )
'
X=chosenFields.get(4) 'get the name of the attribute field in the source table
FldList={"Shape","ID","Attribute"} 'create the field names in the output table
'
ftbOutput.AddFields({Field.Make("ID", #FIELD_LONG, 8, 0)})
ftbOutput.AddFields({Field.make("Attribute", X.gettype, X.getwidth, X.getprecision)})
' ** Get a list of all unique polyline ID values. These are the polylines that you are going to create
' The ID number will be assigned to the ID field of each polyline that is created.
' Also checks to see if there are selected records in the source table.
IDList = List.Make
if (theVTab.GetSelection.Count = 0) then
theSet = theVTab
else
theSet = theVTab.GetSelection
end
for each rec in theSet
IDList.Add(theVTab.ReturnValueString(IDField, rec))
end
'*******************************************************************************************************************
' Check for errors, remove duplicate ID numbers, and sorts the list.
'
if (IDList.Count > 0) then
IDList.RemoveDuplicates
IDList.Sort(true)
else
exit
end
theBitMap = theVTab.GetSelection
theBitMap.Clearall
theVTab.SetSelection(theBitMap)
'*******************************************************************************************************************
' Choose the feature type
'
' Select whether individual line segments or a continuous polyline is required (i.e. more than 2 points)
' For example, you could have 4 points delineating the bounds of a rectangle. You
' are given the option of creating 4 line segments, 1 polyline connecting points 1 through 4, or
' a closed-loop polyline which connects points 1 through 4 then closes back on 1 again.
SnapLine=(FALSE)
ChoiceList={"Segmented", "Continuous","Closed-loop"}
FeatureType=msgbox.ListAsString(ChoiceList,"Choose output format of polylines", "Feature Type to Create")
if (FeatureType <> "Segmented") then
if(FeatureType<> "Continuous") then
SnapLine = (TRUE)
end
end
'*******************************************************************************************************************
'
for each ID in IDList
theVTab.query("[" ++ IDField.AsString ++ "] = " ++ ID.asString, theBitMap, #VTAB_SELTYPE_NEW)
theVTab.UpdateSelection
'**Gets a sorted list of all vertice ID values
vertList = {}
for each rec in theVTab.GetSelection
vertList.add(theVTab.ReturnValue(VertField, rec))
end
vertList.Sort(TRUE)
' **Create a point list and an attribute list and sorts the points by the verticeID numbers.
pointList = {}
dataList={}
for each vertNum in vertList
theVTab.query("[" ++ IDField.AsString ++ "] = " ++ ID.asString, theBitMap, #VTAB_SELTYPE_NEW)
theVTab.query("[" ++ VertField.AsString ++ "] = " ++ vertNum.asString, theBitMap, #VTAB_SELTYPE_AND)
' ** Make the point and get the attributes
for each rec in theVTab.GetSelection
aPoint = point.make( theVTab.ReturnValue (XField, rec), theVTab.ReturnValue (YField, rec) )
pointList.Add(aPoint)
dataList.add(theVTab.ReturnValue(AttribField, rec))
end
end
'
'*******************************************************************************************************************
' ** Optionally create Line segments from points in the polyline theme
if (FeatureType = "Segmented") then
i=0
smallList={}
' ** Add a new polyline record to the output shapefile and get the data for the point
' Note in this application, it assigns the attributes for the first point which makes up the polyline segment
' Change the get(?) option to specify another point to use. For individual line segments, this can be 0 or 1.
for each j in 0 .. (pointList.count -2)
data=dataList.get(j)
newRec = ftbOutput.AddRecord
smallList={pointList.get(i), pointlist.get(i+1)}
newline = Polyline.make({smallList})
fldShapeOut=ftbOutput.FindField("shape")
fldIDOut=ftbOutput.findField("id")
fldDataOut=ftbOutput.findField("attribute")
ftbOutput.SetValue(fldShapeOut, newRec, newLine) '.AsPolyLine)
ftbOutput.SetValue(fldIDOut, newRec, ID.AsString)
ftbOutput.SetValue(fldDataOut, newRec, data)
i=i+1
end
else
' ** Optionally create a continuous polyline from the points in the polyline theme.
' Specify whether you want a closed loop polyline
'
If (SnapLine) then
pointList.Add(pointList.get(0))
end
' ** add a new polyline record to the output shapefile
' Note in this application, it assigns the attributes for the first point which makes up the polyline segment
' Change the get(?) option to specify another point to use.
data=dataList.get(0)
newRec = ftbOutput.AddRecord
newline = Polyline.make({pointList})
fldShapeOut=ftbOutput.FindField("shape")
fldIDOut=ftbOutput.findField("id")
fldDataOut=ftbOutput.findField("attribute")
ftbOutput.SetValue(fldShapeOut, newRec, newLine) '.AsPolyLine)
ftbOutput.SetValue(fldIDOut, newRec, ID.AsString)
ftbOutput.SetValue(fldDataOut, newRec, data)
end
end
theBitMap.Clearall
theVTab.UpdateSelection
'
'*******************************************************************************************************************
' ** Add the output shapefile to a View
'
viewList = list.make
for each d in av.GetProject.GetDocs
if (d.Is(View)) then
viewList.Add(d)
end
end
viewList.Add("")
addToView = MsgBox.ListAsString( viewList,"Add Theme to:", "Convert Points to Polylines" )
'
' ** Get the specified view, make the theme, and add it...
if (addToView <> nil) then
if (addToView = "") then
addToView = View.Make
addToView.GetWin.Open
end
newTheme = FTheme.Make( ftbOutput )
addToView.AddTheme( newTheme )
addToView.GetWin.Activate
end
</pre>
<p>
<p>Howard Mark wrote:
<blockquote TYPE=CITE>Kieran,
<p>You'll need to know a bit of avenue script to do this. First you'll
need to create a new LINE theme.
<br>Using an avenue script, you'll need to create a new line shape from
the points, and add the shape to the line theme.
<br>This explanation is a bit simplistic.
<br>There are sample scripts online at the esri site www.esri.com
<p>Mark
<p>-----Original Message-----
<br>From: mapserver-users-admin at lists.gis.umn.edu [<a href="mailto:mapserver-users-admin at lists.gis.umn.edu">mailto:mapserver-users-admin at lists.gis.umn.edu</a>]On
Behalf Of Kieran J. Ames
<br>Sent: Monday, January 26, 2004 2:38 PM
<br>To: mapserver list
<br>Subject: [Mapserver-users] OT: ArcView Line Theme
<p>List,
<br>Sorry for the Off-Topic, but...
<br>I know how to import an event theme (points) into ArcView from text
or
<br>dbf.
<br>I want to create a line theme (have 2 sets of points... the nodes).
<br>Can anyone point me to some documentation on how I'd get this
<br>information into ArcView?
<p>Thanks in advance.
<br>Kieran
<p>_______________________________________________
<br>Mapserver-users mailing list
<br>Mapserver-users at lists.gis.umn.edu
<br><a href="http://lists.gis.umn.edu/mailman/listinfo/mapserver-users">http://lists.gis.umn.edu/mailman/listinfo/mapserver-users</a>
<p>********************************************************************************
<br>This message is intended only for the use of the Addressee and may
<br>contain information that is PRIVILEGED and CONFIDENTIAL.
<p>If you are not the intended recipient, you are hereby notified that
any
<br>dissemination of this communication is strictly prohibited. If you
have
<br>received this communication in error, please erase all copies of the
<br>message and its attachments and notify Space Imaging immediately.
<br>********************************************************************************</blockquote>
</html>
--------------5472D2CD0BFEA022A822166E--
More information about the MapServer-users
mailing list