Tuesday, October 25, 2016

Modern Database Models and Technologies

A data models define how the logical structure of a database is modeled. Data Models are fundamental entities to introduce abstraction in a Database Management Systems
 (DBMS). According to WikiPedia, a database model is a type of data model that determines the logical structure of a database and fundamentally determines in which manner data can be stored, organized, and manipulated. The most popular example of a database model is the relational model, which uses a table-based format.

(Source: WikiPedia)

Thursday, October 20, 2016

Background Maps in QGIS

Hi there,

For any GIS task, you need a Basemap to kick start the GIS project. Basemaps are often presented through different GIServices in the form of: TMS, WMS, WMTS, ESRI ArcGIS Services or simply as XYZ tiles.

QGIS has different tools for adding basemaps.



If you need a background map tiles for your QGIS projects, then the two awesome options I do recommend you checkout are OpenLayer and QuickMapServices.

With any of the above plugins, you can import background basemaps in the form of satellite images, line maps, topographic maps, landsat images or combination of the two (hybrid maps) from any of the service providers listed below into your project:-

1) Google
2) Bing
3) OSM - Open Street Map
4) ESRI - ArcGIS Online
5) eAtlas
6) Yandex
7) NASA
8) CartoDB
9) MapQuest
10) MapBox
11) 2gis
12) MapSurfer
13) Apple Maps

You can find all these under QGIS web menu.




Happy mapping.

Monday, October 17, 2016

The new GUI Interface for PostgreSQL - pgAdmin4

Hello,

The eagerly awaited new version of pgAdmin 4 is finally here with features that are more flexible and reliable than its predecessor (pgAdmin 3).

pgAdmin is the leading graphical Open Source management, development and administration tool for PostgreSQL object relational database management system.

For a very long time pgAdmin has been on version 3 (pgAdminlll). However, just of recent (in October, 2016) it was upgraded to version 4 (pgAdmin4).

This new application (pgAdmin4) is designed for operation on both the desktop and a webserver. It is written in Python using the Flask framework for the backend, and Javascript/jQuery/Backbone for the frontend.

The core functionality of pgAdmin4 remains similar to pgAdmin3, but there are a number of changes made. Read more on Dave's blog.

To learn step-by-step how to install pgAdmin4 and also install PostGIS on it, check this link here.


Saturday, October 15, 2016

Number of rows in an SQLite database with python

Hello there,

In this post, I will demonstrate a common issue of concern when working with an SQLite database in python.

As you already know, SQLite database is powered in python with a default module name: sqlite3. You don't need to install this as it already comes with every python installations since python version 2.5.

To use SQLite database in python there are basically six steps to take as follow:-

Step 1: Import sqlite3 module
Step 2: Connect to a database
Step 3: Create a cursor object
Step 4: Write an SQL query
Step 5: Commit changes
Step 6: Close database connection

Getting to know the number of rows in an SQLite database with python


This could be easily determined by use any SQLite GUI browser like SQLiteStudio, DB Browser, Navicat or SQLite Firefox browser add-on. But there is drawback in using the GUI, as you have to install a tool on your working machine and it the dataset within the database in big, it will take some effort to scroll down the table just to know the number of rows in the table.

If you already working in python, this can easily be done with few lines of code as follow.



As you can see above, my database "flights.db" has 6048 rows in its "airlines" table.

You will need to change step 2 and 4 above to match your database name and table name respectively.


Thanks for reading.

Wednesday, October 12, 2016

Difference Between Spatial Database And Non-Spatial Database

Basically, a database consists of an organized collection of data for one or more uses, typically in digital form.

Spatial Database: has the ability to store and access both Location/Spatial Information and Attributes/Non-Spatial Information.

Non-Spatial Database: has the ability to store and access only Attributes/Non-Spatial Information.

The info-graphics below shows the difference in the concepts of Spatial and Non-Spatial databases.



Basically, the differences are in the storage, function, and query capabilities between the two. The notable differences are listed below;-

a)  A spatial database supports special data types for geometric objects and allows you to store geometric data (usually of a geographic nature) in tables while a non-spatial database doesn't support such.

b)  A spatial database provides special functions and indexes for querying and manipulating geospatial data using something like Structured Query Language (SQL) while non-spatial database doesn't provide such functions and indexes.

c)  A spatial database is often used as a storage container for geospatial data, but it can do much more than that. While non-spatial database is often used as a storage container for non-spatial data.

d)  A spatial database uses spatial query in geometric functions to answer questions about space and objects in space. While non-spatial database don't support spatial queries.

e)  In addition to being able to answer questions about the use of space, spatial database functions allow you to create and modify objects in space. This portion of spatial analysis is often referred to as geometric or spatial processing.

f)  A spatially enabled database can intrinsically work with data types like rivers (modeled as linestrings), land parcels (modeled as polygons), and trees (modeled as points). While non-spatial database can’t work with these forms of models.


Examples of Spatial and Non-spatial databases


There are several examples of Spatial and Non-spatial database servers available, but the top common once include:
a) SpatiaLite - SQLite
b) Oracle Spatial/Locator - Oracle
c) MySQL Spatial - MySQL
d) PostGIS - PostgreSQL
e) DB2 Spatial - IBM DB2/Informix
f) MsSQL Spatial - MsSQL server
g) Spatial Hadoop - Hadoop
h) MS Access - this is Non-spatial database, it has no support for Spatial database at the time of writing.

Note that Spatial databases are actually Non-spatial databases with spatial extension added onto them (I hope this makes sense). Anyway, study the pictures below, the first contains Non-spatial databases. After extending them with location/spatial capabilities, they then become Spatial databases.

Before getting location/spatial capabilities




After getting location/spatial capabilities



Thanks for reading.

Monday, October 3, 2016

Working with Spatial Database in QGIS and Python Part 1


Hello,
I will explain how to get up and running with PostGIS Database in QGIS and Python.

This blog post will be in series of three parts. This first part will give an overview and installation steps of PostGIS on the local windows machine. Then Part 2 and Part 3 will discuss on working with the PostGIS database server/engine in QGIS and Python respectively.

Lets get started...