Wednesday , November 20 2024

How to Install PostGIS in PostgreSQL 12

What is PostGIS in PostgreSQL?

It would not be wrong to say that PostGIS is an open source software program that supports geometrical features for object relational database.

We use PostGIS together with postgresql. Thanks to PostGIS, we can store the polygon, linestring and point types of the data in the database. We can say that Polygon symbolizes a certain region and linestring is a particular line segment between two locations.

We describe the PostGIS installation on PostrgreSQL 12 step by step below.

How to Install PostGIS in PostgreSQL 12?

Step1: Download RPM Packages

In the first step, we download RPM packages.

Step2: Enable PowerTool

Step3: Disable default PostgreSQL AppStream Repository

Step4: Install PostGIS

This will install PostGIS v2.5 for PostgreSQL 12.

Step5: Create Extensions

After the necessary installations are completed, let’s create EXTENTION now.

Step5: Check PostGIS Version

Let’s query the library versions it uses.

Examples

We start our examples by creating a table with an Id and Geometry column below.

Let’s add a column to the table_a table with the AddGeometryColumn function, which has a position of 4326 in the geographic coordinate named geo2 and will contain two-dimensional coordinates.

Create a point with the geomfromtext function

Create a point with the makepoint function and define projection with setsrid

Creating geometry from geojson

Creating geometry from kml

Create a line with the makeline

Create a polygon with makepolygon

Outputs geometry in wkt format

Outputs geometry in geojson format

Output in kml format

Projection information must be defined for kml

For PostGIS documentation ; https://postgis.net/stuff/postgis-2.5.pdf

Loading

About Yusuf KAHVECİ

Leave a Reply

Your email address will not be published. Required fields are marked *