---
title: "Acuan API QuerySet GIS"
version: 6.0
locale: id
source: https://docs.djangoproject.com/id/6.0/ref/contrib/gis/geoquerysets/
canonical: https://djangodocs.dev/id/6.0/ref/contrib/gis/geoquerysets/
---
# Acuan API QuerySet GIS

## Pencarian Spasial

Pencarian spasial dalam bagian ini tersedia untuk [`GeometryField`](/id/6.0/ref/contrib/gis/model-api/#django.contrib.gis.db.models.GeometryField) dan [`RasterField`](/id/6.0/ref/contrib/gis/model-api/#django.contrib.gis.db.models.RasterField).

For an introduction, see the [spatial lookups introduction](/id/6.0/ref/contrib/gis/db-api/#spatial-lookups-intro). For an overview of what lookups are
compatible with a particular spatial backend, refer to the
[spatial lookup compatibility table](/id/6.0/ref/contrib/gis/db-api/#spatial-lookup-compatibility).

### Pencarian dengan raster

Semua contoh dalam acuan dibawah diberikan untuk bidang-bidang dan masukan geometri, tetapi pencarian dapat menggunakan cara sama dengan raster pada kedua sisi. Kapanpun pencarian tidak mendukung amsukan raster, masukan otomatis dirubah ke geometri dimana dibutuhkan menggunakan fungsi [ST\_Polygon](https://postgis.net/docs/RT_ST_Polygon.html). Lihat juga [introduction to raster lookups](/id/6.0/ref/contrib/gis/db-api/#spatial-lookup-raster).

Penghubung basisdata digunakan oleh pencarian dapat dibagi menjadi tiga kategori:

- Raster asli mendukung `N`: penghubung menerima raster secara asli pada kedua sisi dari pencarian, dan masukan raster dapat dicampur dengan masukan geometri.
- Dukungan raster timbal balik `B`: penghubung mendukung hanya raster jika kedua sisi dari pencarian menerima masukan raster. Data raster otomatis dirubah menjadi geometri untuk pencarian campuran.
- Dukungan perubahan geometri `C`. Pencarian tidak memiliku dukungan raster asli, semua data raster otomatis dirubah ke geometri.

Contoh-contoh dibawah menunjukkan SQL setara untuk pencarian dalam jenis berbeda dari dukungan raster. Pola sama berlaku pada semua pencarian spasial.

| Kasus | Cari | Setara SQL |
| --- | --- | --- |
| N, B | `rast__contains=rst` | `ST_Contains(rast, rst)` |
| N, B | `rast__1__contains=(rst, 2)` | `ST_Contains(rast, 1, rst, 2)` |
| B, C | `rast__contains=geom` | `ST_Contains(ST_Polygon(rast), geom)` |
| B, C | `rast__1__contains=geom` | `ST_Contains(ST_Polygon(rast, 1), geom)` |
| B, C | `poly__contains=rst` | `ST_Contains(poly, ST_Polygon(rst))` |
| B, C | `poly__contains=(rst, 1)` | `ST_Contains(poly, ST_Polygon(rst, 1))` |
| C | `rast__crosses=rst` | `ST_Crosses(ST_Polygon(rast), ST_Polygon(rst))` |
| C | `rast__1__crosses=(rst, 2)` | `ST_Crosses(ST_Polygon(rast, 1), ST_Polygon(rst, 2))` |
| C | `rast__crosses=geom` | `ST_Crosses(ST_Polygon(rast), geom)` |
| C | `poly__crosses=rst` | `ST_Crosses(poly, ST_Polygon(rst))` |

Pencarian spasial dengan raster hanya didukung untuk backend PostGIS (dinamai sebagai PGRaster dalam bagian ini).

### `bbcontains`

*Ketersediaan*: [PostGIS](https://postgis.net/docs/ST_Geometry_Contain.html), MariaDB, MySQL, SpatiaLite, PGRaster (Asli)

Coba jika geometri atau kotak pembatas bidang raster sepenuhnya mengandung pencarian kotak pembatas geometri.

Contoh:

```
Zipcode.objects.filter(poly__bbcontains=geom)
```

| Backend | Setara SQL |
| --- | --- |
| PostGIS | `poly ~ geom` |
| MariaDB | `MBRContains(poly, geom)` |
| MySQL | `MBRContains(poly, geom)` |
| SpatiaLite | `MbrContains(poly, geom)` |

### `bboverlaps`

*Ketersediaan*: [PostGIS](https://postgis.net/docs/geometry_overlaps.html), MariaDB, MySQL, SpatiaLite, PGRaster (Asli)

Coba jika kotak pembatas bidang geometri tumpang tindih pencarian kotak pembatas geometri.

Contoh:

```
Zipcode.objects.filter(poly__bboverlaps=geom)
```

| Backend | Setara SQL |
| --- | --- |
| PostGIS | `poly && geom` |
| MariaDB | `MBROverlaps(poly, geom)` |
| MySQL | `MBROverlaps(poly, geom)` |
| SpatiaLite | `MbrOverlaps(poly, geom)` |

### `contained`

*Ketersediaan*: [PostGIS](https://postgis.net/docs/ST_Geometry_Contained.html), MariaDB, MySQL, SpatiaLite, PGRaster (Asli)

Coba jika kotak pembatas bidang geometri sepenuhnya terkandung oleh pencarian kotak pembatas geometri.

Contoh:

```
Zipcode.objects.filter(poly__contained=geom)
```

| Backend | Setara SQL |
| --- | --- |
| PostGIS | `poly @ geom` |
| MariaDB | `MBRWithin(poly, geom)` |
| MySQL | `MBRWithin(poly, geom)` |
| SpatiaLite | `MbrWithin(poly, geom)` |

### `contains`

*Ketersediaan*: [PostGIS](https://postgis.net/docs/ST_Contains.html), Oracle, MariaDB, MySQL, SpatiaLite, PGRaster (Timbal balik)

Dicoba jika bidang geometri secara spasial mengandung pencarian geometri.

Contoh:

```
Zipcode.objects.filter(poly__contains=geom)
```

| Backend | Setara SQL |
| --- | --- |
| PostGIS | `ST_Contains(poly, geom)` |
| Oracle | `SDO_CONTAINS(poly, geom)` |
| MariaDB | `ST_Contains(poly, geom)` |
| MySQL | `ST_Contains(poly, geom)` |
| SpatiaLite | `Contains(poly, geom)` |

### `contains_properly`

*Tersedia*: [PostGIS](https://postgis.net/docs/ST_ContainsProperly.html), PGRaster (Timbal balik)

Mengembalikan true jika pencarian geometri memotong interior dari bidang geometri, tetapi bukan batas (atau eksterior).

Contoh:

```
Zipcode.objects.filter(poly__contains_properly=geom)
```

| Backend | Setara SQL |
| --- | --- |
| PostGIS | `ST_ContainsProperly(poly, geom)` |

### `coveredby`

*Availability*: [PostGIS](https://postgis.net/docs/ST_CoveredBy.html),
Oracle, MariaDB, MySQL, PGRaster (Bilateral), SpatiaLite

Uji jika tidak ada titik dalam bidang geometri diluar pencarian geometri. [^3]

Contoh:

```
Zipcode.objects.filter(poly__coveredby=geom)
```

| Backend | Setara SQL |
| --- | --- |
| PostGIS | `ST_CoveredBy(poly, geom)` |
| Oracle | `SDO_COVEREDBY(poly, geom)` |
| MariaDB | `MBRCoveredBy(poly, geom)` |
| MySQL | `MBRCoveredBy(poly, geom)` |
| SpatiaLite | `CoveredBy(poly, geom)` |

> **Changed in Django 5.2**
>
> Dukungan MySQL telah ditambahkan.

> **Changed in Django 6.0**
>
> MariaDB 12.0.1+ support was added.

### `covers`

*Ketersediaan*: [PostGIS](https://postgis.net/docs/ST_Covers.html), Oracle, MySQL, PGRaster (Bilateral), SpatiaLite

Uji jika tidak ada titik dalam pencarian geometri diluar bidang geometri. [^3]

Contoh:

```
Zipcode.objects.filter(poly__covers=geom)
```

| Backend | Setara SQL |
| --- | --- |
| PostGIS | `ST_Covers(poly, geom)` |
| Oracle | `SDO_COVERS(poly, geom)` |
| MySQL | `MBRCovers(poly, geom)` |
| SpatiaLite | `Covers(poly, geom)` |

> **Changed in Django 5.2**
>
> Dukungan MySQL telah ditambahkan.

### `crosses`

*Ketersediaan*: [PostGIS](https://postgis.net/docs/ST_Crosses.html), MariaDB, MySQL, SpatiaLite, PGRaster (Perubahan)

Uji jika bidang geometri secara spasial menyebrangi pencarian geometri.

Contoh:

```
Zipcode.objects.filter(poly__crosses=geom)
```

| Backend | Setara SQL |
| --- | --- |
| PostGIS | `ST_Crosses(poly, geom)` |
| MariaDB | `ST_Crosses(poly, geom)` |
| MySQL | `ST_Crosses(poly, geom)` |
| SpatiaLite | `Crosses(poly, geom)` |

### `disjoint`

*Ketersediaan*: [PostGIS](https://postgis.net/docs/ST_Disjoint.html), Oracle, MariaDB, MySQL, SpatiaLite, PGRaster (Timbal balik)

Coba jika bidang geometri secara spasial diuraikan dari pencarian geometri.

Contoh:

```
Zipcode.objects.filter(poly__disjoint=geom)
```

| Backend | Setara SQL |
| --- | --- |
| PostGIS | `ST_Disjoint(poly, geom)` |
| Oracle | `SDO_GEOM.RELATE(poly, 'DISJOINT', geom, 0.05)` |
| MariaDB | `ST_Disjoint(poly, geom)` |
| MySQL | `ST_Disjoint(poly, geom)` |
| SpatiaLite | `Disjoint(poly, geom)` |

### `equals`

*Ketersediaan*: [PostGIS](https://postgis.net/docs/ST_Equals.html), Oracle, MariaDB, MySQL, SpatiaLite, PGRaster (Perubahan)

Coba jika bidang geometri secara spasial setara pada pencarian geometri.

Contoh:

```
Zipcode.objects.filter(poly__equals=geom)
```

| Backend | Setara SQL |
| --- | --- |
| PostGIS | `ST_Equals(poly, geom)` |
| Oracle | `SDO_EQUAL(poly, geom)` |
| MariaDB | `ST_Equals(poly, geom)` |
| MySQL | `ST_Equals(poly, geom)` |
| SpatiaLite | `Equals(poly, geom)` |

### `exact`, `same_as`

*Ketersediaan*: [PostGIS](https://postgis.net/docs/ST_Geometry_Same.html), Oracle, MariaDB, MySQL, SpatiaLite, PGRaster (Timbal balik)

Tests if the geometry field is "equal" to the lookup geometry. On Oracle,
MySQL, and SpatiaLite, it tests spatial equality, while on PostGIS it tests
equality of bounding boxes.

Contoh:

```
Zipcode.objects.filter(poly=geom)
```

| Backend | Setara SQL |
| --- | --- |
| PostGIS | `poly ~= geom` |
| Oracle | `SDO_EQUAL(poly, geom)` |
| MariaDB | `ST_Equals(poly, geom)` |
| MySQL | `ST_Equals(poly, geom)` |
| SpatiaLite | `Equals(poly, geom)` |

### `intersects`

*Ketersediaan*: [PostGIS](https://postgis.net/docs/ST_Intersects.html), Oracle, MariaDB, MySQL, SpatiaLite, PGRaster (Timbal balik)

Coba jika bidang geometri secara spasial memotong pencarian geometri.

Contoh:

```
Zipcode.objects.filter(poly__intersects=geom)
```

| Backend | Setara SQL |
| --- | --- |
| PostGIS | `ST_Intersects(poly, geom)` |
| Oracle | `SDO_OVERLAPBDYINTERSECT(poly, geom)` |
| MariaDB | `ST_Intersects(poly, geom)` |
| MySQL | `ST_Intersects(poly, geom)` |
| SpatiaLite | `Intersects(poly, geom)` |

### `isempty`

*Ketersediaan*: [PostGIS](https://postgis.net/docs/ST_IsEmpty.html)

Tests if the geometry is empty.

Contoh:

```
Zipcode.objects.filter(poly__isempty=True)
```

### `isvalid`

*Availability*: MariaDB, MySQL,
[PostGIS](https://postgis.net/docs/ST_IsValid.html), Oracle, SpatiaLite

Coba jika geometri adalah sah.

Contoh:

```
Zipcode.objects.filter(poly__isvalid=True)
```

| Backend | Setara SQL |
| --- | --- |
| MariaDB, MySQL, PostGIS, SpatiaLite | `ST_IsValid(poly)` |
| Oracle | `SDO_GEOM.VALIDATE_GEOMETRY_WITH_CONTEXT(poly, 0.05) = 'TRUE'` |

> **Changed in Django 6.0**
>
> MariaDB 12.0.1+ support was added.

### `geom_type`

> **New in Django 6.0**

*Availability*: [PostGIS](https://postgis.net/docs/GeometryType.html),
Oracle 23c+, MariaDB, MySQL, SpatiaLite

Returns the geometry type of the geometry field.

Contoh:

```
Zipcode.objects.filter(poly__geom_type="POLYGON")
```

| Backend | Setara SQL |
| --- | --- |
| PostGIS | `GeometryType(geom)` |
| MariaDB | `ST_GeometryType(geom)` |
| MySQL | `ST_GeometryType(geom)` |
| Oracle | `SDO_GEOMETRY.GET_GTYPE(geom)` |
| SpatiaLite | `GeometryType(geom)` |

### `overlaps`

*Ketersediaan*: [PostGIS](https://postgis.net/docs/ST_Overlaps.html), Oracle, MariaDB, MySQL, SpatiaLite, PGRaster (Timbal balik)

Coba jika bidang geometri spasial tumpang tindih pencarian geometri.

| Backend | Setara SQL |
| --- | --- |
| PostGIS | `ST_Overlaps(poly, geom)` |
| Oracle | `SDO_OVERLAPS(poly, geom)` |
| MariaDB | `ST_Overlaps(poly, geom)` |
| MySQL | `ST_Overlaps(poly, geom)` |
| SpatiaLite | `Overlaps(poly, geom)` |

### `relate`

*Ketersediaan*: [PostGIS](https://postgis.net/docs/ST_Relate.html), MariaDB, Oracle, SpatiaLite, PGRaster (Conversion)

Tests if the geometry field is spatially related to the lookup geometry by the
values given in the given pattern. This lookup requires a tuple parameter,
`(geom, pattern)`; the form of `pattern` will depend on the spatial
backend:

#### MariaDB, PostGIS, and SpatiaLite

On these spatial backends the intersection pattern is a string comprising nine
characters, which  define intersections between  the interior, boundary, and
exterior of the geometry field and the lookup geometry. The intersection
pattern matrix may only use the following characters: `1`, `2`, `T`,
`F`, or `*`. This lookup type allows users to "fine tune" a specific
geometric relationship consistent with the DE-9IM model. [^1]

Contoh geometri:

```
# A tuple lookup parameter is used to specify the geometry and
# the intersection pattern (the pattern here is for 'contains').
Zipcode.objects.filter(poly__relate=(geom, "T*T***FF*"))
```

PostGIS and MariaDB SQL equivalent:

```sql
SELECT ... WHERE ST_Relate(poly, geom, 'T*T***FF*')
```

SpatiaLite SQL setara:

```sql
SELECT ... WHERE Relate(poly, geom, 'T*T***FF*')
```

Contoh raster:

```
Zipcode.objects.filter(poly__relate=(rast, 1, "T*T***FF*"))
Zipcode.objects.filter(rast__2__relate=(rast, 1, "T*T***FF*"))
```

PostGIS SQL setara:

```sql
SELECT ... WHERE ST_Relate(poly, ST_Polygon(rast, 1), 'T*T***FF*')
SELECT ... WHERE ST_Relate(ST_Polygon(rast, 2), ST_Polygon(rast, 1), 'T*T***FF*')
```

#### Oracle

Here the relation pattern is comprised of at least one of the nine relation
strings: `TOUCH`, `OVERLAPBDYDISJOINT`, `OVERLAPBDYINTERSECT`,
`EQUAL`, `INSIDE`, `COVEREDBY`, `CONTAINS`, `COVERS`, `ON`, and
`ANYINTERACT`. Multiple strings may be combined with the logical Boolean
operator OR, for example, `'inside+touch'`. [^2]  The relation
strings are case-insensitive.

Contoh:

```
Zipcode.objects.filter(poly__relate=(geom, "anyinteract"))
```

Oracle SQL setara:

```sql
SELECT ... WHERE SDO_RELATE(poly, geom, 'anyinteract')
```

### `touches`

*Ketersediaan*: [PostGIS](https://postgis.net/docs/ST_Touches.html), Oracle, MariaDB, MySQL, SpatiaLite

Coba jika bidang geometri secara spasial menyentuh pencarian geometri.

Contoh:

```
Zipcode.objects.filter(poly__touches=geom)
```

| Backend | Setara SQL |
| --- | --- |
| PostGIS | ST\_Touches(poly, geom)\`\` |
| MariaDB | ST\_Touches(poly, geom)\`\` |
| MySQL | ST\_Touches(poly, geom)\`\` |
| Oracle | `SDO_TOUCH(poly, geom)` |
| SpatiaLite | `Touches(poly, geom)` |

### `within`

*Ketersediaan*: [PostGIS](https://postgis.net/docs/ST_Within.html), Oracle, MariaDB, MySQL, SpatiaLite, PGRaster (Timbal balik)

Coba jika bidang geomrtri secara spasial dalam pencarian geometri.

Contoh:

```
Zipcode.objects.filter(poly__within=geom)
```

| Backend | Setara SQL |
| --- | --- |
| PostGIS | `ST_Within(poly, geom)` |
| MariaDB | `ST_Within(poly, geom)` |
| MySQL | `ST_Within(poly, geom)` |
| Oracle | `SDO_INSIDE(poly, geom)` |
| SpatiaLite | `Within(poly, geom)` |

### `left`

*Tersedia*: [PostGIS](https://postgis.net/docs/ST_Geometry_Left.html), PGRaster (Perubahan)

Coba jika kotak pembatas bidang geometri ketat ke kiri dari pencarian kotak pembatas geometri.

Contoh:

```
Zipcode.objects.filter(poly__left=geom)
```

PostGIS setara:

```sql
SELECT ... WHERE poly << geom
```

### `right`

*Tersedia*: [PostGIS](https://postgis.net/docs/ST_Geometry_Right.html), PGRaster (Perubahan)

Coba jika kotak pembatas bidang geometri tegas ke kanan dari pencarian kotak pembatas geometri.

Contoh:

```
Zipcode.objects.filter(poly__right=geom)
```

PostGIS setara:

```sql
SELECT ... WHERE poly >> geom
```

### `overlaps_left`

*Tersedia*: [PostGIS](https://postgis.net/docs/ST_Geometry_Overleft.html), PGRaster (Timbal balik)

Coba jika kotak pencarian bidang geometri tumpang tindih atau ke kiri dari pencarian kotak pembatas geometri.

Contoh:

```
Zipcode.objects.filter(poly__overlaps_left=geom)
```

PostGIS setara:

```sql
SELECT ... WHERE poly &< geom
```

### `overlaps_right`

*Tersedia*: [PostGIS](https://postgis.net/docs/ST_Geometry_Overright.html), PGRaster (Timbal balik)

Coba jika kotak pencarian bidang geometri tumpang tindih atau ke kanan dari pencarian kotak pembatas geometri.

Contoh:

```
Zipcode.objects.filter(poly__overlaps_right=geom)
```

PostGIS setara:

```sql
SELECT ... WHERE poly &> geom
```

### `overlaps_above`

*Tersedia*: [PostGIS](https://postgis.net/docs/ST_Geometry_Overabove.html), PGRaster (Perubahan)

Coba jika kotak pembatas bidang geometri tumpang tindih atau diatas pencarian kotak pembatas geometri.

Contoh:

```
Zipcode.objects.filter(poly__overlaps_above=geom)
```

PostGIS setara:

```sql
SELECT ... WHERE poly |&> geom
```

### `overlaps_below`

*Tersedia*: [PostGIS](https://postgis.net/docs/ST_Geometry_Overbelow.html), PGRaster (Perubahan)

Coba jika kotak pembatas bidang geometri tumpang tindih atau dibawah pencarian kotak pembatas geometri.

Contoh:

```
Zipcode.objects.filter(poly__overlaps_below=geom)
```

PostGIS setara:

```sql
SELECT ... WHERE poly &<| geom
```

### `strictly_above`

*Tersedia*: [PostGIS](https://postgis.net/docs/ST_Geometry_Above.html), PGRaster (Perubahan)

Coba jika kotak pembatas bidang geometri ketat diatas pencarian kotak pembatas geometri.

Contoh:

```
Zipcode.objects.filter(poly__strictly_above=geom)
```

PostGIS setara:

```sql
SELECT ... WHERE poly |>> geom
```

### `strictly_below`

*Tersedia*: [PostGIS](https://postgis.net/docs/ST_Geometry_Below.html), PGRaster (Perubahan)

Coba jika kotak pembatas bidang geometri ketat dibawah pencarian kotak pembatas geometri.

Contoh:

```
Zipcode.objects.filter(poly__strictly_below=geom)
```

PostGIS setara:

```sql
SELECT ... WHERE poly <<| geom
```

## Pencarian Jarak

*Ketersediaan*: PostGIS, Oracle, MariaDB, MySQL, SpatiaLite, PGRaster (Asli)

Untuk sebuah tinjauan pada melakukan permintaan jarak, hrap mengacu pada [distance queries introduction](/id/6.0/ref/contrib/gis/db-api/#distance-queries).

Distance lookups take the following form:

```text
<field>__<distance lookup>=(<geometry/raster>, <distance value>[, "spheroid"])
<field>__<distance lookup>=(<raster>, <band_index>, <distance value>[, "spheroid"])
<field>__<band_index>__<distance lookup>=(<raster>, <band_index>, <distance value>[, "spheroid"])
```

The value passed into a distance lookup is a tuple; the first two
values are mandatory, and are the geometry to calculate distances to,
and a distance value (either a number in units of the field, a
[`Distance`](/id/6.0/ref/contrib/gis/measure/#django.contrib.gis.measure.Distance) object, or a [query
expression](/id/6.0/ref/models/expressions/)). To pass a band index to the lookup, use
a 3-tuple where the second entry is the band index.

Pada setiap pencarian jarak kecuali [`dwithin`](#std-fieldlookup-dwithin), sebuah unsur pilihan, `'spheroid'`, mungkin disertakan untuk digunakan lebih akurat fungsi perhitungan jarak bulatan dengan sistem kordinat geodetik.

Pada PostgreSQL, pilihan `'spheroid'` menggunakan [ST\_DistanceSpheroid](https://postgis.net/docs/ST_Distance_Spheroid.html) daripada [ST\_DistanceSphere](https://postgis.net/docs/ST_DistanceSphere.html). Fungsi [ST\_Distance](https://postgis.net/docs/ST_Distance.html) paling sederhana digunakan dengan sistem kordinat yang sudah dihitung. Raster dirubah ke geometri untuk pencarian berdasarkan spheroid.

### `distance_gt`

Mengembalikan model-model dimana jarak pada bidang geometri dari geometri pencarian lebih besar dari nilai jarak yang diberikan.

Contoh:

```
Zipcode.objects.filter(poly__distance_gt=(geom, D(m=5)))
```

| Backend | Setara SQL |
| --- | --- |
| PostGIS | `ST_Distance/ST_Distance_Sphere(poly, geom) > 5` |
| MariaDB | `ST_Distance(poly, geom) > 5` |
| MySQL | `ST_Distance(poly, geom) > 5` |
| Oracle | `SDO_GEOM.SDO_DISTANCE(poly, geom, 0.05) > 5` |
| SpatiaLite | `Distance(poly, geom) > 5` |

### `distance_gte`

Mengembalikan model-model dimana jarak pada bidang geometri dari geometri pencarian lebih besar dari atau setara pada nilai jarak diberikan.

Contoh:

```
Zipcode.objects.filter(poly__distance_gte=(geom, D(m=5)))
```

| Backend | Setara SQL |
| --- | --- |
| PostGIS | `ST_Distance/ST_Distance_Sphere(poly, geom) >= 5` |
| MariaDB | `ST_Distance(poly, geom) >= 5` |
| MySQL | `ST_Distance(poly, geom) >= 5` |
| Oracle | `SDO_GEOM.SDO_DISTANCE(poly, geom, 0.05) >= 5` |
| SpatiaLite | `Distance(poly, geom) >= 5` |

### `distance_lt`

Mengembalikan model-model dimana jarak pada bidang geometri dari geometri pencarian kurang dari nilai jarak yang diberikan.

Contoh:

```
Zipcode.objects.filter(poly__distance_lt=(geom, D(m=5)))
```

| Backend | Setara SQL |
| --- | --- |
| PostGIS | `ST_Distance/ST_Distance_Sphere(poly, geom) < 5` |
| MariaDB | `ST_Distance(poly, geom) < 5` |
| MySQL | `ST_Distance(poly, geom) < 5` |
| Oracle | `SDO_GEOM.SDO_DISTANCE(poly, geom, 0.05) < 5` |
| SpatiaLite | `Distance(poly, geom) < 5` |

### `distance_lte`

Mengembalikan model-model dimana jarak pada bidang geometri dari geometri pencarian kurang dari atau setara pada nilai jarak yang diberikan.

Contoh:

```
Zipcode.objects.filter(poly__distance_lte=(geom, D(m=5)))
```

| Backend | Setara SQL |
| --- | --- |
| PostGIS | `ST_Distance/ST_Distance_Sphere(poly, geom) <= 5` |
| MariaDB | `ST_Distance(poly, geom) <= 5` |
| MySQL | `ST_Distance(poly, geom) <= 5` |
| Oracle | `SDO_GEOM.SDO_DISTANCE(poly, geom, 0.05) <= 5` |
| SpatiaLite | `Distance(poly, geom) <= 5` |

### `dwithin`

Mengembalikan model-model dimana jarak pada bidang geometri dari geometri pencarian dalam jarak yang diberikan dari satu lainnya. Catat bahwa anda hanya dapat menyediakan obyek [`Distance`](/id/6.0/ref/contrib/gis/measure/#django.contrib.gis.measure.Distance) jika geometri tersasar dalam sistem diperhitungkan. Untuk geometri geografis, anda harus menggunakan satuan dari bidang geometri (misalnya tingkatan untuk `WGS84`) .

Contoh:

```
Zipcode.objects.filter(poly__dwithin=(geom, D(m=5)))
```

| Backend | Setara SQL |
| --- | --- |
| PostGIS | `ST_DWithin(poly, geom, 5)` |
| Oracle | `SDO_WITHIN_DISTANCE(poly, geom, 5)` |
| SpatiaLite | `PtDistWithin(poly, geom, 5)` |

### Fungsi Kumpulan

Django menyediakan beberapa fungsi pengumpulan khusus-GIS. Untuk rincian pada bagaimana menggunakan fungsi-fungsi pengumpulan ini, lihat [the topic guide on aggregation](/id/6.0/topics/db/aggregation/).

| Argumen Katakunci | Deskripsi |
| --- | --- |
| `tolerance` | This keyword is for Oracle only. It is for the<br>tolerance value used by the `SDOAGGRTYPE`<br>procedure; the  [Oracle documentation](https://docs.oracle.com/en/database/oracle/oracle-database/21/spatl/spatial-concepts.html#GUID-CE10AB14-D5EA-43BA-A647-DAC9EEF41EE6) has more<br>details. |

Example:

```pycon
>>> from django.contrib.gis.db.models import Extent, Union
>>> WorldBorder.objects.aggregate(Extent("mpoly"), Union("mpoly"))
```

#### `Collect`

#### `class Collect(geo_field, filter=None)`

*Availability*: [PostGIS](https://postgis.net/docs/ST_Collect.html),
MariaDB, MySQL, SpatiaLite

Returns a `GEOMETRYCOLLECTION` or a `MULTI` geometry object from the
geometry column. This is analogous to a simplified version of the
[`Union`](#django.contrib.gis.db.models.Union) aggregate, except it can be several orders of magnitude faster
than performing a union because it rolls up geometries into a collection or
multi object, not caring about dissolving boundaries.

> **Changed in Django 6.0**
>
> MariaDB 12.0.1+ support was added.

#### `Extent`

#### `class Extent(geo_field, filter=None)`

*Tersedia*: [PostGIS](https://postgis.net/docs/ST_Extent.html), Oracle, SpatiaLite

Returns the extent of all `geo_field` in the `QuerySet` as a 4-tuple,
comprising the lower left coordinate and the upper right coordinate.

Example:

```pycon
>>> qs = City.objects.filter(name__in=("Houston", "Dallas")).aggregate(Extent("poly"))
>>> print(qs["poly__extent"])
(-96.8016128540039, 29.7633724212646, -95.3631439208984, 32.782058715820)
```

#### `Extent3D`

#### `class Extent3D(geo_field, filter=None)`

*Tersedia*: [PostGIS](https://postgis.net/docs/ST_3DExtent.html)

Returns the 3D extent of all `geo_field` in the `QuerySet` as a 6-tuple,
comprising the lower left coordinate and upper right coordinate (each with x,
y, and z coordinates).

Example:

```pycon
>>> qs = City.objects.filter(name__in=("Houston", "Dallas")).aggregate(Extent3D("poly"))
>>> print(qs["poly__extent3d"])
(-96.8016128540039, 29.7633724212646, 0, -95.3631439208984, 32.782058715820, 0)
```

#### `MakeLine`

#### `class MakeLine(geo_field, filter=None)`

*Tersedia*: [PostGIS](https://postgis.net/docs/ST_MakeLine.html), SpatiaLite

Mengembalikan `LineString` dibangun dari geometri bidang titik dalam `QuerySet`. Saat ini pengurutan queryset tidak mempunyai pengaruh.

Example:

```pycon
>>> qs = City.objects.filter(name__in=("Houston", "Dallas")).aggregate(MakeLine("poly"))
>>> print(qs["poly__makeline"])
LINESTRING (-95.3631510000000020 29.7633739999999989, -96.8016109999999941 32.7820570000000018)
```

#### `Union`

#### `class Union(geo_field, filter=None)`

*Tersedia*: [PostGIS](https://postgis.net/docs/ST_Union.html), Oracle, SpatiaLite

Metode ini mengembalikan obyek [`GEOSGeometry`](/id/6.0/ref/contrib/gis/geos/#django.contrib.gis.geos.GEOSGeometry) terdiri dari gabungan dari setiap geometri dalam queryset. Harap catat bahwa penggunaan dari `Union` diolah secara intensif dan mungkin mengambil jumlah signifikan waktu pada queryset besar.

> **Note**
>
> Jika waktu perhitungan untuk menggunakan metode ini terlalu mahal, pertimbangkan menggunakan [`Collect`](#django.contrib.gis.db.models.Collect) sebagai gantinya.

Example:

```pycon
>>> u = Zipcode.objects.aggregate(Union(poly))  # This may take a long time.
>>> u = Zipcode.objects.filter(poly__within=bbox).aggregate(
...     Union(poly)
... )  # A more sensible approach.
```

**Catatan kaki**

[^1]: *Lihat* [OpenGIS Simple Feature Specification For SQL](https://portal.ogc.org/files/?artifact_id=829), at Ch. 2.1.13.2, p. 2-13 (The Dimensionally Extended Nine-Intersection Model).

[^2]: *Lihat* [SDO\_RELATE documentation](https://docs.oracle.com/en/database/oracle/oracle-database/18/spatl/spatial-operators-reference.html#GUID-97C17C18-F05E-49B4-BE11-E89B972E2A02), dari  Panduan Oracle Spatial and Graph Developer.

[^3]: Untuk penjelasan dari rutin ini, baca [Quirks of the "Contains" Spatial Predicate](https://lin-ear-th-inking.blogspot.com/2007/06/subtleties-of-ogc-covers-spatial.html) oleh Martin Davis (seorang pengembang PostGIS).
