USDAForestService / gdalraster

R Bindings to GDAL (Geospatial Data Abstraction Library)
https://usdaforestservice.github.io/gdalraster/
Other
41 stars 7 forks source link

`GDALVector`: add method `$setSelectedFields()`, alternative to `$setIgnoredFields()` #511

Closed ctoney closed 3 weeks ago

ctoney commented 3 weeks ago

GDAL API provides only OGRLayer::SetIgnoredFields() for reasons given in RFC 29.

GDALVector::setSelectedFields() sets the fields to include. Other than the specified fields will be ignored. This mimics the behavior of the -select argument in the ogr2ogr command line utility.

$setSelectedFields(fields)

' Set which fields will be included when retrieving features from the layer.

' The fields argument is a character vector of field names. Passing an

' empty string ("") for fields will reset to no ignored fields.

' See the $setIgnoredFields() method above for more information. The data

' source must provide IgnoreFields capability in order to set selected

' fields. Note that geometry fields, if desired, must be specified when setting

' selected fields, either by including named geometry field(s) or the special

' field "OGR_GEOMETRY" in the fields argument.

' No return value, called for side effects.

This PR also adds GDALVector::getFieldNames(), a convenience method as alternative to the list structure returned by getLayerDefn().

$getFieldNames()

' Returns a character vector of the layer's field names.