Map data can be available in different formats like KML, GeoTiff, GeoJSON, Shapefile, etc. There might be situations where you need to render the map data as BMP images. For that, this article will teach you how to render map data in BMP format using C#.
- C# API for Rendering Map to BMP Format
- Render Map to BMP Format using C#
- Rendering Map to Specific Projection using C#
- Add Marker with Custom Style using C#
C# API for Rendering Map to BMP Format
We will use the Aspose.GIS for .NET API to render maps to BMP format. It is an API that supports working with geospatial data stored in various file formats. It also provides the ability to render maps and create, read, and convert geographic data without any additional software. You can either install the API through NuGet or download it directly from the Downloads section.
PM> Install-Package Aspose.GIS
Render Map to BMP Format using C#
The following are the steps to render maps to BMP format.
- Create an instance of the Map class.
- Create a vector layer from the shapefile and add it to the map.
- Render the map as a BMP using the Map.Render(string outputPath, Renderer renderer) method.
The following sample code shows how to render a map to BMP format using C#.
Rendering Map to Specific Projection using C#
The following are the steps to render a map to a specific projection.
- Create an instance of the Map class.
- Create a vector layer from the shapefile and add it to the map.
- Set the map’s spatial reference system using the Map.SpatialReferenceSystem property.
- Save the map as a BMP image using the Map.Render(string outputPath, Renderer renderer) method.
The following sample code shows how to render a map to a specific projection using C#.
Add Marker with Custom Style using C#
The following are the steps to add a marker with custom style to a map.
- Create an instance of the Map class.
- Create an instance of the SimpleMarker class.
- Set the properties of the SimpleMarker object according to your requirements.
- Create a vector layer from the geojson file and add it to the map along with the markers.
- Save the map as a BMP image using the Map.Render(string outputPath, Renderer renderer) method.
The following sample code shows how to add a custom-style marker to a map using C#.
Get a Free License
In order to try the API without evaluation limitations, you can request a free temporary license.
Conclusion
In this article, you have learned how to render map data as BMP images using C#. Moreover, you have seen how to set the map projections and add markers with custom styling. Aspose.GIS for .NET is a robust API that provides a bunch of additional features for working with map data. You can explore the API in detail by visiting the official documentation. In case of any questions, please feel free to reach us at our free support forum.