Leveraging Kaggle for Free Geographical Data: A Guide to Integrating with PostGIS via QGIS
Tags: tabaqat, postgis, qgis, kaggle
Published: 2024-05-02 06:08:53

In today's data-driven world, access to quality geographical data is crucial for a wide range of applications, from urban planning to environmental monitoring. While obtaining such data may seem daunting, platforms like Kaggle offer a treasure trove of freely available datasets waiting to be explored. In this article, we'll walk through the process of acquiring real geographical data from Kaggle, loading it into QGIS as a CSV layer, and seamlessly integrating it with PostGIS for advanced spatial analysis.

### 1. Prepare Data from Kaggle Datasets:
   - Navigate to Kaggle Datasets (https://www.kaggle.com/datasets) and explore the vast collection of available datasets.
   - Use the search functionality to find geographical datasets relevant to your area of interest. Whether it's demographic data, transportation networks, or environmental parameters, Kaggle likely has what you need.
   - Select a dataset that suits your project requirements and download it in CSV format. Ensure that the dataset contains geographical attributes such as latitude and longitude or shapefiles for spatial analysis.

in this article we will use Riyadh Restaurants Dataset

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/kf2zgxo8p43liodq8wqu.png)

Then download it 

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/0zzy4iwfzeo6xlkmykl8.png)


![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/rg8x45vg36683ynbja7c.png)




### 2. Open QGIS and And Add your Basemap:
   - You can Access Tabaqat's free basemaps (https://platform.tabaqat.net/base-maps) to enhance the visual representation of your geographical data for Saudi Arabia within QGIS.
   - Tabaqat offers a variety of basemap styles, including street maps, satellite imagery, and terrain maps, enabling you to choose the most suitable backdrop for your analysis.
   - Integrate the Tabaqat basemap with your QGIS project to provide context to your geographical data and facilitate spatial interpretation.


![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/jivvyv2vrruz0yo3co0v.png)

Then Copy the WMTS URL Note **Optain your access_token by signing up and replace it on url before using it** for example

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/94yg7u5h5121gq25u49h.png)
https://basemaps.tabaqat.net/styles/bright-arabic-ksa-boundary/wmts.xml?access_token=YOUR-ASSESS-KEY => https://basemaps.tabaqat.net/styles/bright-arabic-ksa-boundary/wmts.xml?access_token=tabaqat-13uPaas5bdT6IW-xxxxxx

Then add the basemap to your QGIS Project 

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/eww6egkg00z2n9qckk24.png)


![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/ncbzh1v78xc96572e610.png)
Congrats

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/loekn3lbz0h83kvx8guj.png)





### 3. Add CSV as a Layer:
   - Launch QGIS, Create new project.
   - Use the 'Add Layer' button to import the CSV file you

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/rr6vavkl2mgkmhsx8b2g.png)

Navigate to the downloaded dataset in file name input and select your file


![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/lcqmpbgpwwyln8yuj70k.png)

Your Data is Ready 

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/se4dkjmpzv3qakz81376.png)



### 4. Load Data to PostGIS:
   - PostGIS, an extension of PostgreSQL, is a spatial database that allows for advanced storage, retrieval, and analysis of geographical data.
   - Before loading data into PostGIS, ensure that you have PostgreSQL and PostGIS installed on your system or you can Get Free PostGIS Hosted on the Cloud From SupaBase, check this article for more info: (https://dev.to/fady-shafeek/how-to-get-free-postgres-if8).


![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/5yo40vz5qh5hjzcnd3my.png)

then enter your credential and test the connection 

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/2dr04r6qpo15x11rbkth.png)

Now Drag and Drop Time!!

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/iej1aqmkfvfon5yknhlg.png)

Congrats your data imported to PostGIS Successfully!