MapPoint Forums

MapForums

Community of MapPoint and Bing Maps Users and Developers




Calculate area of territory

This is a discussion on Calculate area of territory within the MapPoint Desktop Discussion forums, part of the Map Forums category; Hi all, I have create some territories on a map, i would like to now how many square kilometers that ...


Go Back   MapPoint Forums > Map Forums > MapPoint Desktop Discussion

Today's Posts Twitter Feed Register Blogs FAQ Members List Calendar Search Today's Posts Mark Forums Read
  #1 (permalink)  
Old 07-23-2008
Junior Member
White Belt
 
Join Date: Jul 2008
Posts: 3
Calculate area of territory

Hi all,

I have create some territories on a map, i would like to now how many square kilometers that territory is. is this possible in Mappoint 2006
(territory is a collection of postalcodes).

kind regards

Ludo
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Spurl this Post!Reddit! Wong this Post!
Reply With Quote
  #2 (permalink)  
Old 07-23-2008
Senior Member
Green Belt
 
Join Date: Sep 2005
Location: Battle Creek, Michigan
Posts: 136
Arrow Re: Calculate area of territory

You can iterate through the territory dataset and get each postal code contained within a particular territory. Then you can use ActiveMap.Datasets.GetDemographics() to query for the area (sqkm) of each postal code. Add them up to get the total sqkm for each territory.

HTH
-Paul
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Spurl this Post!Reddit! Wong this Post!
Reply With Quote
  #3 (permalink)  
Old 07-24-2008
Junior Member
White Belt
 
Join Date: Jul 2008
Posts: 3
Re: Calculate area of territory

Hi,

Thanks for your reply Paul, I am not that experienced with MapPoint, I have tried to retrieve the data, but no succes...
here is the code:
Imports MapPoint
Imports MapPoint.GeoMapRegion
PublicClass Form1
Dim objapp As MapPoint.Application
Dim objDataSet As MapPoint.DataSet
Dim objDataMap As MapPoint.DataMap
Dim objField As MapPoint.Field
Dim objMap As MapPoint.Map
Dim objLocation As MapPoint.Location
Dim objShape As MapPoint.Shape
PrivateSub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) HandlesMyBase.Load
Dim km AsString
'Create Mappoint as Object and allow control
objapp = CreateObject("Mappoint.application")
objapp.Visible = True
objapp.UserControl = True
km = Getkm("77600")
EndSub
Function Getkm(ByVal Postcode AsString)
'Add data to current map
objDataSet = objapp.ActiveMap.DataSets.GetDemographics(GeoCount ry.geoCountryFrance)
objField = objDataSet.Fields(1)
objDataMap = objDataSet.DisplayDataMap(GeoDataMapType.geoDataMa pTypeShadedArea, objField, GeoShowDataBy.geoShowByPostal1, , , , 15)
'Find and set location
objMap = objapp.ActiveMap
objLocation = objMap.FindResults(Postcode).Item(1)
'get data ???
Getkm =
EndFunction

I don't now what i do wrong to get the specific data..

kind regards

Ludo
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Spurl this Post!Reddit! Wong this Post!
Reply With Quote
  #4 (permalink)  
Old 07-27-2008
Senior Member
Blue Belt
 
Join Date: Oct 2003
Location: London
Posts: 290
Re: Calculate area of territory

It may not be what you’re looking for but you can do this fairly easily in excel vba (or Access) by handling the data-bases independent of MP. I worked through an example in which I set up an excel workbook with sheet “Territories Definition” containing the ‘export to excel’ data from the MP territories map, sheet “Territory Names” containing a column with the territory names and sheet “Demographics” containing the area information. To get this area information use Data Mapping Wizard to plot a shaded map for all of France showing postcode areas. Now export that data to excel (5942 postcode areas in total) and cut and paste into your main excel workbook. You can now do the analysis independent of MP and get around the vagaries of the query methods on MP. If you set up another sheet called “Analysis” then my following feeble attempt at code would, I think, give you the area for a specified territory

