While working with spatial databases loading data from another datasources could be problematic. Mostly SRID difference and attribute (field) mismatch need transformation before starting loading operation. I have wrote another post GeoKettle: Açık Kaynaklı Konumsal ETL Aracı about this subject.
As mentioned above, a few days ago i need to load some GIS data to Oracle Spatial. I have tried with QGIS by Copy Features (CTRL + C) and Paste Features (CTRL + V) but not succeed. Because attribute fields were not matched. So I tried with MapInfo’s Easy Loader tool and made it done. So I rolled up sleeves to make this operation done in QGIS. And I have developed Feature Loader. This plugin lets you load spatial data from one layer to another one by simple three click. It matches fields automatically and support all formats that QGIS support (Oracle, Postgis, Spatialite, SHP, TAB etc…).
I show you loading GIS data that comes from field works to Oracle Spatial table in this tutorial. I must mention; this plugin works with not only databases but also all file based formats (SHP, TAB, GDB etc.).
I assume that you connected to Oracle database and loaded the table (data to be loaded) to QGIS as a vector layer. And also add field works data to QGIS as another layer. Start Feature Loader and select the vector layer that comes from Oracle Spatial as Target Layer. And than select other layer as Source Layer. Sample screen shown below.
After selecting layers as Target and Source click Start button to load spatial features to Target Layer from Source layer. If you work with huge data it will take sometime so don’t be impatient . After all an information window appears. Ok, that’s all.
Loading Attribute Fields
Feature Loader detects attribute fields that matched by name between Target and Source layer. And only includes matched fields to the loading operation. The sample fields and matched ones shown below.
- Target and Source source layers must be same geometry.
- Both layers (Target-Source) must be in same SRS. I didnt add any control for different SRS. So you can load data that has incopatible SRS with target layer. But this could be error prone.
- When loading attributes Feature Loader matches them by field name. For example Target Layer has fields like ID, AD,SEVIYE. And Source layer has fields like ID, AD, CINS. So matched fields will be ID and AD.
- When working with database layers, PRIMARY KEY colums wont be loaded any value. For example a Target layer (database layer) has PKUID or ID column and it is PRIMARY KEY. This column wont be loaded any value even if matched with Source layers fields. Otherwise database will give error message.
- When working with database layers that have UNIQUE or NOT NULL colums do not try to violate these constraints. For example Target layer has a column name CINS with NOT NULL constraint. And Source layer has no column thar named CINS. So this colum will be NULL in case of loading new features and will give error when trying to save.
- If there are no matched attribute fields between Target and Source layers, only geometry will be loaded.