---
title: "Memasang Spatialite"
version: 1.9
locale: id
source: https://docs.djangoproject.com/id/1.9/ref/contrib/gis/install/spatialite/
canonical: https://djangodocs.dev/id/1.9/ref/contrib/gis/install/spatialite/
---
# Memasang Spatialite

[SpatiaLite](https://www.gaia-gis.it/fossil/libspatialite) adds spatial support to SQLite, turning it into a full-featured
spatial database.

First, check if you can install Spatialite from system packages or binaries.

For example, on Debian-based distributions, try to install the
`spatialite-bin` package. For distributions that package SpatiaLite 4.2+,
install `libsqlite3-mod-spatialite`.

Untuk Mac OS X, ikuti [instructions below](#spatialite-macosx).

Untuk Windows, anda mungkin menemukan biner pada halaman rumah  [Gaia-SINS](http://www.gaia-gis.it/gaia-sins/).

In any case, you should always be able to [install from source](#spatialite-source).

> **Pengaturan SPATIALITE_LIBRARY_PATH dibutuhkan untuk SpatiaLite 4.2+**
>
> Jika anda menggunakan SpatiaLite 4.2+, anda harus menaruh ini dalam pengaturan anda:
>
> ```
> SPATIALITE_LIBRARY_PATH = 'mod_spatialite'
> ```

## Memasang dari sumber

[GEOS and PROJ.4](/id/1.9/ref/contrib/gis/install/geolibs/) harus dipasang sebelum membangun SpatiaLite.

### SQLite

Periksa pertama jika SQLLite disusun dengan [R\*Tree module](https://www.sqlite.org/rtree.html). Jalankan antarmuka baris perintah sqlite3 dan masukkan permintaan berikut:

```
sqlite> CREATE VIRTUAL TABLE testrtree USING rtree(id,minX,maxX,minY,maxY);
```

Jika anda mendapatkan sebuah kesalahn, anda akan harus menyusun kembali SQLite dari sumber. Jika tidak, cukup lewati bagian ini.

Untuk memasang dari sumber, unduh arsip sumber penggabungan terakhir dari [SQLite download page](https://www.sqlite.org/download.html), dan ekstrak:

```
$ wget https://sqlite.org/sqlite-amalgamation-3.6.23.1.tar.gz
$ tar xzf sqlite-amalgamation-3.6.23.1.tar.gz
$ cd sqlite-3.6.23.1
```

Next, run the `configure` script -- however the `CFLAGS` environment variable
needs to be customized so that SQLite knows to build the R\*Tree module:

```
$ CFLAGS="-DSQLITE_ENABLE_RTREE=1" ./configure
$ make
$ sudo make install
$ cd ..
```

### Pustaka SpatiaLite (`libspatialite`)

Get the latest SpatiaLite library source bundle from the
[download page](http://www.gaia-gis.it/gaia-sins/libspatialite-sources/):

```
$ wget http://www.gaia-gis.it/gaia-sins/libspatialite-sources/libspatialite-4.1.0.tar.gz
$ tar xaf libspatialite-4.1.0.tar.gz
$ cd libspatialite-4.1.0
$ ./configure
$ make
$ sudo make install
```

> **Note**
>
> For Mac OS X users building from source, the SpatiaLite library *and* tools
> need to have their `target` configured:
>
> ```
> $ ./configure --target=macosx
> ```

## Mac OS X-specific instructions

To install the SpatiaLite library and tools, Mac OS X users can choose between
[KyngChaos](#kyngchaos) and [Homebrew](http://brew.sh/).

### KyngChaos

Pertama, ikuti perintah dalam bagian [KyngChaos](#kyngchaos).

When creating a SpatiaLite database, the `spatialite` program is required.
However, instead of attempting to compile the SpatiaLite tools from source,
download the [SpatiaLite Binaries](http://www.gaia-gis.it/spatialite-2.3.1/binaries.html) for OS X, and install `spatialite` in a
location available in your `PATH`.  For example:

```
$ curl -O http://www.gaia-gis.it/spatialite/spatialite-tools-osx-x86-2.3.1.tar.gz
$ tar xzf spatialite-tools-osx-x86-2.3.1.tar.gz
$ cd spatialite-tools-osx-x86-2.3.1/bin
$ sudo cp spatialite /Library/Frameworks/SQLite3.framework/Programs
```

Finally, for GeoDjango to be able to find the KyngChaos SpatiaLite library,
add the following to your `settings.py`:

```
SPATIALITE_LIBRARY_PATH='/Library/Frameworks/SQLite3.framework/SQLite3'
```

### Homebrew

[Homebrew](http://brew.sh/) handles all the SpatiaLite related packages on your behalf,
including SQLite3, SpatiaLite, PROJ, and GEOS. Install them like this:

```
$ brew update
$ brew install spatialite-tools
$ brew install gdal
```

Finally, for GeoDjango to be able to find the SpatiaLite library, add the
following to your `settings.py`:

```
SPATIALITE_LIBRARY_PATH='/usr/local/lib/mod_spatialite.dylib'
```
