Load Vector Data from a Shapefile
- 2 minutes to read
This document describes the basics of working with Shapefiles using the Map Control.
This subject consists of the following sections.
Overview
A Shapefile (Esri Shapefile) is a vector format that represents geographic data (e.g., rivers, lakes, and countries) using geometries (e.g., points, polylines, and polygons). Data in this format is usually stored in two files:
- a .shp file that contains data about geometries;
- a .dbf file that contains data associated with geometries 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 above country shapes) loaded from a Shapefile.
Load Shapefile Data
To load shapes from a Shapefile, do the following.
- Create a ShapefileDataAdapter object.
- Specify the path to a Shapefile using the FileDataAdapterBase.FileUri property.
- Assign the ShapefileDataAdapter object to the VectorItemsLayer.Data property.
When data is loaded from a Shapefile, the Map control generates a collection of vector item objects stored in a VectorItemsLayer.
Note
All data stored in a .dbf will be provided as attribute values for each vector item. This approach allows you, for instance, to use this data to colorize shapes or to display supplementary information in shape tooltips.
Examples
To learn how this can be done, see the How to: Load Data from a Shapefile example.