Introductory knowledge of open source library OGR

1 Introduction

OGR is an open source code library for reading and processing GIS vector data. It can read and process a variety of popular vector data (such as ESRI's Shapefile, S-57, SDTS, PostGIS, Oracle Spatial, and Mapinfo's mid/mif and TAB formats)

2. OGR library installation

OGR is a supporting library of GDAL. It is a part of GDAL library. As long as you install GDAL library, you
already have OGR library. For the installation of gdal (python), you can refer to this blog .

3. OGR library data model

The OGR data model is based on the OpenGIS standard. Looking at the OGR class structure, its main classes are shown below.

  • Geometry
  • SpatialReference
  • Feature
  • FeatureDefn
  • Layer
  • DataSource
  • Driver

4. Introduction to Geometry

Geometry refers to geometric shapes. This class contains vector data models (defined by OGC related standards), related geometric operations, and data import and export (wkb/wkt format) functions. It is worth noting that Geometry also contains spatial reference system (projection) information. The inheritance diagram of its class is as follows:
Insert picture description here
From the class result diagram in the above figure, all Geometry classes are inherited from OGRGeometry. OGRGeometry defines some common operations that support all Geometry shapes. Geometry types include point (OGRPoint), line (OGRLineString), polygon (OGRPolygon), geometric shape collection (OGRGeometryCollection), point collection (OGRMultiPoint), line collection (OGRMultiLineString) and polygon collection (OGRMultiPolygon).

5. Introduction to SpatialReference

SpatialReference is the spatial reference system, which is defined with reference to the relevant OGC standards, including geographic coordinate systems and projected coordinate systems. The spatial reference data model uses the WKT format of OpenGIS. At the same time, you can use PROJ.4 (another open source code library) to convert between coordinate systems.

6. Feature introduction

Feature is a feature, which includes geometric objects (Geometry) and feature attributes. The attributes of a feature set or field can be read through the OGRFeatureDefn class. Among them, FID is the unique identifier of the feature in the layer, and a feature generally corresponds to a row in the attribute table.

7. Layer introduction

Layer is the layer. The OGRLayer in OGR is composed of features of the same type and has the same coordinate system, which is equivalent to FeatureClass in ArcGIS. The OGRLayer class encapsulates the methods for reading and creating features from the data source.

8. Introduction to DataSource

DataSource is a data source, composed of a series of layers (OGRLayer). OGRDataSource is an abstract
base class. This class cannot be instantiated like a general abstract class and needs to be combined with the OGRSFDriver. class.

9. Introduction to Drivers

Drivers, as the name implies, are drivers, which are used to instantiate the file formats supported by OGR and are
implemented in the OGRSFDriver class . The object of OGRSFDriver needs to be registered by OGRSFDriverRegistrar.

10. Summary

At this point, I believe that everyone has a preliminary understanding of OGR, and its functions are still very powerful, let's explore it yourself!

Guess you like

Origin blog.csdn.net/weixin_42990464/article/details/111416562