I have a .csv file of coordinates such as the following:

-90.19, 38.62, St Louis
-122.42, 37.82, San Francisco
-74.04, 40.68, New York

I want to create a shapefile using DotSpatial that has these points, so that I can overlay them on a shapefile of the United States. Which functions in DotSpatial would I provide these points to, to generate a shapefile?

I don't use this library, however you can write a similar code:

            string[] csv = new string[] { "-90.19, 38.62, St Louis", "-122.42, 37.82, San Francisco", "-74.04, 40.68, New York" };

            using (FeatureSet features = new FeatureSet(FeatureType.Point))
                features.CoordinateType = CoordinateType.Regular;
                features.Filename = @"c:\temp\test1.shp";
                features.Projection = ProjectionInfo.FromProj4String(KnownCoordinateSystems.Geographic.World.WGS1984.ToProj4String());
                DataColumn dt = features.DataTable.Columns.Add("City", typeof(string));
                int idxColumn = dt.Ordinal;
                foreach (var row in csv) 
                    string[] s = row.Split(',');
                    IBasicGeometry g = new Point(Convert.ToDouble(s[0], CultureInfo.InvariantCulture), Convert.ToDouble(s[1], CultureInfo.InvariantCulture));
                    IFeature f = features.AddFeature(g);
                    DataRow dr = f.DataRow;
                    dr.SetField<string>(idxColumn, s[2].Trim());


closed as off-topic by PolyGeo Jun 2 '16 at 9:47

This question appears to be off-topic. The users who voted to close gave this specific reason:

  • "Questions seeking help to debug/write/improve code must include the desired behavior, a specific problem or error and the shortest code necessary to reproduce it in the question itself. Providing a clear problem statement and evidence of a code attempt will help others to help you. See: How to create a Minimal, Complete, and Verifiable example." – PolyGeo
If this question can be reworded to fit the rules in the help center, please edit the question.

  • 1
    Looking at the DotSpatial documentation provides a few samples to do just this...I could copy and past the code but that would be cheating :-) And, you wouldn't see the rest! See Dotspatial Sample Code Have fun! – WolfOdrade Feb 4 '11 at 23:47

Browse other questions tagged or ask your own question.