The area of feature don't equal the value Shape.Area ?

2722
11
02-17-2014 12:04 AM
TaiBui
by
Occasional Contributor II
Hi everyone,

I used this statement to get the area value of polygon feature:

 while (pFeature != null)
     {
               
                IGeometry shapeCopy = pFeature.ShapeCopy;                                

                IArea area = pFeature.Shape as IArea;
                double value = area.Area; // Result is: 110102.807...
                  
       
                // ....
                pFeature = pFeatureCursor.NextFeature();
      }


But when showing the identify: The Shape.Area is: 20737.12 (not equal 110102.807). Please see the image:

[ATTACH=CONFIG]31505[/ATTACH]

Do you know what's wrong with it ?

Thanks and regards,

Tai
0 Kudos
11 Replies
SachinKanaujia
Occasional Contributor III
Can you validate the following information?

1) Are you looking at the correct features (for matching)? Can you print the FIDs or does it have just one feature?

2) Are you changing the coordinate reference system in any way?

3) When looking at the values in ArcMap is there any conversion mapping or unit change occurring?


Please provide some more of this information to help understand the problem !!
0 Kudos
TaiBui
by
Occasional Contributor II
Thanks Sachin,

Yes, it is the correct feature (polygon). But it contains many other features (polygons). So, I subtracted it the areas of sub features, but the final result doesn't equal the value: Shape.Area.

How can I get the area of that feature (not include area of sub features) ?

Please see my image (the current feature is green)

[ATTACH=CONFIG]31541[/ATTACH]

Thanks and regards,

Tai
0 Kudos
LeoDonahue
Occasional Contributor III
You need to set the spatial reference of your geometry object before calling the area method.

One thing you will notice about ArcObjects and the different data formats is that you get different area results for the same geometry, given the same projection.

Take that one geometry, and save it three ways:  shapfile, file geodatabase and in SDE if you have it.

Then use ArcMap to get the Area of that geometry, you might see different results.

Now, use ArcObjects to get the area of that same geometry from the three different file formats and you will see slightly different results again.
0 Kudos
SachinKanaujia
Occasional Contributor III
Will it be possible for you to export the data in a shapefile or the feature whose area you are calculating into a shapefile and upload it. Its difficult to understand how you are trying to accomplish it?

Also let me know what Spatial reference you are working in?
0 Kudos
TaiBui
by
Occasional Contributor II
Thank you.

I am reading features from CAD file (.dgn) then write to feature class in SDE.

I haven't set the SpatialReference for the geometries of these features before checking the area.

Could you tell me how to set it ?

Plese see my codes:

Type factoryType = Type.GetTypeFromProgID(
                 "esriDataSourcesFile.CadWorkspaceFactory");
 System.Object obj = Activator.CreateInstance(factoryType);

factory = obj as IWorkspaceFactory;
IFeatureWorkspace ftrWorkSpace = (IFeatureWorkspace)factory.OpenFromFile(strWorkSpace, 0);
IFeatureDataset pFeatureDataset = ftrWorkSpace.OpenFeatureDataset(strFileName);
IFeatureClassContainer pFeatureClassContainer = (IFeatureClassContainer)pFeatureDataset;
IFeatureClass pCadPolygon;
IFeatureCursor pFeatureCursor = pCadPolygon.Search(pQueryFilter, false);
if (pFeatureCursor == null)
         return false;

IFeature pFeature = pFeatureCursor.NextFeature();
while (pFeature != null)
{
      ......
}



Thanks and regards,

Tai
0 Kudos
LeoDonahue
Occasional Contributor III
If your data frame has a spatial reference defined, you can do something like this:

// Note: not actual code...
geometry.setspatialreference(the_active_view.getscreendisplay.getdisplaytransformation.getspatialreference)
0 Kudos
SachinKanaujia
Occasional Contributor III
1) What is your source file (dgn file) spatial reference? Does it have an associated spatialreference file or not?

validate the source spatial reference

IGeometry shapeCopy = pFeature.ShapeCopy;

Get the spatial reference from Geometry to see if it has a geometry.

2) Your feature class in destination (feature class in SDE) must be in some spatial reference? What is that?

3) If the source and destination Spatial references are not same you will see differences. You will have to ensure that the CRS definition is correct. Depending of the spatial reference of source and destination you will have to either set spatial reference of project the shape to the target spatial reference.
0 Kudos
TaiBui
by
Occasional Contributor II
Thank you,

The original dgn file haven't set coordinate system yet. Then I set it (same with projection system of SDE) as your say.

But, the area still not equal. So I am checking features again

I attached the project file for your refecence

Thanks and regards,

Tai
0 Kudos
isaacferrie
New Contributor
I am having this same type of problem.  If I run the geometry calculator in the table I do not get the same area as when I run the
shape.area@acres in a script.  They are close but they seem to be about .07 acres off.  How do I run a script so that it gets me the exact same output as the calculate geometry feature?

Thanks
0 Kudos