Code:
Private Sub GetTerritoryArea_Click()

  Dim TerritoryName As String, Postcode As String
  Dim nCurrentRow As Integer, nRow1 As Integer, nRow2 As Integer, _ 
                iCount As Integer, jCount As Integer
  Dim R As Range
  Dim Area As Single, TotalArea As Single

  nCurrentRow = 2
  Worksheets("Territory Definition").Cells(1, 4).Value = "Area"

  Do While Worksheets("Territory Definition").Cells(nCurrentRow, 1) <> ""
     Postcode = Worksheets("Territory Definition").Cells(nCurrentRow, 1).Value
     Set R = Worksheets("Demographics").Range("A1:C5943").Find(Postcode)
     If Not R Is Nothing Then Area = R.Offset(0, 2).Value
     Worksheets("Territory Definition").Cells(nCurrentRow, 4).Value = Area
     Set R = Nothing
     nCurrentRow = nCurrentRow + 1
  Loop

  TerritoryName = InputBox("Which Territory?")

  nCurrentRow = 2
  TotalArea = 0#
  Do While Worksheets("Territory Definition").Cells(nCurrentRow, 1) <> ""
       If Worksheets("Territory Definition").Cells(nCurrentRow, 3).Value = TerritoryName _
       Then TotalArea = TotalArea + Worksheets("Territory Definition"). _
       Cells(nCurrentRow, 4).Value

  nCurrentRow = nCurrentRow + 1
  Loop

  MsgBox "Area of " & TerritoryName & " is " & TotalArea

End Sub
If you wanted to output the area of ALL your territories to the “Analysis” sheet you could substitute the following code into the routine above

Code:
  nRow1 = Worksheets("Territory Names").Cells(1, 1).End(xlDown).Row 
  nRow2 = Worksheets("Territory Definition").Cells(1, 1).End(xlDown).Row
  iCount = 2
    For iCount = 2 To nRow1
    jCount = 2
    TotalArea = 0#
       For jCount = 2 To nRow2
       If Worksheets("Territory Definition").Cells(jCount, 3).Value _
       = Worksheets("Territory    Names").Cells(iCount, 1).Value Then _
       TotalArea = TotalArea + Worksheets("Territory Definition").Cells(jCount, 4).Value
      Next jCount
   Worksheets("Analysis").Cells(iCount, 1).Value = _
           Worksheets("Territory Names").Cells(iCount, 1).Value
   Worksheets("Analysis").Cells(iCount, 2).Value = TotalArea
   Next iCount
Taking this approach you only need to set up the French demographic database once and it can contain lots of columns, including your own data, that can be accessed by the off-set attribute in Find. Also you can you can use the territory map to redefine territories and then cut and paste the results into “Territory Definitions” and generate the new results

Code:
Private Sub TerritoryMap_Click()

  Dim objApp As MapPoint.Application
  Dim objMap As MapPoint.Map
  Dim objDataSet1 As MapPoint.DataSet
  Dim objDataSets As MapPoint.DataSets
  Dim zDataSource1 As String

  Set objApp = CreateObject("mappoint.application") ' Start Mappoint Europe 2006
  Set objMap = objapp.ActiveMap 
  objApp.Visible = True
  objApp.UserControl = True

  Set objDataSets = objapp.ActiveMap.DataSets
  zDataSource1 = "…… \FranceTerritories.xls!Territory Definition!"
  Set objDataSet1 = objDataSets.ImportTerritories(zDataSource1, , geoCountryFrance, , geoImportExcelSheet)
    objMap.DataSets.ZoomTo 

End Sub
HTH. I'm not a programmer so please treat the code with care if you use any of it. It'll need checking!!

Rgds
__________________
David
UK mapping and map analysis services at www.broomanalysis.plus.com
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Spurl this Post!Reddit! Wong this Post!
Reply With Quote
  #5 (permalink)  
Old 07-27-2008
Junior Member
White Belt
 
Join Date: Jul 2008
Posts: 3
Re: Calculate area of territory

Thank you David, this is just what I need many thanks.

Kind regards

Ludo
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Spurl this Post!Reddit! Wong this Post!
Reply With Quote
Reply

Tags
area, calculate, territory


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)

 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads

Thread Thread Starter Forum Replies Last Post
Show Postal code Area in existing territory file Rubinho MapPoint Desktop Discussion 4 05-31-2007 06:54 AM
Calculate miles of roads in an area? Anonymous MapPoint Desktop Discussion 0 12-02-2004 10:38 PM
Calculate distances Anonymous MapPoint Desktop Discussion 1 11-18-2004 10:58 AM
gettign teh area inside a polygon or territory Anonymous MapPoint Desktop Discussion 1 10-18-2003 05:21 PM
Calculate route Anonymous MapPoint Desktop Discussion 0 07-03-2003 02:25 AM


All times are GMT -5. The time now is 10:54 PM.


Powered by vBulletin® Version 3.8.6
Copyright ©2000 - 2010, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 3.5.0 RC3
MP2K Magazine
Visitor Map



1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70