Map Rendering to SVG, JPG, or PNG Image using C#

Map rendering

Map Rendering refers to making visual maps from geospatial data. You can render maps from KML, GeoJSON, GeoTIFF, as well as the Shapefile to different file formats. You can render maps to different image formats like PNG, SVG, JPG, etc. In this article, the following sections further elaborate the map rendering to images:

Map Rendering from a Shapefile to Images – C# API Installation

Aspose.GIS for .NET API lets you work with different geographical and geo-spatial file formats. You can render maps from supported file formats to SVG, PNG, and other file formats as per your requirements. Please configure the API by downloading it from the New Releases section, or you can use the following NuGet installation command on the package manager console.

PM> Install-Package Aspose.GIS

Render Map from Shapefile to SVG Programmatically using C#

You can render map from a shapefile to an SVG file with the following steps:

  1. Create a new instance of the Map class.
  2. Create a vector map layer and add it to the map.
  3. Render the map into a file.

The code below elaborates how to render a map from a Shapefile to SVG programmatically using C#;

Render Map from Shapefile to PNG Image Programmatically in C#

You can render map from a shapefile to raster image formats like PNG, JPG, BMP, etc. The following are the steps for rendering map from shapefile to PNG image:

  1. Initialize Map class object with dimensions.
  2. Create and add a vector map layer.
  3. Render the map to a PNG image.

The following code shows map rendering from Shapefile to PNG image programmatically using C#:

Custom Map Rendering with Advance Style using C#

You can customize the appearance of a map with advance feature styles. Please follow the steps below for custom map rendering:

  1. Initialize Map class object.
  2. Initialize SimpleFill for a simple polygon symbolizer.
  3. Open the layer from the input shapefile for reading.
  4. Render the map into a file.

The code below explains how to do custom map rendering with advanced style using C#:

Render Map from GeoTIFF format to SVG Programmatically using C#

You can render a map from GeoTIFF to SVG file with the following steps:

  1. Instantiate Map class object.
  2. Open the layer for reading using the driver for the GeoTIFF or TIFF format.
  3. Render map into a file.

The code snippet below demonstrates how to render map from GeoTIFF format to SVG programmatically using C#:

Get Free API License

You can evaluate the API with a Free Temporary License for testing the API without any limitations.

Conclusion

In this article, you have learned map rendering from shapefile or GeoTIFF format to SVG, or other raster image formats like PNG, JPG, TIFF, etc. You can explore other features of the API by visiting the Documentation. Please feel free to contact us via Free Support Forum in case of any queries.

See Also

Create KML File or Read its Features Programmatically using C#