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

[SpatiaLite](https://www.gaia-gis.it/fossil/libspatialite/index) menambah dukungan spasial untuk SQLite, merubah itu menjadi basisdata spasial penuh-fitur.

Pertama, periksa jika anda dapat memasang SpatiaLite dari paket-paket sistem atau biner.

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

Untuk macOS, ikuti instructions below1.

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

Dalam kasus apapun, anda harus selalu dapat untuk install from source 1.

## Memasang dari sumber

[GEOS and PROJ](/id/6.0/ref/contrib/gis/install/geolibs/) should be installed
prior to building SpatiaLite.

### SQLite

Check first if SQLite is compiled with the [R\*Tree module](https://www.sqlite.org/rtree.html). Run the sqlite3
command line interface and enter the following query:

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

If you obtain an error, you will have to recompile SQLite from source.
Otherwise, skip this section.

To install from sources, download the latest amalgamation source archive from
the [SQLite download page](https://www.sqlite.org/download.html), and extract:

```shell
$ wget https://www.sqlite.org/YYYY/sqlite-amalgamation-XXX0000.zip
$ unzip sqlite-amalgamation-XXX0000.zip
$ cd sqlite-amalgamation-XXX0000
```

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

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

### Pustaka SpatiaLite (`libspatialite`)

Dapatkan bundel sumber pustaka SpatiaLite dari [download page](https://www.gaia-gis.it/gaia-sins/libspatialite-sources/):

```shell
$ wget https://www.gaia-gis.it/gaia-sins/libspatialite-sources/libspatialite-X.Y.Z.tar.gz
$ tar xaf libspatialite-X.Y.Z.tar.gz
$ cd libspatialite-X.Y.Z
$ ./configure
$ make
$ sudo make install
```

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

## Petunjuk-petunjuk khusus-macOS

To install the SpatiaLite library and tools, macOS users can use [Homebrew](https://brew.sh/).

### Homebrew

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

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

Finally, for GeoDjango to be able to find the SpatiaLite library, set
the `SPATIALITE_LIBRARY_PATH` setting to its path. This will be within
your brew install path, which you can check with:

```console
$ brew --prefix
/opt/homebrew
```

Using this brew install path, the full path can be constructed like this:

```
SPATIALITE_LIBRARY_PATH = "/opt/homebrew/lib/mod_spatialite.dylib"
```
