MapWinGeoProc:Utils AreaOfPart

This is a back-up of the WIKI.
Not all links might work
We're working on a new wiki.

Main Page | Recent changes | View source | Page history | Log in / create account |

Printable version | Disclaimers | Privacy policy

AreaOfPart

Syntax

 double AreaOfPart(MapWinGIS.Shape polygon, int PartIndex)

Summary

Calculates the area of a part, without taking into consideration any other aspects of the polygon.

Parameters

polygon A MapWinGIS.Shape POLYGON, POLYGONZ, or POLYGONM
PartIndex The integer index of the part to obtain the area of.
This value will be ignored if the shape only has one part, and the function
will calculate the area of the entire shape.

Returns

A double value that is equal to the area of the part.

Remarks

Coded by Ted Dunsford 6/23/2006, derived from Angela's Area algorithm
Code reference http://astronomy.swin.edu.au/~pbourke/geometry/polyarea/
Cached in MapWinGeoProc\clsUtils\Documentation\
I don't think that we ever want to return a negative area from this function,
even if the part is a hole, because it is being calculated outside of the
context of any other parts. Only the collective Area function should worry about
ascribing a sign value to the individual part areas.

Visual Basic Net 2005 Example Implementation Code

 ' Requires a reference to MapWinGIS
 ' Requires a reference to MapWinGeoProc
 Public Class Form1
     Implements MapWinGIS.ICallback
     Dim mwShapefile As New MapWinGIS.Shapefile
 
     Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
         mwShapefile.Open("C:\temp\Triangles.shp")
         AxMap1.AddLayer(mwShapefile, True)
     End Sub
 
     Private Sub cmdGetArea_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles cmdGetArea.Click
         Dim shape As New MapWinGIS.Shape
         shape = mwShapefile.Shape(0)
         MessageBox.Show("Area 0: " & MapWinGeoProc.Utils.AreaOfPart(shape, 0))
         MessageBox.Show("Area 1: " & MapWinGeoProc.Utils.AreaOfPart(shape, 1))
     End Sub
 
     Public Sub [Error](ByVal KeyOfSender As String, ByVal ErrorMsg As String) Implements MapWinGIS.ICallback.Error
         MessageBox.Show("ErrorMsg")
     End Sub
 
     Public Sub Progress(ByVal KeyOfSender As String, ByVal Percent As Integer, ByVal Message As String) Implements MapWinGIS.ICallback.Progress
         ProgressBar1.Value = Percent
     End Sub
 
 End Class

Visual C# 2005 Implementation Example code

 ' Requires a reference to MapWinGIS
 ' Requires a reference to MapWinGeoProc
 using System;
 using System.Collections.Generic;
 using System.ComponentModel;
 using System.Data;
 using System.Drawing;
 using System.Text;
 using System.Windows.Forms;
 
 namespace CSharpDemo
 {
     public partial class Form1 : Form, MapWinGIS.ICallback 
     {
         MapWinGIS.Shapefile mwShapefile;
         public Form1()
         {
             InitializeComponent();
         }
         private void cmdGetArea_Click(object sender, EventArgs e)
         {
             MapWinGIS.Shape shape;
             shape = mwShapefile.get_Shape(0);
             MessageBox.Show("Area 0: " + MapWinGeoProc.Utils.AreaOfPart(shape, 0));
             MessageBox.Show("Area 1: " + MapWinGeoProc.Utils.AreaOfPart(shape, 1));
         }
 
         private void Form1_Load(object sender, EventArgs e)
         {
             mwShapefile = new MapWinGIS.ShapefileClass();
             mwShapefile.Open(@"C:\Temp\Triangles.shp", this);
             axMap1.AddLayer(mwShapefile, true);
         }
         public void Error(string KeyOfSender, string ErrorMsg)
         {
             MessageBox.Show(ErrorMsg);
         }
         public void Progress(string KeyOfSender, int Percent, string Message)
         {
             progressBar1.Value = Percent;
         }
     }
 }

Function added to MapWinGeoProc by Ted Dunsford 6/23/2006

Back to Utils

Retrieved from "http://mapwindow.org/wiki/index.php/MapWinGeoProc:Utils_AreaOfPart"

This page has been accessed 1,206 times. This page was last modified on 26 June 2006, at 22:24.