How do I read the attribute data associated with my SHP?

المشرف العام

Administrator
طاقم الإدارة
I'm using DotSpatial to aid in processing some geospatial data. I'm using the code below to determine if a point (lat/lon location) is within a polygon contained in the SHP. If the point is in a polygon, I want some of the attributes stored in the DBF associated with the polygon. How do I access the attribute data?

// Reproject the strange shapefile so that it is in latitude/longitude coordinates wierdShapefile.Reproject(DotSpatial.Projections.KnownCoordinateSystems.Geographic.World.WGS1984); // Define the WGS84 Lat Lon point to test Coordinate test = new Coordinate(longitude, latitude); foreach (Feature f in wierdShapefile.Features) { Polygon pg = f.BasicGeometry as Polygon; if (pg != null) { if (pg.Contains(new Point(test))) { ****************************************** *** Need to access attribute data here *** ****************************************** // If the point is inside one of the polygon features return true; } } else { // If you have a multi-part polygon then this should also handle holes I think MultiPolygon polygons = f.BasicGeometry as MultiPolygon; if (polygons.Contains(new Point(test))) { return true; } } } return false; }

أكثر...
 
أعلى