ArcGIS <-> QGis. How to share data?

More frequently we have a cohabitation of ArcGis
with QGis. We keep ArcGis for heavy operations while
QGis is used for lighter work , even if QGis is quite capable of
assuming much more than that . Free , easier to handle, QGis  is more used for portable applications.
But there’s always the
possibility of sharing the data between these two
software
. Towork properly with ArcGis we use geodatabases, but
it
is not possible to access such data from QGis.
Therefore, we choose to export a shapefile that it is easily accessible
by both software . Except that this specific format,
available for more than 30 years does not pose many problems. In
this article, we will discuss, a quite unknown option, the use of
databases SpatiaLite databases, to communicate between both
software
.

If
you want , first of all, to know why it’s worth
using SpatiaLite instead of a shapefile, go directly
to the paragraph Why not a shapefile?
.
And
afterwards, return here.



With QGis, we have already discuss how to work
with SpatiaLite databases ( Tutorial
databases
SpatiaLite under QGis 2.8
Wien
). ArcGis uses may be surprised since the format SpatiaLite is well
supported
by ArcGis since version 10.2.

What is
SpatiaLite?

SpatiaLite is an Open Source Spatial Data
Management Project built above the SQLite
platform.
Here
is an excerpt from the Wikipedia SQLite article:

« 
SQLite is a relational database management system contained in a C
programming library and SQL language.
SQLite
implements in great
part of the SQL-92 standard and ACID properties
.

Unlike traditional
database servers, such as MySQL or PostgreSQL,
its main feature is to not reproduce
the usual client- server schema but
to be directly integrated into
programs.
The entire database (reports,
tables, indexes and
data) is stored
in an independent file of the platform .

D. Richard Hipp , the creator of
SQLite,
chose to put this
library and its source code in
the public domain, allowing unrestricted use as
well as
 the
open source
projects as proprietary
projects
.
The creator as well as part of the SQLite’s
main features developers are
employed by American Hwaci1society.

SQLite is the most distributed database
engine in the world, thanks to its use in many
consumer software such as Firefox,
Skype, Google Gears,
in some products
Apple, Adobe and McAfee and in many
standard
libraries languages like
PHP or Python. By
its
extreme lightness ( less
than 300 Kio2), it is also
very popular on board
systems,
including on most modern smartphones: iPhone
as well as the mobile operating
systems Symbian and Android use it as
an embedded database3 . In
total, we
can count over a billion
copies of
known and reported to the library
« ( see
full article
)

What to do to be able to use Spatialite?

NOTHING! There is no installation or
configuration. You can
create
and use databases Spatialite from
for
ArcGIS or QGis, without doing anything special .

How to create
a SpatiaLite database with ArcGis

We will use the Python console to create the database
SpatiaLite
.

Open the Python console by clicking on the icon

Firstly we will define
the name of the database to create ( argistest.sqlite ) in
a
variable ( sqlite_database )

Type the command next in
the window sqlite_database= ‘C: / qgis /arcgistest.sqlite

Then we create the
actual database with the following command:

a rcpy.gp.CreateSQLiteDatabase(sqlite_database, « SPATIALITY »)

The
database is
created
containing
all
the necessary tables and views for its management

Warning! The parameter
« SPATIALITY has to be in use
if
you
want
to communicate with QGis or any other software
. The other option, « ST_GEOMETRY » is
specific
to ArcGis and the geometry of the created tables will not be read by QGis or
the others software .
Now
that the base is created you
can
use
it in a standard way , with the catalogue window , to import data
in
the base.   

Why not a shapefile?

A demonstration is
better
that
a long speech , here is a small example grouping three reasons not to
use a shapefile as an intermediate format .

Here is a class
of
geodatabase entities. It contains 4 attributes :

Date_and_time_take , type DATE
3
fields of type float r esultat_xxx

The
same table after an export in shapefile
shows
:  

Find the difference !

1- The field names are truncated and modified .
Here we only have three fields, but when
he
there
are many, there find is
complicated
. On the other hand, if the shapefile must be
recovered
after treatment , for example after correction or updated
by users, you will have
to manually make the correspondence of each field in the shapefile with the
fields of the geodatabase.

2- The null values of the attributes digital
, indicating it there
is no measure , are processed in 0.
But 0 is a possible value of measurement
. You have no more way
of knowing if analysis n / A
find
no
trace of the product or if
analysis
did
not take place. This change is so
irreversible
.

3- Even if the field is called date
and time , you have only the date and you
have
lost the time . The sql version used
by dbf files ( those used in
shapefiles) supports only part day- month – year to date. Your
hours
and minutes are finally passed
to the trap, and this is irreversible .

The result of the import of
the class entity
in
a
SpatiaLite base :

Look again for the difference …

There is none!!

The fields keep their name, values
null are respected
, the date contains well time .

Those
-ci were only three examples of problems but he
there
are others . Why miss this solution?

In QGis there enough Now
right click on Spatialite, and connect the base created with ArcGIS.

You can then
load the layer in the window cartographic
, open the attribute table , etc …

Laisser un commentaire

Votre adresse de messagerie ne sera pas publiée. Les champs obligatoires sont indiqués avec *