Stel je hebt een shapefile gemaakt met polygonen.
Wanneer je nu op de theme table klikt: ![]() Om bij iedere polygon de oppervlak en omtrek erbij te krijgen moet je een script maken, compilen en runnen: Klik in het project (*.apr) op Scripts | New.Geef meteen het Script een naam zodat je weet waar het over gaat b.v. Als je onderstaand scherm ziet; selecteer Script2
Terug in de view selecteer je de shapefile waarvan je het oppervlak
en omtrek van iedere polygoon afzonderijk wilt berekenen.
Wanneer je nieuwe polygonen aan de shapefile toevoegd word niet automatisch oppervlak en omtrek toegevoegd. Hiervoor moet je steeds opnieuw het script laten runnen |
![]() ![]() |
' Name: View.CalculateFeatureGeometry
' ' Title: Calculates feature geometry values ' ' Topics: GeoData ' ' Description: Calculates area and perimeter for polygon themes and length ' for line themes. If the View has been projected the calculations are in ' projected meters. Otherwise the calculations are in 'native' map units. ' Modify the script to provide calculation in the current report units of ' the View. The script processes the list of active themes to calculate ' area and perimeter, or length, depending on the theme type. ' ' The script will add the fields: Area and Perimeter to polygon themes, Length ' to line themes if they do not exist. If the fields exist their values will ' be recalculated. Rerun the script if you change the projection of the view. ' ' Requires: A View with at least one active theme. You must have write access ' to the active theme(s). ' ' Self: ' ' Returns: '
'
'
theAreaField = theFTab.FindField("Area")
if (theFTab.FindField("Perimeter") = nil) then
thePerimeterField = theFTab.FindField("Perimeter")
'
theArea = theShape.ReturnArea
theFTab.SetValue(theAreaField,rec,theArea)
elseif (theType = #FIELD_SHAPELINE) then
else
theLengthField = theFTab.FindField("Length")
'
theLength = theShape.ReturnLength theFTab.SetValue(theLengthField,rec,theLength)
end theFTab.SetEditable(FALSE)
|