GeoProjection.cs

This example demonstrates how to initialize GeoProjection object and retrieve an information from it. Here is a screenshot with the results of the code execution.

using System;
using System.Diagnostics;
using System.Windows.Forms;
using AxMapWinGIS;
using MapWinGIS;
namespace Examples
{
public partial class MapExamples
{
// <summary>
// Some operaions with GeoProjection object
// </summary>
public void GeoProjection(AxMap axMap1)
{
// EPSG code
proj.ImportFromEPSG(4326); // WGS84
// proj 4 string
proj.ImportFromProj4("+proj=longlat +datum=WGS84 +no_defs"); // WGS84
// autodetect the format
string unknown_format = "4326";
proj.ImportFromAutoDetect(unknown_format);
// from file
string filename = "some_name";
proj.ReadFromFile(filename);
// show the name of the loaded projection
Debug.Print("Projection loaded: " + proj.Name);
// show proj 4 representation
Debug.Print("Proj4 representation: " + proj.ExportToProj4());
// let's show the properties of the geographic projection
string s = "";
double[] arr = new double[5];
for (int i = 0; i < 5; i++)
{
// extract the parameter in element of val arr
proj.get_GeogCSParam((tkGeogCSParameter)i, ref arr[i]);
// append the name of parameter and the value to the string
s += (tkGeogCSParameter)i + ": " + arr[i] + Environment.NewLine;
}
MessageBox.Show("Parameters of geographic coordinate system: " + Environment.NewLine + s);
}
}
}
tkGeogCSParameter
The list of parameters of the geographical coordinate system.
Definition: Enumerations.cs:629
Map component for visualization of vector, raster or grid data.
Definition: AxMap.cs:56
Holds information about coordinate system and projection of the data.
Definition: GeoProjection.cs:98
string Name
Returns the name of the coordinate system.
Definition: GeoProjection.cs:262
bool ImportFromAutoDetect(string proj)
Initializes geoprojection from the input string of arbitrary format.
Definition: GeoProjection.cs:153
bool get_GeogCSParam(tkGeogCSParameter Name, ref double pVal)
Gets specified parameter of the geographic coordinate system.
Definition: GeoProjection.cs:382
bool ImportFromProj4(string proj)
Initializes geoprojection object from proj4 format.
Definition: GeoProjection.cs:183
bool ReadFromFile(string Filename)
Initializes geoprojection from the specified file.
Definition: GeoProjection.cs:282
bool ImportFromEPSG(int projCode)
Initializes geoprojection object from EPSG numeric code.
Definition: GeoProjection.cs:163
string ExportToProj4()
Exports information to the proj4 format.
Definition: GeoProjection.cs:114