How to get the area (as a double) from a ShapefileFeatureTable?

143
5
Jump to solution
05-16-2020 02:24 PM
Erick_CamiloMorris_Duarte
New Contributor II

Hi, I need to get the area from a shapefile, this has the area in its attribution table, but I need it as a double.

I've tried to convert the shapefile into a graphic but I don't know-how. This in order to work with the graphic library and calculate the areas. 
Thanks!

Erick Morris

Student of petroleum engineer.

Reply
0 Kudos
1 Solution

Accepted Solutions
MortenNielsen
Esri Frequent Contributor

oh also just realized that your where clause will probably mean you don't get any features back, as the where clause looks for rows that's returns true on that expression.  Try setting the WhereClause to "1=1" which would make all rows match the filter and you get them all back.

If your dataset also have an AREA attribute (like your screenshot seem to indicate), you can read that using

feature.Attributes["AREA"]

View solution in original post

5 Replies
MichaelBranscomb
Esri Frequent Contributor

Hi,

A Shapefile is a collection of features, which means you might be asking one of several questions depending on what you're trying to achieve.

- The area of each individual feature?

- The combined area values of all features?

- The area of the rectangular extent encompassing all features?

The area of the smallest polygon encompassing all features?

In all cases above you should be able to follow sample arcgis-runtime-samples-dotnet/src/WPF/ArcGISRuntime.WPF.Viewer/Samples/Data/FeatureLayerQuery at mas...  and use ShapefileFeatureTable instead of the ServiceFeatureTable.

Thanks

Mike

Erick_CamiloMorris_Duarte
New Contributor II

Hi Mike, thanks for replying. Yes I understand you, 1 Shapefile has just 1 feature, I just need the area of that feature.
And also I need the Sum of all the areas from another shapefile, Thanks for the advice! any news I'll post right here.

Reply
0 Kudos
Erick_CamiloMorris_Duarte
New Contributor II

Michael, I've tried to display the area of the feature, but I don't get anything, the following is the code that I've been using:

Also, here is the attribute table of the shapefile:

Reply
0 Kudos
MortenNielsen
Esri Frequent Contributor

Have you tried using GeometryEngine.AreaGeodetic(feature.Geometry) ?

Reply
0 Kudos
MortenNielsen
Esri Frequent Contributor

oh also just realized that your where clause will probably mean you don't get any features back, as the where clause looks for rows that's returns true on that expression.  Try setting the WhereClause to "1=1" which would make all rows match the filter and you get them all back.

If your dataset also have an AREA attribute (like your screenshot seem to indicate), you can read that using

feature.Attributes["AREA"]

View solution in original post