Точка в центре полигона

Arcview GIS 3.x, Arcinfo Workstation, Mapobjects
Ответить
greengo
Новоприбывший
Сообщения: 8
Зарегистрирован: 07 июн 2010, 10:40
Репутация: 0

Точка в центре полигона

Сообщение greengo » 07 июн 2010, 10:46

Имеем шейп-файл с множеством разбросанных по карте замкнутых мелких полигонов.
Задача - получить одну точку в центре каждого полигона.
Как можно это реализовать наименьшими трудозатратами?
Вручную стал набивать ... понял что не выход.
Может кто сталкивался с подобными задачами?
Версия ArcView 3.х

ggis
Завсегдатай
Сообщения: 302
Зарегистрирован: 31 окт 2008, 10:39
Репутация: 2

Re: Точка в центре полигона

Сообщение ggis » 07 июн 2010, 11:41

' Name: PolyCentroidToPoint
'
' Title: Polygon Centroid to Point Theme
'
' Topics: polygon, shapefile, centroid, point
'
' Author: Tara Montgomery 12/20/99
'
' Description: Make a point theme from the centroid of a polygon
'
' Called by:
'
' Runs:
'
' Self:
'
' Returns: Nothing

theProject = av.GetProject
theDocs = theProject.GetDocs

'Let the user select the view and polygon theme
theViewList = List.Make
for each theDoc in theDocs
if (theDoc.GetClass.GetClassName = "view") then
theViewList.Add(theDoc)
end
end
theView = msgbox.Choice (theViewList,"Select the view containing the polygon theme you wish to convert","Select a View")
if (theView.GetName = "") then
Exit
end

theProjection = theView.GetProjection
if (theProjection <> "") then
msgbox.info ("It was determined that the view is projected." + NL + NL +
"Please un-project the view then re-run the conversion.","ERROR - VIEW IS PROJECTED")
Exit
end

theThemeList = theView.GetThemes
thePolyThemeList = List.Make
for each theThm in theThemeList
if (theThm.GetSrcName.GetSubName = "polygon") then
thePolyThemeList.Add(theThm)
end
end
theTheme = msgbox.Choice (theThemeList,"Select the polygon theme you wish to convert",theView.GetName + ": Select a Theme")
if (theTheme.GetName = "") then
Exit
end

theTList = List.Make
for each theView in theViewList
theTs = theView.GetThemes
for each theT in theTs
if (theT.GetSrcName.AsString = theTheme.GetSrcName.AsString) then
theTList.Add(theT)
end
end
end
if (theTList.Count > 1) then
msgbox.WARNING ("The same theme exists in other views in this project." + NL + NL + "Please create a unique shapefile from the theme before running this utility.","WARNING - DUPLICATE THEME EXISTS IN PROJECT")
Exit
end

theFullThemeName = theTheme.GetFTab.GetName
thePeriod = theFullThemeName.Indexof(".")
theThemeName = theFullThemeName.Left(thePeriod)

'Add the polygon centroid to the theme's table
theFTab = theTheme.GetFTab
theFTab.SetEditable(True)
if (theFTab.IsEditable) then
X = Field.Make ("X",#FIELD_DECIMAL,18,5)
Y = Field.Make ("Y",#FIELD_DECIMAL,18,5)
theFTab.AddFields({X,Y})
theFTab.Calculate("[Shape].ReturnCenter.GetX",X)
theFTab.Calculate("[Shape].ReturnCenter.GetY",Y)
end
theFTab.SetEditable(False)

'Create a point event theme and add it to the view
theEventTheme = XYName.Make(theFTab,X,Y)
theEventTheme = Theme.Make(theEventTheme)
theEventTheme.SetName(theThemeName + "_pt")
theView.AddTheme(theEventTheme)
theEventTheme.SetVisible(True)
msgbox.info ("A new point theme ( " + theEventTheme.GetName + " ) has been added to the " + theView.GetName + " view.","NEW POINT THEME ADDED TO VIEW")

greengo
Новоприбывший
Сообщения: 8
Зарегистрирован: 07 июн 2010, 10:40
Репутация: 0

Re: Точка в центре полигона

Сообщение greengo » 07 июн 2010, 12:21

Огромное спасибо :)

roof2005
Интересующийся
Сообщения: 29
Зарегистрирован: 06 авг 2013, 16:42
Репутация: 0

Re: Точка в центре полигона

Сообщение roof2005 » 12 сен 2013, 13:09

Кто-нибудь может помочь, как воспользоваться этим кодом?
Простая вставка его в окно питона не работает ØD
Надо что-то где-то заменить?

roof2005
Интересующийся
Сообщения: 29
Зарегистрирован: 06 авг 2013, 16:42
Репутация: 0

Re: Точка в центре полигона

Сообщение roof2005 » 12 сен 2013, 13:15

Решил проблему следующим образом:
1) Feature to point
2) Add XY to point

dime1
Гуру
Сообщения: 939
Зарегистрирован: 29 май 2011, 19:41
Репутация: 94
Откуда: Киев

Re: Точка в центре полигона

Сообщение dime1 » 12 сен 2013, 14:03

Точка в центре полигона называется центроид, спокойно автоматически выставляется в атрибутивной таблице через Calculate Geometry.

Ответить

Вернуться в «Arcview GIS»

Кто сейчас на конференции

Сейчас этот форум просматривают: нет зарегистрированных пользователей и 3 гостя