The OGR library is a C++ open source
library (and command-line tools) providing read (and sometimes write) access
to a variety of vector file formats
including ESRI Shapefiles, S-57, SDTS, PostGIS, Oracle Spatial, and Mapinfo
mid/mif and TAB formats.
The C API is generally easy
to call from other languages which allow call out to DLLs functions, such
as Visual Basic, or Delphi.
The OGR/PHP extension enables
PHP users to access the functionalities included in the OGR library.
This extension can be used as built-in PHP or as dynamic library (".dll"
on Windows or ".so" on Unix).
This extension was developed
and is currently being maintained by DM Solutions Group. Special thanks
go to Lars V. Nielsen and Hvenegaard & Meklenborg
for funding the initial development of this extension and allowing it to
remain open source.
The php_ogr.dll is located in /ms4w/Apache/php/extensions.
To verify that the OGR/PHP extension
was installed properly, check PHP's list of loaded extensions by clicking here.
If the PHP/OGR extension was successfully loaded,
you should see an "OGR" table stating that OGR support is enabled.
The C API documentation
was created using Doxygen and is part of the GDAL/OGR documentation.
In addition to OGR functions, four CPL functions for handling error are made
available to the user: CPLErrorReset, CPLGetLastErrorNo, CPLGetLastErrorMsg
and CPLGetLastErrorType. Information on these functions can be found
on this page.
Information and bug reporting
The firstname.lastname@example.org mailing list can
be used for discussion of development and user issues related to OGR and related
technologies. Subscriptions can be done, and archives reviewed
on the web.
There are a few examples showing
how to use the functions in the PHP/OGR extension module. Consult the
README_EXAMPLES.TXT in the /ms4w/apps/php_ogr/examples directory to get
more information on what is the purpose of each example.
Each example must be invoked
from the command-line.
Example: ./php -q ogr2tab.php
"ogr2ogr.php" shows mostly the
"ogr2tab.php" is accomplishing
the same operations as "ogr2ogr.php" but is concerned especially with the
MapInfo File format.
- Opening an existing data
source with a specific driver
- Creating a new data source
- Accessing a layer
- Creating a new layer
- Adding fields on a layer
- Getting features from a
- Creating new features on
- Testing capabilities of
a data source or a layer
mostly how to set a spatial filter and an attribute filter.
is accomplishing the same operations as "ogr_spatialfilter.php" but is used
exclusively with MapInfo File format.
"ogr_sql.php" demonstrates how
to build an SQL statement and apply an SQL request to a data source.
"ogr2tab_sql.php" is a copy
of "ogr_sql.php" and is concerned with the MapInfo File format.
the following items:
- Accessing a specific feature
by specifying a feature id
- Getting a field definition
- Getting a field name
- Setting a field value
- Getting a geometry from
- Setting a geometry to a
"ogr2tab_update.php" is a copy of "ogr_update.php" but is concerned with
the MapInfo File format.
"ogr_dump.php" shows the following
"ogr_write.php" demonstrates the
- Getting geometry components
from which geometry is built from, like point coordinates for a linestring,
linestring for a polygon and so on
- Getting geometry name
- Getting the number of geometry
"ogr_setgetfield.php" shows how
to get and to set field values of various types inside a feature.
- Accessing a specific layer
- Creating a new field definition
and assigning it to a layer
- Creating a new feature on
- Setting a field value
- Creating a new geometry
(point, linestring, polygon) and adding it to a feature