GDAL/OGR with OCI support on Linux
This is a second post of the Maps series. It describes how to build a GDAL/OGR tool.
GDAL - Geospatial Data Abstraction Library
GDAL is a translator library for raster and vector geospatial data formats that is released under an X/MIT style Open Source licence by the Open Source Geospatial Foundation. As a library, it presents a single raster abstract data model and vector abstract data model to the calling application for all supported formats. It also comes with a variety of useful command line utilities for data translation and processing.
In a nutshell, GDAL/OGR is a library and a set of command line tools for manipulating geodata. It is used as a library in many products or can be used standalone for different purposes. I'm going to use ogr2ogr tool for importing Open Street Maps .pbf files into Oracle Spatial.
This tool is distributed in source codes and you need to build it before use. While this procedure is quite simple, I haven't found a complete guide for building it with OCI and PBF support on Linux platform.
At the time of writing this post, the current version is 2.0.2. You can get actual sources here
Download the source code.
Unpack it.
Change directory to the unpacked sources.
Run ./configure command.
Depending on your machine and which packages are installed you can get another result. I use freshly installed Oracle Linux 6 VM for this gude. You need to check these positions:
- Expat support
- OCI support
- SQLite support
Expat and SQLite libraries can be easily installed with yum (or other package managers). We need to install both library and -devel packages.
Now
./configure
should show that we have expat and SQLite libraries. But no OSI support yet.
For building GDAL/OGR with OCI support, we need to download and install Oracle Database Client. You need at least Runtime install type. Instant client is not enough.
Update: See info from John A Stevenson about using Oracle Instant Client below in the comments section.
Define
ORACLE_HOME
variable. If you don't do it, the compiler won't see your newly installed database client.
Run
./configure
once again. You could see that all required options are "yes" for this time. If something of these three options is "no" you should resolve the issue before proceeding.
If everything is OK you may run
make
. It takes a few minutes to complete.
And the last step -
make install
(sudo make install
).
Now your tools are located in the
/usr/local/bin
directory (you could change it with --prefix
option of the configure commnad).
And configuration files are located in the /usr/local/share/gdal directory.
I'm going to use
ogr2ogr
program. A small test.
The file I'm going to use contains non-English characters, so I need to define
NLS_LANG
environment variable. It looks like the only important part is a character set (UTF8).
The basic syntax for ogr2org is the following:
This is the basic syntax, and it's likely that a big pbf file won't import with the default options
org2ogr -f OCI OCI:username/password@tnsalias filename
It looks like that only tnsalias is supported. I haven't managed to get work EZ-connect syntax.This is the basic syntax, and it's likely that a big pbf file won't import with the default options
It's possible that we get some warnings. I see no impact of this warning on the result so simply ignore it.
Now we can open schema and see what was created. There are five tables for different types of data:
LINES
, ULTILINESTRINGS
, MULTYPOLYGONS
, OTHER_RELATIONS
and POINTS
.
We can preview data using Oracle Mapbuilder by now. It's OK that it look ugly. Later I'll show how to make it look good.
In the next post I'm going to show
osmconf.ini
file and some basic options for importing big data files.Andrew Fomin
OBIEE specialist since 2007 and Oracle Discoverer before. DWH architect, BI enthusiast, blogger. Lazy cats owner. All opinions are my own and not the views of my employer.
Additional Posts
Share This Post
Like
Closed discussion
ليست هناك تعليقات:
إرسال تعليق