#include#include // Assume that we have opened a shapefile datasource and a layer // named "example_layer" is available in it. OGRLayer* layer = dataSource->GetLayerByName("example_layer"); // Get the first feature in the layer OGRFeature* feature = layer->GetFeature(0); // Set the value of the "name" attribute field to "John" feature->SetField("name", "John"); // Save the changes to the feature object layer->SetFeature(feature);
#includeIn both examples, we use the OGRFeature SetField function to set the values of attribute fields in a feature object. The function takes two arguments: the attribute field name (a string), and the attribute value (a string or a numeric value). We also use the OGR layer object's SetFeature function to save the changes to the feature object. The OGR library provides a set of C++ classes to work with various Geo-spatial Data formats. The library provides an implementation of the OpenGIS Simple Features Reference Implementation, which is used for handling vector data including points, lines, polygons, and more.#include // Assume that we have opened a shapefile datasource and a layer // named "example_layer" is available in it. OGRLayer* layer = dataSource->GetLayerByName("example_layer"); // Get the feature with ID=10 in the layer OGRFeature* feature = layer->GetFeature(10); // Set the value of the "age" attribute field to 25 feature->SetField("age", 25); // Save the changes to the feature object layer->SetFeature(feature);