---
title: "Memasang PostGIS"
version: 5.2
locale: id
source: https://docs.djangoproject.com/id/5.2/ref/contrib/gis/install/postgis/
canonical: https://djangodocs.dev/id/5.2/ref/contrib/gis/install/postgis/
---
# Memasang PostGIS

[PostGIS](https://postgis.net/) menambahkan dukungan obyek geografis pada PostgreSQL, merubah itu menjadi basisdata spasial. [GEOS](/id/5.2/ref/contrib/gis/install/geolibs/#geosbuild), [PROJ](/id/5.2/ref/contrib/gis/install/geolibs/#proj4) dan [GDAL](/id/5.2/ref/contrib/gis/install/geolibs/#gdalbuild) harus dipasang sebelum membangun PostGIS. Anda mungkin juga butuh pustaka-pustaka tambahan, lihat [PostGIS requirements](https://postgis.net/docs/postgis_installation.html#install_requirements).

The [psycopg](https://www.psycopg.org/psycopg3/) or [psycopg2](https://www.psycopg.org/) module is required for use as the database
adapter when using GeoDjango with PostGIS.

On Debian/Ubuntu, you are advised to install the following packages:
`postgresql-x`, `postgresql-x-postgis-3`, `postgresql-server-dev-x`,
and `python3-psycopg3` (x matching the PostgreSQL version you want to
install). Alternately, you can [build from source](https://postgis.net/docs/postgis_installation.html#install_short_version). Consult the
platform-specific instructions if you are on [macOS](/id/5.2/ref/contrib/gis/install/#macos) or [Windows](/id/5.2/ref/contrib/gis/install/#windows).

## Pasca-pemasangan

### Membuat basisdata spasial

PostGIS includes an extension for PostgreSQL that's used to enable spatial
functionality:

```shell
$ createdb  <db name>
$ psql <db name>
> CREATE EXTENSION postgis;
```

Pengguna basisdata harus super pengguna untuk menjalankan `CREATE EXTENSION postgis;`. Perintah berjalan selama pengolahan [`migrate`](/id/5.2/ref/django-admin/#django-admin-migrate). Sebuah cara lain adalah untuk menggunakan tndakan perpindahan dalam proyek anda:

```
from django.contrib.postgres.operations import CreateExtension
from django.db import migrations

class Migration(migrations.Migration):
    operations = [CreateExtension("postgis"), ...]
```

If you plan to use PostGIS raster functionality, you should also activate the
`postgis_raster` extension. You can install the extension using the
[`CreateExtension`](/id/5.2/ref/contrib/postgres/operations/#django.contrib.postgres.operations.CreateExtension) migration
operation, or directly by running `CREATE EXTENSION postgis_raster;`.

GeoDjango saat ini tidak mempengaruhi [PostGIS topology functionality](https://postgis.net/docs/Topology.html) apapun. Jika anda berencana untuk menggunakan fitur-fitur tersebut pada beberapa titik, anda dapat juga memasang tambahan `postgis_topology` dengan menerbitkan `CREATE EXTENSION postgis_topology;`.

### Mengelola basisdata

To administer the database, you can either use the pgAdmin III program
(Start ‣ PostgreSQL X ‣ pgAdmin III) or the SQL Shell
(Start ‣ PostgreSQL X ‣ SQL Shell). For example, to create
a `geodjango` spatial database and user, the following may be executed from
the SQL Shell as the `postgres` user:

```psql
postgres# CREATE USER geodjango PASSWORD 'my_passwd';
postgres# CREATE DATABASE geodjango OWNER geodjango;
```
