Nevron Open Vision Documentation
Diagram / Map / ESRI Shapefiles
In This Topic
    ESRI Shapefiles
    In This Topic

    The ESRI shapefile is a popular geospatial vector data format, which contains geographical data and is widely used by geographical information system (GIS) software. An ESRI shapefile typically has an "shp" file extension and contains information about the geometry of different geographical objects called features, for example country boundaries, rivers, cities and so on. It's accompanied by a a file in the dBase format (DBF file), which contains attributes for each shape. For example if the shapefile is about the countries in the world, the DBF file may contain information about the name, the area, the population and the GDP of each country.

    NOV Diagram provides support for importing of ESRI shapefile data through the NEsriMapImporter class. The shapefile data can come from a file on the disk, from a stream or from a resource embedded in your NOV application. To add ESRI shapefiles to the importer use the AddShapefile method of the ESRI map importer.

     Shapefile Properties

    The NEsriShapefile class exposes the following properties you can use to configure the way the shapes are imported in the drawing document and their behavior:

    • NameColumn - specifies the data column from the DBF file to use for naming of the diagram shapes created from the shapefile.
    • TextColumn - specifies the data column from the DBF file to use for labeling the diagram shapes created from the shapefile.
    • MinZoomPercent, MaxZoomPercent - specifies the zoom percent range in which the shapes imported from the shapefile should be visible. By default set to [0, Double.MaxValue], which means that the imported shapes are always visible no matter what the zoom level of the drawing page is.
    • MinTextZoomPercent, MaxTextZoomPercent - specifies the zoom percent range in which the text of the shapes imported from the shape file should be visible. By default set to [0, Double.MaxValue], which means that the text of the imported shapes is always visible no matter what the zoom level of the drawing page is. For example imagine you have a political map of the world and you want the country labels to appear when the user zooms the diagram to 50%. In this case all you have to do is to set the MinTextZoomPercent property of the shapefile to 50.
    Note that you should configure all properties of the shapefiles you want prior to calling the Import method of the map importer.
     Code Example

    The following piece of code demonstrates how to create an ESRI map importer, add a shapefile to it and import the shapes from the shape file to a drawing document:

    ESRI map import
    Copy Code
    // Create a map importer
    mapImporter = new NEsriMapImporter();
    
    // Add a shapefile
    NEsriShapefile countries = new NEsriShapefile(NResources.RBIN_Maps_countries_zip);
    countries.NameColumn = "name_long";
    countries.TextColumn = "name_long";
    countries.MinTextZoomPercent = 50;
    countries.FillRule = new NMapFillRuleRange("pop_est", NColor.White, new NColor(0, 80, 0), 12);
    mapImporter.AddShapefile(countries);
    
    // Read the map data
    mapImporter.Read();
    mapImporter.MapBounds = WorldBounds;
    
    // Import the map data
    mapImporter.Import(drawingDocument, page.Bounds);
    
    See Also