Extract lat/long coordinates from a shapefile

Topics: SharpMap Project, General Topics
Apr 21, 2007 at 8:10 AM
Hi, is it possible to extract lat/long coordinates from a shapefile?
Thanks.
Apr 23, 2007 at 3:40 AM
i got the problem but not in this way , i need to point a lat,lon with a icon on the map
Apr 23, 2007 at 2:23 PM
Assuming you have a point shapefile, this is how you can dump out the x & y of each feature:

ShapeFile shapeFile = new ShapeFile("path_to_my_file");
shapeFile.Open();
FeatureDataRow feature;
Point pnt;
for (uint i = 0; i < shapeFile.GetFeatureCount(); ++i)
{
  feature = shapeFile.GetFeature(i);
  pnt = (Point)feature.Geometry;
  Console.Write("x={0}, y={1}", pnt.X, pnt.Y);
}
shapeFile.Close();

--
Abe Gillespie, abe@digital-pulp.com
Programmer for hire - GIS, Business Apps, Website Apps
http://code.google.com/p/ziggis/
Apr 24, 2007 at 2:44 PM
Ok, thanks! I'll try.
Jun 2, 2007 at 2:36 AM
hey,
you could extract shp file data to a database with this method. Nice.