How to load csv file instead of shape file

Please help, i want to load csv files using long lat coordinates… Thank you and God Bless!
I am using C#…

Hello @iTechProg, and welcome.

There are a couple ways this could possibly be accomplished, depending upon what you have and how it is best interpreted.

Beyond Shapefiles, we use the GDAL library for various data sources, and there is a CSV driver which may work for you. Please check it out.

The alternative is to write code to:

  1. Create a Shapefile (it can be either in-memory or disk-based)
  2. Iterate your CSV file, extracting the Lon/Lat values
    a. For each coordinate, create a point shape and add it to the Shapefile
  3. You may need to apply a projection to your Shapefile

Depending on your intentions, we can likely provide more details.


Hello sir @jerryfaust, thank you for your reply…
sir, can you please share your example on how to connect csv file using c# and MapWinGIS… Thank you and God bless!!!

Hello again.

I’m not sure what you’re looking for. I don’t have an example using the CSV driver, you would have to research that.

As far as a coding example, here’s a quick sample that you would have to fill in some details, but hopefully gets you started.

        Shapefile sf = new Shapefile();
        sf.CreateNew("CSVPoints", ShpfileType.SHP_POINT);
        // iterate your csv file, extracting x and y
        for(int i = 0; i < rowsInFile; i++)
            // get x and y from csv file, then add point
            double x, y;
            // create point Shape
            Shape shp = new Shape();
            shp.AddPoint(x, y);
            // add to Shapefile
        // presuming points are long and lat, the projection is likely WGS84
        axMap1.Projection = tkMapProjection.PROJECTION_WGS84;
        // add the layer to the map
        axMap1.AddLayer(sf, true);