Provide Cartesian Data to a Geographical Map

  • 2 minutes to read

This document describes how to load Cartesian coordinate data onto a geographical map. The document consists of the following sections.

Overview

The CoordinateSystemDataAdapterBase class descendants allow you to provide both Cartesian and geographical map data. To specify which kind of data the adapter should provide, customize the CoordinateSystemDataAdapterBase.SourceCoordinateSystem property.

By default, this property is set to GeoSourceCoordinateSystem and to load Cartesian data, assign an CartesianSourceCoordinateSystem object to this property.

CoordinateSystems

Load Coordinate System from the *.PRJ File

If your data contains the *.PRJ file and this file is located in the same directory and has the same name as a shapefile, the coordinate system will be loaded automatically. Otherwise, if the paths or the names are different, call the ShapefileDataAdapter.LoadPrjFilemethod to load coordinate system metadata.

The following code demonstrates how to load the projection information using the LoadPrjFile method.

data.Add(new MapData() {
    Name = "LoadPrjFile( ) calling loaded coordinate system",
    FileUri = new Uri(baseUri, "../../Shapefiles/Lambert/Belize.shp"),
    CoordinateSystem = ShapefileDataAdapter.LoadPrjFile(new Uri(
        baseUri,
        "../../Shapefiles/Lambert/Projection.prj"))
});

The following image demonstrates the result.

LoadPrjFime

Specify Coordinate Converter Manually

If your data does not contain a *.PRJ file, it is possible to customize a Cartesian coordinate system manually. To do this, create a CartesianSourceCoordinateSystem object, and specify its CartesianSourceCoordinateSystem.MeasureUnit and SourceCoordinateSystem.CoordinateConverter properties. Then, assign the object to the CoordinateSystemDataAdapterBase.SourceCoordinateSystem property.

The following code demonstrates this customization.

new MapData() {
    Filepath = "../../Shapefiles/TransverseMercator/israel.shp", 
    CoordinateSystem = new CartesianSourceCoordinateSystem() {
        CoordinateConverter = new UTMCartesianToGeoConverter() {
            UtmZone = 36, Hemisphere = Hemisphere.Northern
        }
    }
},

The following image demonstrates the result.

ManuallyLoadedCS

See Also