I am trying to get the area of a feature within Bing Maps.
//Create Feature based upon Well Known Text you have stored in your database table Feature plotPolygon = new Feature(dr["property_wkt"].ToString()); //Set the field information for each plot polygon based upon what is stored in the database. plotPolygon.ColumnValues.Add("id", dr["property_id"].ToString()); plotPolygon.ColumnValues.Add("name", dr["property_name"].ToString());
//AreaBaseShape areaShape = (AreaBaseShape)selectedFeatures[0].GetShape(); //double area = areaShape.GetArea(GeographyUnit.DecimalDegree, AreaUnit.SquareKilometers);
AreaBaseShape abs = (AreaBaseShape)plotPolygon.GetShape(); //Map1.MapUnit double area = abs.GetArea(GeographyUnit.Meter, AreaUnit.Acres);
plotPolygon.ColumnValues.Add("area", area.ToString()); //Add the plot to the Plots Layer. propertyLayer.EditTools.Add(plotPolygon);
However the results are way off. My MapUnit is meters because I am using Bing.
What is the unit of the polygon that you want to get the area? The unit must match together to get the correct result. Could you please show me the wkt of the polygon and the result area you get?
I didn’t realize we had to set the unit of the polygon we create. I thought it was derived/calculated based on the current Map layer. How do you set the unit?
You don’t need to set the unit of polygon, the coordinates are just representing the values without unit, e.g. RectangleShape(-180, 90, 180, -90), it could represent Meter/Feet/DecimalDegree, it will return different values when the GeographyUnit is different in the method GetArea. I think your result is right, I used another areaUnit polygon.GetArea(GeographyUnit.Meter, AreaUnit.SquareMeters) and get the result 585191, as is known that 1 acre equals 4046 square meters, and 144.6 acres multiply 4046 is 585051.6, despite the accuracy, the results are matched. Could you please have check?
Oh that means you’ve confirmed your result with the website in your previous reply? Sorry I thought the web gave you a different result :). So, do you have any questions now?
In addition to that issue, do you know of a way that map suite can have the same kind of functionality that the daftlogic website gives for calculating the area in real-time as you draw.
I tested the shape with the web site you provided, and get the result as 84, but after I draw it on a bitmap, I calculate its area estimately, and get the area as 145, see the attached picture.
So I think there must be something wrong with the web site.
For you second question, you can refer to the sample HowDoISamples->MapShapes->TrackShapeFinishedEvent, there you can draw a shape you want and do anything you want to the feature you drew.
This is my property. The property is 82 acres. This is verified by the state of Virginia.
Using Google's measuring tools, your image is drastically off. support.google.com/maps/bin/answer.py?hl=en&answer=1628031
Using the same drawing you did, the width is 420 meters and the length is 618 meters for a total of 259,560 square meters. That is 64 acres. Of course the other 18 acres are on the outside of your rectangle.
The track shaped finished event is for when the shape is finished, right? I am asking if it is possible to show "real time area calculations" as I am drawing.
Now I know the root problem, the polygon is projected from decimal degree right? If so, the area should have be changed when projecting, just like the Russia looks much bigger in 900913 projection than that in 4326, so the only way to get the accurate area is converting the polygon back to decimal degree unit, in your case you can do it like this,