This example demonstrates how to calculate area of polygons and to set 3 ranges of categories with different symbology. This example demonstrates quite elaborate specification of categories. In most cases much easier approaches can be used (see ShapefileCategories.Generate). Here is a screenshot with the results of the code execution.
using System.IO;
using System.Windows.Forms;
using AxMapWinGIS;
using MapWinGIS;
namespace Examples
{
public partial class MapExamples
{
public void AddCategoryRange(
AxMap axMap,
string dataPath)
{
string filename = dataPath + "landuse.shp";
if (File.Exists(filename) == false)
{
MessageBox.Show(@"Failed to open file: " + filename);
return;
}
if (!sf.
Open(filename))
return;
{
MessageBox.Show(@"Failed to open editing mode.");
return;
}
int fieldIndex = sf.
Table.FieldIndexByName[
"Area"];
if (fieldIndex == -1)
{
double area = sf.Shape[i].Area * 100000.0;
}
double mean = sf.
Table.MeanValue[fieldIndex];
double stDev = sf.
Table.StandardDeviation[fieldIndex];
double min = (double)sf.
Table.MinValue[fieldIndex];
double max = (
double)sf.
Table.MaxValue[fieldIndex];
}
private void RestoreCategories(
AxMap axMap,
string dataPath)
{
string filename = dataPath + "landuse.shp";
if (!sf.
Open(filename))
return;
string description = "";
}
}
}
tkShapeElements
The elements of the symbology for a single shape with individual colors.
Definition: Enumerations.cs:1323
tkClassificationType
The type of the classification available for ShapefileCategories.Generate and Labels....
Definition: Enumerations.cs:227
tkMapColor
A list of named constants for some of the well-known colors.
Definition: Enumerations.cs:951
tkColorSchemeType
The type of color scheme. Determines how colors will be extracted from the color scheme (see Shapefil...
Definition: Enumerations.cs:305
tkFillType
The type of shape fill.
Definition: Enumerations.cs:521
FieldType
The available types of fields of dbf table.
Definition: Enumerations.cs:34
tkGDIPlusHatchStyle
The hatch style available for drawing of fill for polygons and point symbols.
Definition: Enumerations.cs:567
tkMapProjection
Commonly used map projections to be set in Form Designer (see AxMap.Projection property).
Definition: Enumerations.cs:1741
Map component for visualization of vector, raster or grid data.
Definition: AxMap.cs:56
void Redraw()
Redraws all layers in the map if the map is not locked.
Definition: AxMap.cs:183
Provides methods for random colour generation and colour interpolation based on the specific set of c...
Definition: ColorScheme.cs:65
tkGDIPlusHatchStyle FillHatchStyle
The hatch style of the fill for point symbols and polygon shapes.
Definition: ShapeDrawingOptions.cs:510
tkFillType FillType
The type of the polygon fill. See the enumeration for details.
Definition: ShapeDrawingOptions.cs:539
uint FillColor2
Gets or sets the end color of the gradient fill.
Definition: ShapeDrawingOptions.cs:481
void ApplyColorScheme3(tkColorSchemeType Type, ColorScheme ColorScheme, tkShapeElements ShapeElement, int CategoryStartIndex, int CategoryEndIndex)
Applies color scheme to the visualization categories.
Definition: ShapefileCategories.cs:118
bool AddRange(int FieldIndex, tkClassificationType ClassificationType, int numClasses, object MinValue, object MaxValue)
Creates the specified number of visualization categories and expressions for them.
Definition: ShapefileCategories.cs:84
void ApplyExpressions()
Maps shapes to the visualization categories based in ShapefileCategory.Expression.
Definition: ShapefileCategories.cs:143
Provides a functionality for accessing and editing ESRI shapefiles.
Definition: Shapefile.cs:72
int NumShapes
Gets the number of shapes in the shapefile.
Definition: Shapefile.cs:254
ShapeDrawingOptions DefaultDrawingOptions
Gets or sets an instance of ShapeDrawingOptions class which holds default drawing options.
Definition: Shapefile.cs:111
ShapefileCategories Categories
Gets or sets an instance of ShapefileCategories class associated with the shapefile.
Definition: Shapefile.cs:81
A utils object provides access to a set of utility functions to perform a variety of tasks on other o...
Definition: Utils.cs:20
uint ColorByName(tkMapColor Name)
Returns the numeric representation for the specified color.
Definition: Utils.cs:40
tkMapProjection Projection
Sets projection of the map. It providers 2 most commonly used coordinate system/projections to be eas...
Definition: AxMap.cs:2709
int AddLayer(object Object, bool visible)
Adds a layer to the map.
Definition: AxMap.cs:1342
Shapefile get_Shapefile(int layerHandle)
Gets shapefile object associated with the layer.
Definition: AxMap.cs:1546
bool SaveLayerOptions(int layerHandle, string optionsName, bool overwrite, string description)
Saves settings of the layer to the file.
Definition: AxMap.cs:896
bool LoadLayerOptions(int layerHandle, string optionsName, ref string description)
Applies to the layer a set of settings from file with the specified name.
Definition: AxMap.cs:868
bool Open(string shapefileName, ICallback cBack)
Opens shapefile from the disk.
Definition: Shapefile.cs:1430
int EditAddField(string name, FieldType type, int precision, int width)
Adds a field to the attribute table of the shapefile. The table must be in editing mode.
Definition: Shapefile.cs:708
Table Table
Gets the reference to the attribute table associated with the shapefile.
Definition: Shapefile.cs:677
bool EditCellValue(int fieldIndex, int shapeIndex, object newVal)
Sets the new value for particular cell in attribute table. The table must be in editing mode.
Definition: Shapefile.cs:633
bool StartEditingTable(ICallback cBack)
Opens editing mode for the attribute table.
Definition: Shapefile.cs:684