MapWinGeoProc:Utils Area1

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

Area

Syntax

 double Area(ref MapWinGIS.Shape shape)

Summary

Computes the area of a polygon. For multi-part polygons, assume holes are counter-clockwise.

Parameters

shape The polygon shape.

Returns

The area in square units, or 0.0 if it could not be found.

Remarks

Revised by Ted Dunsford 6/23/2006 to loop through AreaOfPart

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
         MessageBox.Show("Area 0: " & MapWinGeoProc.Utils.Area(mwShapefile.Shape(0)))
         MessageBox.Show("Area 1: " & MapWinGeoProc.Utils.Area(mwShapefile.Shape(0)))
     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 Example Implementation 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 = mwShapefile.get_Shape(0);
             MessageBox.Show("Area 0: " + MapWinGeoProc.Utils.Area(ref shape));
            
             shape = mwShapefile.get_Shape(1);
             MessageBox.Show("Area 1: " + MapWinGeoProc.Utils.Area(ref shape));
         }
 
         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;
         }
     }
 }

Back to Utils

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

This page has been accessed 866 times. This page was last modified on 17 March 2008, at 09:26.