ArcView:Polygone aufteilen
GISWiki - Das freie Portal für Geoinformatik (GIS)
Frage aus dem Anuva-Forum
Hallo
folgendes Problem: Ich habe ein Polygonshape mit ca. 1000 Polygone und ein Punktshape. Ich soll nun alle Polygone in denen sich mehr als ein Punkt befindet, entsprechend der Punktanzahl aufteilen (3 Punkte im Polygon -> Polygon auf drei neue Polygone aufteilen, Punkt = Mitte vom neuen Polygon). Kennt jemand eine Extension die diese Funktion beinhaltet oder einen anderen Lösungsweg
ArcView 3.2 oder ArcView 9
Script für den ersten Bearbeitungsschritt (Punkte je Polygon zählen):
' Name: View.CountPointsInPolygon
' Purpose: Counts the number of points in a point theme within or adjacent
' to each polygon ' in a polygon theme and writes the count to a
' user named field in the polygon theme's ftab
' Written by: Maxilla 26.11.03
'---------------------------------------------------------------------------------
' GET THE VIEW
theView = av.GetActiveDoc
if (theView.is(View).not) then
msgBox.Info("Starten Sie das Skript von einem View aus!","")
return NIL
end
'---------------------------------------------------------------------------------
' FILL THEME LISTS
thePGThms = List.Make
thePTThms = List.Make
for each thm in theView.GetThemes
theFClass = thm.GetSrcName.GetSubName
if(theFClass = "POLYGON") then
thePGThms.Add(thm)
elseif(theFClass = "POINT") then
thePTThms.Add(thm)
end
end
'---------------------------------------------------------------------------------
' GET THEMES FROM THE USER
thePGThm = MsgBox.List(thePGThms,"Selektieren Sie das Polygonthema:"," Polygonthema")
if (thePGThm = NIL) then
return nil
end
thePTThm = MsgBox.List(thePTThms,"Selektieren Sie das Punktthema:"," Punktthema")
if (thePTThm = NIL) then
return nil
end
'---------------------------------------------------------------------------------
' GET THE POLYGON VTAB AND THE NEW FIELD'S NAME
thePGVTab = thePGThm.GetFtab
theEditState = thePGVTab.IsEditable
thePGVTab.SetEditable(TRUE)
if (thePGVTab.IsEditable.not) then return NIL end
thePGNumR = thePGVTab.GetNumRecords
theShpFld = thePGVTab.FindField("Shape")
theCountFldStr = MsgBox.Input("Bitte einen Namen für das Countfeld eingeben","Feldname","PT_Count")
a = 0
while (a = 0)
if (thePGVTab.FindField(theCountFldStr) <> NIL) then
MsgBox.Info("Ein Feld mit dem Namen '"+theCountFldStr+"' existiert bereits. Geben Sie einen anderen Namen an...","")
theCountFldStr = MsgBox.Input("Bitte einen Namen für das Countfeld eingeben","Feldname","PT_Count")
if (theCountFldStr = NIL) then
return NIL
end
else
a = 1
end
end
if (thePGVTab.FindField(theCountFldStr) = NIL) then
thePGVTab.AddFields({Field.Make(theCountFldStr, #FIELD_DECIMAL, 9, 0)})
end
theCountFld = thePGVTab.FindField(theCountFldStr)
'---------------------------------------------------------------------------------
' COUNT POINTS FOR EACH POLYGON
for each rec in thePGVTab
av.ShowMsg("Zähle Punkte ...")
av.ShowStopButton
progress = (rec/thePGNumR)*100
goesAhead = av.setStatus(progress)
if (not goesAhead) then break end
av.UseWaitCursor
theShp = {thePGVTab.returnValue(theShpFld, rec)}
thePTThm.SelectByShapes (theShp,#VTAB_SELTYPE_NEW)
thePTVTab = thePTThm.GetFTab
thePTBitmap = thePTVTab.GetSelection
theCount = thePTBitmap.Count
thePGVTab.SetValue(theCountFld, rec, theCount)
end
thePGVTab.SetEditable(theEditState)
av.clearStatus
av.ShowMsg("Fertig...")
Das ganze geht auch über einen Join mit anschließendem Summarize, das ist aber natürlich nicht sooo simpel, wie einfach nur ein Knöpfchen zu drücken ;).