Represents GDAL/OGR vector datasource which may be represented by spatial database or file-based vector format. More… Represents GDAL/OGR vector datasource which may be represented by spatial database or file-based vector format. The class can be used to access various vector datasources supported by GDAL/OGR. Depending on driver, datasources may be represented by particular file formats ( ESRI Shapefile, MapInfo TAB, KML, etc) or spatial databases (PostGIS, Microsoft SQL Server, SpatiaLite, etc). See the full list of formats in GDAL documentation. An instance of OgrDatasource can’t be added to the map directly, but instances of OgrLayer class opened by its methods can. OgrDatasource encapsulates an instance of GDALDataset C++ class. Check its documentation to better understand what’s going on under the hood. Here is code sample which lists all layers available in PostGIS database. OgrDatasource and OgrLayer classes by default use UTF-8 string encoding to interact with underlying drivers. This applies to connection strings, layer names, SQL queries and error messages. This behavior can be changed by setting GlobalSettings.OgrStringEncoding property. The new setting will be used immediately by all existing and new objects. See details about string encoding in the documentation of particular OGR driver. SRID will be set to 0 if null or empty GeoProjection object is passed. See OgrDatasource.ImportShapefile for the details on creation options. Known issues: creation of layer in nonexistent schema in PostGIS databases completes successfully, yet the neither schema nor objects in it are visible afterwards. Use OgrDatasource.TestCapability(tkOgrDSCapability.odcDeleteLayer) to check whether functionality is supported by particular driver. Should be used for non-SELECT instructions which don’t return resulting set of rows. To select data use OgrDatasource.RunQuery instead. Resulting OgrLayer has no reference to OgrDatasource object, which can safely closed if it is no longer needed. In case of spatial databases layerName corresponds to name of the underlying table. However there can be some format specifics. For example name may include schema prefix and name of geometry column (in case there is more than one geometry column in the table). For example, ‘public.buildings(geom2)’ may correspond to ‘geom2’ column of table named ‘buildings’ in ‘public’ schema. Resulting layer has no reference to OgrDatasource object, which can safely closed if it is no longer needed. The list of available creation options can be found in GDAL on-line documentation or retrieved by calling OgrDatasource.get_DriverMetadata(tkGdalDriverMetadata.dmdLAYER_CREATIONOPTIONLIST). In addition MapWinGIS defines its own options: Depending on driver invalid geometries may be accepted in the datasource, but they may cause errors on trying to perform spatial queries against these layers later on. Usually some sort of SELECT query returning a set of rows with one or several geometry columns is expected here. Other types of SQL instructions will also be processed, however OgrDatasource.ExecuteSQL is recommended way to do it. Resulting layer has no reference to OgrDatasource object, which can safely closed if it is no longer needed. The following code builds 0.01 degree buffer zones around waterways layer extracted from database and displays both waterways and buffer layers on the map. st_buffer function is supported by PostGIS. See documentation of particular spatial database for list of supported functions and their arguments. Gets or sets a text string associated with object. Any value can be stored by developer in this property. Source.