title: Adding point geometries to shapefile in GDAL (C#)
body: <p>I am trying to make shapefiles with point geometries using GDAL. I am following the example given <a href="https://trac.osgeo.org/gdal/browser/trunk/gdal/swig/csharp/apps/createdata.cs" rel="nofollow noreferrer">here</a>. I am using Microsoft Visual Studio and the programming language is C#. For now, I am just making one point at the origin and I'm viewing the resulting shapefiles in QGIS. For some reason, I am not being able to view the point which I make. I have tried making a polygon too but I am facing the same problem. Below is the code I have written:</p>
  
  <pre><code>        public void testSF(Dataset ds)
          {
          Console.WriteLine("Writing ERSI shapefile");
          // Registering drivers
          OSGeo.OGR.Ogr.RegisterAll();
          OSGeo.OGR.Driver driverSH = OSGeo.OGR.Ogr.GetDriverByName("ESRI Shapefile");
  
          if (driverSH == null)
          {
              Console.WriteLine("Cannot get drivers. Exiting");
              System.Environment.Exit(-1);
          }
          Console.WriteLine("Drivers fetched");
  
          // Creating a shapefile
          OSGeo.OGR.DataSource dataSourceSH = driverSH.CreateDataSource("ERSI_TEST_ShapeFile.shp", new string[] { });
          if (dataSourceSH == null)
          {
              Console.WriteLine("Cannot create datasource");
              System.Environment.Exit(-1);
          }
          Console.WriteLine("Shapefile created");
  
          // Creating a point layer
          OSGeo.OGR.Layer layerSH;
          layerSH = dataSourceSH.CreateLayer("PolygonLayer", null, OSGeo.OGR.wkbGeometryType.wkbPoint, new string[] { });
          if (layerSH == null)
          {
              Console.WriteLine("Layer creation failed, exiting...");
              System.Environment.Exit(-1);
          }
          Console.WriteLine("Polygon Layer created");
  
          // Creating and adding attribute fields to layer
          OSGeo.OGR.FieldDefn fdefnName = new OSGeo.OGR.FieldDefn("Name", OSGeo.OGR.FieldType.OFTString);
          fdefnName.SetWidth(32);
  
          OSGeo.OGR.FieldDefn fdefnGPS = new OSGeo.OGR.FieldDefn("GPS", OSGeo.OGR.FieldType.OFTString);
          fdefnGPS.SetWidth(32);
  
          if (layerSH.CreateField(fdefnName, 1) != 0)
          {
              Console.WriteLine("Creating Name field failed");
              System.Environment.Exit(-1);
          }
  
          if (layerSH.CreateField(fdefnGPS, 1) != 0)
          {
              Console.WriteLine("Creating GPS field failed");
              System.Environment.Exit(-1);
          }
  
          Console.WriteLine("Fields created and added to layer");
          OSGeo.OGR.Feature featureSH = new OSGeo.OGR.Feature(layerSH.GetLayerDefn());
          featureSH.SetField("Name", "This is a NAME");
          featureSH.SetField("GPS", "Test GPS point");
  
          // Outer Ring 
          // Methodology: Create a linear ring geometry, add it to a polygon geometry. Add polygon geometry to feature. Add feature to layer
  
          OSGeo.OGR.Feature feature = new OSGeo.OGR.Feature( layerSH.GetLayerDefn() );
          OSGeo.OGR.Geometry geom = OSGeo.OGR.Geometry.CreateFromWkt("POINT(0.0 0.0)");
  
          feature.SetGeometry(geom);
          layerSH.CreateFeature(feature);
  }
  </code></pre>
  
  <p>This code adds a point to the polygon layer at 0.0 and 0.0. However, when I open the resulting layer in QGIS, I can not see/locate the point. Any help would be appreciated.</p>