Vector Format Files
- 3 minutes to read
This document lists supported vector formats, and explains how to import and visualize data from these formats in a map control. The following vector formats are supported.
Shapefiles
A Shapefile (Esri Shapefile) is a vector format that represents geographic data (e.g., rivers, lakes, and countries) using geometric shapes (e.g., points, polylines, and polygons). Data in this format is usually stored in two files:
- a .shp file, which contains data about geometric shapes;
- a .dbf file, which contains data associated with geometric shapes from the corresponding .shp file.
Note
To learn more about the Shapefile format, refer to Shapefile (Wikipedia).
The image below illustrates country shapes, along with supplemental information (country names and GDP above country shapes) loaded from a Shapefile.
To load shapes from a Shapefile, do the following.
- Create a ShapefileReader object and assign it to the VectorFileLayer.FileReader property.
- Specify the path to a Shapefile using one of the MapFileSourceBase class descendant objects assigned to the MapFileReaderBase.FileSource property.
Note
Make sure the Build Action property of both shape files is set to Content.
When data is loaded from a Shapefile, the Map control generates a collection of vector items stored in a VectorFileLayer. Note that in this case, data from a .dbf file is stored as attributes in each vector item object. This approach allows you, for instance, to use this data to colorize shapes or display supplementary information in shape tooltips.
To learn how this can be done, see the How to: Load Vector Data from Shapefile topic.
KML
Using the Map control, you can load and depict any set of geographic visualization data (placemarks, polygons, images, textual descriptions, etc.) stored in the KML (Keyhole Markup Language) format. KML files have a tag-based structure with nested elements (similar to the XML standard).
Note
For more information, see the following link: KML Documentation (on developers.google.com).
One of the common usage scenarios for the KML format is to display vector data above an image tiles map. For instance, the image below shows the Liberty Island shape loaded from a KML file.
To load geographic data from a KML file, do the following.
- Create a KmlReader object and assign it to the VectorFileLayer.FileReader property.
- Specify the path to a KML file using one of MapFileSourceBase class descendant objects assigned to the MapFileReaderBase.FileSource property.
Note
Make sure the Build Action property of a KML file is set to Content.
To learn how this can be done, see the How to: Load Vector Data from a KML File topic.