I'm using SharpMap 2.0, and I'm successfully loading a shapefile and parsing through it. The particular shapefile that I'm working with has about 700 polygons in it, and each of those polygons has meta data associated with it (the metadata is in the .DBF file).

How can I get at the metadata for each polygon? I'm not seeing any methods that allow access to this data...

I've searched Google, these forums and have pretty much exhausted my resources trying to figure this one out.

Any help would be greatly appreciated!


The geometry and attributes should be linked. If you already have the FeatureDataRow object then try getting attribute values with row["ATTRIBUTE_NAME"]

If you can't actually get a FeatureDataRow object have a look at the How do I return a set of feature attribute data from a click on a map? page, but you will need to use SharpMap.Data.Providers.ShapeFile rather than SharpMap.Providers.PostGIS

The following code shows how to get a set of features from a datasource:

  SharpMap.Geometries.Point p = mapImage1.Map.ImageToWorld(e.Location); //could be any point geometry
  FeatureDataSet ds = new FeatureDataSet();

  //example uses a map image, but this could be a layer generated with code
  mapImage1.Layers[0].DataSource.ExecuteIntersectionQuery(p.GetBoundingBox(), ds);
  FeatureDataTable dt = ds.Tables[0];
  FeatureDataRow row = dt.Rows[0];

Then you should be able to access values with row["ATTRIBUTE_NAME"]


If I understand your question you may not be looking fo rmetadata but attribute data. I am not familiar with sharpmap. but the data in the dbf is the attribute infomration. the oid is associated with each object and relates it to the shape , and the index (if it exists). In my software I simply select the layer name a right click to open attribute table I know in qgis it is a simiar process. The relationship is already established. Am I off base?

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.