{"title":"API Model GeoDjango","version":"6.1","locale":"id","docname":"ref/contrib/gis/model-api","url":"/id/6.1/ref/contrib/gis/model-api/","canonical":"https://djangodocs.dev/id/6.1/ref/contrib/gis/model-api/","summary":"This document explores the details of the GeoDjango Model API. Throughout this section, we'll be using the following geographic model of a ZIP code and of a Digital…","html":"<span id=\"geodjango-model-api\"></span><h1>API Model GeoDjango<a class=\"heading-anchor\" href=\"#module-django.contrib.gis.db.models\"><span class=\"visually-hidden\">Link to this heading</span><span aria-hidden=\"true\">#</span></a></h1>\n<p>This document explores the details of the GeoDjango Model API. Throughout this\nsection, we'll be using the following geographic model of a <a class=\"reference external\" href=\"https://en.wikipedia.org/wiki/ZIP_code\">ZIP code</a> and\nof a <a class=\"reference external\" href=\"https://en.wikipedia.org/wiki/Digital_elevation_model\">Digital Elevation Model</a> as our examples:</p>\n<div class=\"code-block\" data-language=\"default\"><div class=\"code-block-toolbar\"><span class=\"code-block-language\">Code</span><button type=\"button\" class=\"copy-button\" data-copy hidden><span class=\"copy-button-label\">Copy</span></button></div><pre role=\"group\" tabindex=\"0\" aria-label=\"Code code\"><code><span class=\"kn\">from</span><span class=\"w\"> </span><span class=\"nn\">django.contrib.gis.db</span><span class=\"w\"> </span><span class=\"kn\">import</span> <span class=\"n\">models</span>\n\n\n<span class=\"k\">class</span><span class=\"w\"> </span><span class=\"nc\">Zipcode</span><span class=\"p\">(</span><span class=\"n\">models</span><span class=\"o\">.</span><span class=\"n\">Model</span><span class=\"p\">):</span>\n    <span class=\"n\">code</span> <span class=\"o\">=</span> <span class=\"n\">models</span><span class=\"o\">.</span><span class=\"n\">CharField</span><span class=\"p\">(</span><span class=\"n\">max_length</span><span class=\"o\">=</span><span class=\"mi\">5</span><span class=\"p\">)</span>\n    <span class=\"n\">poly</span> <span class=\"o\">=</span> <span class=\"n\">models</span><span class=\"o\">.</span><span class=\"n\">PolygonField</span><span class=\"p\">()</span>\n\n\n<span class=\"k\">class</span><span class=\"w\"> </span><span class=\"nc\">Elevation</span><span class=\"p\">(</span><span class=\"n\">models</span><span class=\"o\">.</span><span class=\"n\">Model</span><span class=\"p\">):</span>\n    <span class=\"n\">name</span> <span class=\"o\">=</span> <span class=\"n\">models</span><span class=\"o\">.</span><span class=\"n\">CharField</span><span class=\"p\">(</span><span class=\"n\">max_length</span><span class=\"o\">=</span><span class=\"mi\">100</span><span class=\"p\">)</span>\n    <span class=\"n\">rast</span> <span class=\"o\">=</span> <span class=\"n\">models</span><span class=\"o\">.</span><span class=\"n\">RasterField</span><span class=\"p\">()</span>\n</code></pre></div>\n<section id=\"spatial-field-types\">\n<h2>Jenis Bidang Spasial<a class=\"heading-anchor\" href=\"#spatial-field-types\"><span class=\"visually-hidden\">Link to this heading</span><span aria-hidden=\"true\">#</span></a></h2>\n<p>Bidang-bidang spasial terdiri dari deretan dari jenis bidang geometri dan satu jenis bidang raster. Setiap jenis-jenis bidang geometri sesuai pada spesifikasi OpenGIS Simple Features <a class=\"footnote-reference brackets\" href=\"#fnogc\" id=\"id3\" role=\"doc-noteref\"><span class=\"fn-bracket\">[</span>1<span class=\"fn-bracket\">]</span></a>. Tidak ada standar untuk data raster.</p>\n<section id=\"geometryfield\">\n<h3><code class=\"docutils literal notranslate\"><span class=\"pre\">GeometryField</span></code><a class=\"heading-anchor\" href=\"#geometryfield\"><span class=\"visually-hidden\">Link to this heading</span><span aria-hidden=\"true\">#</span></a></h3>\n<dl class=\"py class\">\n<dt class=\"sig sig-object py\" id=\"django.contrib.gis.db.models.GeometryField\">\n<em class=\"property\"><span class=\"k\"><span class=\"pre\">class</span></span><span class=\"w\"> </span></em><span class=\"sig-name descname\"><span class=\"pre\">GeometryField</span></span><a class=\"heading-anchor\" href=\"#django.contrib.gis.db.models.GeometryField\"><span class=\"visually-hidden\">Link to this definition</span><span aria-hidden=\"true\">#</span></a></dt>\n<dd></dd></dl>\n\n<p>Kelas dasar untuk bidang geometri.</p>\n</section>\n<section id=\"pointfield\">\n<h3><code class=\"docutils literal notranslate\"><span class=\"pre\">PointField</span></code><a class=\"heading-anchor\" href=\"#pointfield\"><span class=\"visually-hidden\">Link to this heading</span><span aria-hidden=\"true\">#</span></a></h3>\n<dl class=\"py class\">\n<dt class=\"sig sig-object py\" id=\"django.contrib.gis.db.models.PointField\">\n<em class=\"property\"><span class=\"k\"><span class=\"pre\">class</span></span><span class=\"w\"> </span></em><span class=\"sig-name descname\"><span class=\"pre\">PointField</span></span><a class=\"heading-anchor\" href=\"#django.contrib.gis.db.models.PointField\"><span class=\"visually-hidden\">Link to this definition</span><span aria-hidden=\"true\">#</span></a></dt>\n<dd></dd></dl>\n\n<p>Menyimpan <a class=\"reference internal\" href=\"/id/6.1/ref/contrib/gis/geos/#django.contrib.gis.geos.Point\" title=\"django.contrib.gis.geos.Point\"><code class=\"xref py py-class docutils literal notranslate\"><span class=\"pre\">Point</span></code></a>.</p>\n</section>\n<section id=\"linestringfield\">\n<h3><code class=\"docutils literal notranslate\"><span class=\"pre\">LineStringField</span></code><a class=\"heading-anchor\" href=\"#linestringfield\"><span class=\"visually-hidden\">Link to this heading</span><span aria-hidden=\"true\">#</span></a></h3>\n<dl class=\"py class\">\n<dt class=\"sig sig-object py\" id=\"django.contrib.gis.db.models.LineStringField\">\n<em class=\"property\"><span class=\"k\"><span class=\"pre\">class</span></span><span class=\"w\"> </span></em><span class=\"sig-name descname\"><span class=\"pre\">LineStringField</span></span><a class=\"heading-anchor\" href=\"#django.contrib.gis.db.models.LineStringField\"><span class=\"visually-hidden\">Link to this definition</span><span aria-hidden=\"true\">#</span></a></dt>\n<dd></dd></dl>\n\n<p>Menyimpan <a class=\"reference internal\" href=\"/id/6.1/ref/contrib/gis/geos/#django.contrib.gis.geos.LineString\" title=\"django.contrib.gis.geos.LineString\"><code class=\"xref py py-class docutils literal notranslate\"><span class=\"pre\">LineString</span></code></a>.</p>\n</section>\n<section id=\"polygonfield\">\n<h3><code class=\"docutils literal notranslate\"><span class=\"pre\">PolygonField</span></code><a class=\"heading-anchor\" href=\"#polygonfield\"><span class=\"visually-hidden\">Link to this heading</span><span aria-hidden=\"true\">#</span></a></h3>\n<dl class=\"py class\">\n<dt class=\"sig sig-object py\" id=\"django.contrib.gis.db.models.PolygonField\">\n<em class=\"property\"><span class=\"k\"><span class=\"pre\">class</span></span><span class=\"w\"> </span></em><span class=\"sig-name descname\"><span class=\"pre\">PolygonField</span></span><a class=\"heading-anchor\" href=\"#django.contrib.gis.db.models.PolygonField\"><span class=\"visually-hidden\">Link to this definition</span><span aria-hidden=\"true\">#</span></a></dt>\n<dd></dd></dl>\n\n<p>Menyimpan <a class=\"reference internal\" href=\"/id/6.1/ref/contrib/gis/geos/#django.contrib.gis.geos.Polygon\" title=\"django.contrib.gis.geos.Polygon\"><code class=\"xref py py-class docutils literal notranslate\"><span class=\"pre\">Polygon</span></code></a>.</p>\n</section>\n<section id=\"multipointfield\">\n<h3><code class=\"docutils literal notranslate\"><span class=\"pre\">MultiPointField</span></code><a class=\"heading-anchor\" href=\"#multipointfield\"><span class=\"visually-hidden\">Link to this heading</span><span aria-hidden=\"true\">#</span></a></h3>\n<dl class=\"py class\">\n<dt class=\"sig sig-object py\" id=\"django.contrib.gis.db.models.MultiPointField\">\n<em class=\"property\"><span class=\"k\"><span class=\"pre\">class</span></span><span class=\"w\"> </span></em><span class=\"sig-name descname\"><span class=\"pre\">MultiPointField</span></span><a class=\"heading-anchor\" href=\"#django.contrib.gis.db.models.MultiPointField\"><span class=\"visually-hidden\">Link to this definition</span><span aria-hidden=\"true\">#</span></a></dt>\n<dd></dd></dl>\n\n<p>Menyimpan <a class=\"reference internal\" href=\"/id/6.1/ref/contrib/gis/geos/#django.contrib.gis.geos.MultiPoint\" title=\"django.contrib.gis.geos.MultiPoint\"><code class=\"xref py py-class docutils literal notranslate\"><span class=\"pre\">MultiPoint</span></code></a>.</p>\n</section>\n<section id=\"multilinestringfield\">\n<h3><code class=\"docutils literal notranslate\"><span class=\"pre\">MultiLineStringField</span></code><a class=\"heading-anchor\" href=\"#multilinestringfield\"><span class=\"visually-hidden\">Link to this heading</span><span aria-hidden=\"true\">#</span></a></h3>\n<dl class=\"py class\">\n<dt class=\"sig sig-object py\" id=\"django.contrib.gis.db.models.MultiLineStringField\">\n<em class=\"property\"><span class=\"k\"><span class=\"pre\">class</span></span><span class=\"w\"> </span></em><span class=\"sig-name descname\"><span class=\"pre\">MultiLineStringField</span></span><a class=\"heading-anchor\" href=\"#django.contrib.gis.db.models.MultiLineStringField\"><span class=\"visually-hidden\">Link to this definition</span><span aria-hidden=\"true\">#</span></a></dt>\n<dd></dd></dl>\n\n<p>Menyimpan <a class=\"reference internal\" href=\"/id/6.1/ref/contrib/gis/geos/#django.contrib.gis.geos.MultiLineString\" title=\"django.contrib.gis.geos.MultiLineString\"><code class=\"xref py py-class docutils literal notranslate\"><span class=\"pre\">MultiLineString</span></code></a>.</p>\n</section>\n<section id=\"multipolygonfield\">\n<h3><code class=\"docutils literal notranslate\"><span class=\"pre\">MultiPolygonField</span></code><a class=\"heading-anchor\" href=\"#multipolygonfield\"><span class=\"visually-hidden\">Link to this heading</span><span aria-hidden=\"true\">#</span></a></h3>\n<dl class=\"py class\">\n<dt class=\"sig sig-object py\" id=\"django.contrib.gis.db.models.MultiPolygonField\">\n<em class=\"property\"><span class=\"k\"><span class=\"pre\">class</span></span><span class=\"w\"> </span></em><span class=\"sig-name descname\"><span class=\"pre\">MultiPolygonField</span></span><a class=\"heading-anchor\" href=\"#django.contrib.gis.db.models.MultiPolygonField\"><span class=\"visually-hidden\">Link to this definition</span><span aria-hidden=\"true\">#</span></a></dt>\n<dd></dd></dl>\n\n<p>Menyimpan <a class=\"reference internal\" href=\"/id/6.1/ref/contrib/gis/geos/#django.contrib.gis.geos.MultiPolygon\" title=\"django.contrib.gis.geos.MultiPolygon\"><code class=\"xref py py-class docutils literal notranslate\"><span class=\"pre\">MultiPolygon</span></code></a>.</p>\n</section>\n<section id=\"geometrycollectionfield\">\n<h3><code class=\"docutils literal notranslate\"><span class=\"pre\">GeometryCollectionField</span></code><a class=\"heading-anchor\" href=\"#geometrycollectionfield\"><span class=\"visually-hidden\">Link to this heading</span><span aria-hidden=\"true\">#</span></a></h3>\n<dl class=\"py class\">\n<dt class=\"sig sig-object py\" id=\"django.contrib.gis.db.models.GeometryCollectionField\">\n<em class=\"property\"><span class=\"k\"><span class=\"pre\">class</span></span><span class=\"w\"> </span></em><span class=\"sig-name descname\"><span class=\"pre\">GeometryCollectionField</span></span><a class=\"heading-anchor\" href=\"#django.contrib.gis.db.models.GeometryCollectionField\"><span class=\"visually-hidden\">Link to this definition</span><span aria-hidden=\"true\">#</span></a></dt>\n<dd></dd></dl>\n\n<p>Menyimpan <a class=\"reference internal\" href=\"/id/6.1/ref/contrib/gis/geos/#django.contrib.gis.geos.GeometryCollection\" title=\"django.contrib.gis.geos.GeometryCollection\"><code class=\"xref py py-class docutils literal notranslate\"><span class=\"pre\">GeometryCollection</span></code></a>.</p>\n</section>\n<section id=\"rasterfield\">\n<h3><code class=\"docutils literal notranslate\"><span class=\"pre\">RasterField</span></code><a class=\"heading-anchor\" href=\"#rasterfield\"><span class=\"visually-hidden\">Link to this heading</span><span aria-hidden=\"true\">#</span></a></h3>\n<dl class=\"py class\">\n<dt class=\"sig sig-object py\" id=\"django.contrib.gis.db.models.RasterField\">\n<em class=\"property\"><span class=\"k\"><span class=\"pre\">class</span></span><span class=\"w\"> </span></em><span class=\"sig-name descname\"><span class=\"pre\">RasterField</span></span><a class=\"heading-anchor\" href=\"#django.contrib.gis.db.models.RasterField\"><span class=\"visually-hidden\">Link to this definition</span><span aria-hidden=\"true\">#</span></a></dt>\n<dd></dd></dl>\n\n<p>Menyimpan <a class=\"reference internal\" href=\"/id/6.1/ref/contrib/gis/gdal/#django.contrib.gis.gdal.GDALRaster\" title=\"django.contrib.gis.gdal.GDALRaster\"><code class=\"xref py py-class docutils literal notranslate\"><span class=\"pre\">GDALRaster</span></code></a>.</p>\n<p><code class=\"docutils literal notranslate\"><span class=\"pre\">RasterField</span></code> saat ini hanya diterapkan untuk backend PostGIS.</p>\n</section>\n</section>\n<section id=\"spatial-field-options\">\n<h2>Pilihan Bidang Spasial<a class=\"heading-anchor\" href=\"#spatial-field-options\"><span class=\"visually-hidden\">Link to this heading</span><span aria-hidden=\"true\">#</span></a></h2>\n<p>Sebagai tambahan pada <a class=\"reference internal\" href=\"/id/6.1/ref/models/fields/#common-model-field-options\"><span class=\"std std-ref\">Pilihan bidang</span></a> biasa tersedia untuk bidang model Django, bidang-bidang spasial mempunyai pilihan tambahan berikut. Semua adalah pilihan.</p>\n<section id=\"srid\">\n<h3><code class=\"docutils literal notranslate\"><span class=\"pre\">srid</span></code><a class=\"heading-anchor\" href=\"#srid\"><span class=\"visually-hidden\">Link to this heading</span><span aria-hidden=\"true\">#</span></a></h3>\n<dl class=\"py attribute\">\n<dt class=\"sig sig-object py\" id=\"django.contrib.gis.db.models.BaseSpatialField.srid\">\n<span class=\"sig-prename descclassname\"><span class=\"pre\">BaseSpatialField.</span></span><span class=\"sig-name descname\"><span class=\"pre\">srid</span></span><a class=\"heading-anchor\" href=\"#django.contrib.gis.db.models.BaseSpatialField.srid\"><span class=\"visually-hidden\">Link to this definition</span><span aria-hidden=\"true\">#</span></a></dt>\n<dd></dd></dl>\n\n<p>Setel SRID <a class=\"footnote-reference brackets\" href=\"#fnogcsrid\" id=\"id4\" role=\"doc-noteref\"><span class=\"fn-bracket\">[</span>2<span class=\"fn-bracket\">]</span></a> (Spatial Reference System Identity) dari bidang geometri pada nilai diberikan. Awalan pada 4326 (juga dikenal sebagai <a class=\"reference external\" href=\"https://en.wikipedia.org/wiki/WGS84\">WGS84</a>, satuan-satuan adalah dalam derajat dari garis bujur dan garis lintang).</p>\n<section id=\"selecting-an-srid\">\n<span id=\"id6\"></span><h4>Memilih sebuah SRID<a class=\"heading-anchor\" href=\"#selecting-an-srid\"><span class=\"visually-hidden\">Link to this heading</span><span aria-hidden=\"true\">#</span></a></h4>\n<p>Choosing an appropriate SRID for your model is an important decision that the\ndeveloper should consider carefully. The SRID is an integer specifier that\ncorresponds to the projection system that will be used to interpret the data in\nthe spatial database. <a class=\"footnote-reference brackets\" href=\"#fnsrid\" id=\"id7\" role=\"doc-noteref\"><span class=\"fn-bracket\">[</span>3<span class=\"fn-bracket\">]</span></a>  Projection systems give the context to the\ncoordinates that specify a location. Although the details of <a class=\"reference external\" href=\"https://en.wikipedia.org/wiki/Geodesy\">geodesy</a> are\nbeyond the scope of this documentation, the general problem is that the earth\nis spherical and representations of the earth (e.g., paper maps, web maps) are\nnot.</p>\n<p>Most people are familiar with using latitude and longitude to reference a\nlocation on the earth's surface. However, latitude and longitude are angles,\nnot distances. In other words, while the shortest path between two points on a\nflat surface is a straight line, the shortest path between two points on a\ncurved surface (such as the earth) is an <em>arc</em> of a <a class=\"reference external\" href=\"https://en.wikipedia.org/wiki/Great_circle\">great circle</a>.\n<a class=\"footnote-reference brackets\" href=\"#fnthematic\" id=\"id8\" role=\"doc-noteref\"><span class=\"fn-bracket\">[</span>4<span class=\"fn-bracket\">]</span></a></p>\n<p>Thus, additional computation is required to obtain distances in planar units\n(e.g., kilometers and miles). Using a geographic coordinate system may\nintroduce complications for the developer later on. For example, SpatiaLite\ndoes not have the capability to perform distance calculations between\ngeometries using geographic coordinate systems, e.g. constructing a query to\nfind all points within 5 miles of a county boundary stored as WGS84. <a class=\"footnote-reference brackets\" href=\"#fndist\" id=\"id9\" role=\"doc-noteref\"><span class=\"fn-bracket\">[</span>5<span class=\"fn-bracket\">]</span></a></p>\n<p>Portions of the earth's surface may projected onto a two-dimensional, or\nCartesian, plane. Projected coordinate systems are especially convenient for\nregion-specific applications, e.g., if you know that your database will only\ncover geometries in <a class=\"reference external\" href=\"https://spatialreference.org/ref/epsg/2796/\">North Kansas</a>, then you may consider using projection\nsystem specific to that region. Moreover, projected coordinate systems are\ndefined in Cartesian units (such as meters or feet), easing distance\ncalculations.</p>\n<aside class=\"admonition admonition-note\" role=\"note\">\n<p class=\"admonition-title\">Catatan</p>\n<p>Jika anda berharap melakukan permintaan jarak berubah-ubah menggunakan geometri bukan-titik dalam WGS84 di PostGIS dan anda ingin penampilan layak, adakan kata kunci <a class=\"reference internal\" href=\"#django.contrib.gis.db.models.GeometryField.geography\" title=\"django.contrib.gis.db.models.GeometryField.geography\"><code class=\"xref py py-attr docutils literal notranslate\"><span class=\"pre\">GeometryField.geography</span></code></a> sehingga <a class=\"reference internal\" href=\"#geography-type\"><span class=\"std std-ref\">geography database type</span></a> digunakan sebagai gantinya.</p>\n</aside>\n<p>Sumber daya Tambahan:</p>\n<ul class=\"simple\">\n<li><p><a class=\"reference external\" href=\"https://spatialreference.org/\">spatialreference.org</a>: A database of spatial reference systems.</p></li>\n<li><p><a class=\"reference external\" href=\"https://web.archive.org/web/20080302095452/http://welcome.warnercnr.colostate.edu/class_info/nr502/lg3/datums_coordinates/spcs.html\">The State Plane Coordinate System</a>: A website covering the various\nprojection systems used in the United States. Much of the U.S. spatial\ndata encountered will be in one of these coordinate systems rather than\nin a geographic coordinate system such as WGS84.</p></li>\n</ul>\n</section>\n</section>\n<section id=\"spatial-index\">\n<h3><code class=\"docutils literal notranslate\"><span class=\"pre\">spatial_index</span></code><a class=\"heading-anchor\" href=\"#spatial-index\"><span class=\"visually-hidden\">Link to this heading</span><span aria-hidden=\"true\">#</span></a></h3>\n<dl class=\"py attribute\">\n<dt class=\"sig sig-object py\" id=\"django.contrib.gis.db.models.BaseSpatialField.spatial_index\">\n<span class=\"sig-prename descclassname\"><span class=\"pre\">BaseSpatialField.</span></span><span class=\"sig-name descname\"><span class=\"pre\">spatial_index</span></span><a class=\"heading-anchor\" href=\"#django.contrib.gis.db.models.BaseSpatialField.spatial_index\"><span class=\"visually-hidden\">Link to this definition</span><span aria-hidden=\"true\">#</span></a></dt>\n<dd></dd></dl>\n\n<p>Defaults to <code class=\"docutils literal notranslate\"><span class=\"pre\">True</span></code>. Creates a spatial index for the given geometry\nfield.</p>\n<aside class=\"admonition admonition-note\" role=\"note\">\n<p class=\"admonition-title\">Catatan</p>\n<p>This is different from the <code class=\"docutils literal notranslate\"><span class=\"pre\">db_index</span></code> field option because spatial\nindexes are created in a different manner than regular database\nindexes. Specifically, spatial indexes are typically created using\na variant of the R-Tree, while regular database indexes typically\nuse B-Trees.</p>\n</aside>\n</section>\n</section>\n<section id=\"geometry-field-options\">\n<span id=\"id15\"></span><h2>Pilihan Bidang Geometri<a class=\"heading-anchor\" href=\"#geometry-field-options\"><span class=\"visually-hidden\">Link to this heading</span><span aria-hidden=\"true\">#</span></a></h2>\n<p>Ada pilihan tambahan tersedia untuk bidang Geometri. Semua pilihan berikut adalah pilihan.</p>\n<section id=\"dim\">\n<h3><code class=\"docutils literal notranslate\"><span class=\"pre\">dim</span></code><a class=\"heading-anchor\" href=\"#dim\"><span class=\"visually-hidden\">Link to this heading</span><span aria-hidden=\"true\">#</span></a></h3>\n<dl class=\"py attribute\">\n<dt class=\"sig sig-object py\" id=\"django.contrib.gis.db.models.GeometryField.dim\">\n<span class=\"sig-prename descclassname\"><span class=\"pre\">GeometryField.</span></span><span class=\"sig-name descname\"><span class=\"pre\">dim</span></span><a class=\"heading-anchor\" href=\"#django.contrib.gis.db.models.GeometryField.dim\"><span class=\"visually-hidden\">Link to this definition</span><span aria-hidden=\"true\">#</span></a></dt>\n<dd></dd></dl>\n\n<p>This option may be used for customizing the coordinate dimension of the\ngeometry field. By default, it is set to 2, for representing two-dimensional\ngeometries. For spatial backends that support it, it may be set to 3 for\nthree-dimensional support.</p>\n<aside class=\"admonition admonition-note\" role=\"note\">\n<p class=\"admonition-title\">Catatan</p>\n<p>At this time 3D support is limited to the PostGIS and SpatiaLite backends.</p>\n</aside>\n</section>\n<section id=\"geography\">\n<h3><code class=\"docutils literal notranslate\"><span class=\"pre\">geography</span></code><a class=\"heading-anchor\" href=\"#geography\"><span class=\"visually-hidden\">Link to this heading</span><span aria-hidden=\"true\">#</span></a></h3>\n<dl class=\"py attribute\">\n<dt class=\"sig sig-object py\" id=\"django.contrib.gis.db.models.GeometryField.geography\">\n<span class=\"sig-prename descclassname\"><span class=\"pre\">GeometryField.</span></span><span class=\"sig-name descname\"><span class=\"pre\">geography</span></span><a class=\"heading-anchor\" href=\"#django.contrib.gis.db.models.GeometryField.geography\"><span class=\"visually-hidden\">Link to this definition</span><span aria-hidden=\"true\">#</span></a></dt>\n<dd></dd></dl>\n\n<p>If set to <code class=\"docutils literal notranslate\"><span class=\"pre\">True</span></code>, this option will create a database column of\ntype geography, rather than geometry. Please refer to the\n<a class=\"reference internal\" href=\"#geography-type\"><span class=\"std std-ref\">geography type</span></a> section below for more\ndetails.</p>\n<aside class=\"admonition admonition-note\" role=\"note\">\n<p class=\"admonition-title\">Catatan</p>\n<p>Dukungan geografi adalah terbatas pada PostGIS dan akan memaksa SRID menjadi 4326.</p>\n</aside>\n</section>\n<section id=\"max-geom-collections\">\n<h3><code class=\"docutils literal notranslate\"><span class=\"pre\">max_geom_collections</span></code><a class=\"heading-anchor\" href=\"#max-geom-collections\"><span class=\"visually-hidden\">Link to this heading</span><span aria-hidden=\"true\">#</span></a></h3>\n<dl class=\"py attribute\">\n<dt class=\"sig sig-object py\" id=\"django.contrib.gis.db.models.GeometryField.max_geom_collections\">\n<span class=\"sig-prename descclassname\"><span class=\"pre\">GeometryField.</span></span><span class=\"sig-name descname\"><span class=\"pre\">max_geom_collections</span></span><a class=\"heading-anchor\" href=\"#django.contrib.gis.db.models.GeometryField.max_geom_collections\"><span class=\"visually-hidden\">Link to this definition</span><span aria-hidden=\"true\">#</span></a></dt>\n<dd></dd></dl>\n\n<aside class=\"version-note version-added\" data-version=\"5.2.17\">\n<p class=\"version-note-title\">New in Django 5.2.17</p></aside>\n<p>This option is forwarded to the <a class=\"reference internal\" href=\"/id/6.1/ref/contrib/gis/forms-api/#django.contrib.gis.forms.Field.max_geom_collections\" title=\"django.contrib.gis.forms.Field.max_geom_collections\"><code class=\"xref py py-attr docutils literal notranslate\"><span class=\"pre\">form</span> <span class=\"pre\">field</span></code></a> generated for this model\nfield, bounding how many geometry collections may be contained in submitted\nWKB/WKT inputs before raising <a class=\"reference external\" href=\"https://docs.python.org/3/library/exceptions.html#ValueError\" title=\"(di Python v3.14)\"><code class=\"xref py py-exc docutils literal notranslate\"><span class=\"pre\">ValueError</span></code></a>. Since spatial field\nassignments are lazy, it is also checked when values are accessed, e.g. when\nsaving an instance, but not when read from a database. It defaults to <code class=\"docutils literal notranslate\"><span class=\"pre\">198</span></code>.</p>\n<section id=\"geography-type\">\n<span id=\"id16\"></span><h4>Jenis Geografi<a class=\"heading-anchor\" href=\"#geography-type\"><span class=\"visually-hidden\">Link to this heading</span><span aria-hidden=\"true\">#</span></a></h4>\n<p>The geography type provides native support for spatial features represented\nwith geographic coordinates (e.g., WGS84 longitude/latitude). <a class=\"footnote-reference brackets\" href=\"#fngeography\" id=\"id17\" role=\"doc-noteref\"><span class=\"fn-bracket\">[</span>6<span class=\"fn-bracket\">]</span></a>\nUnlike the plane used by a geometry type, the geography type uses a spherical\nrepresentation of its data. Distance and measurement operations\nperformed on a geography column automatically employ great circle arc\ncalculations and return linear units. In other words, when <code class=\"docutils literal notranslate\"><span class=\"pre\">ST_Distance</span></code>\nis called on two geographies, a value in meters is returned (as opposed\nto degrees if called on a geometry column in WGS84).</p>\n<p>Karena perhitungan geografis melibatkan matematika lebih, hanya bagian dari pencarian spasial PostGIS tersedia untuk jenis geografi. Secara praktik, ini berarti bahwa sebagai tambahan pada <a class=\"reference internal\" href=\"/id/6.1/ref/contrib/gis/geoquerysets/#distance-lookups\"><span class=\"std std-ref\">distance lookups</span></a> hanya berikut tambahan <a class=\"reference internal\" href=\"/id/6.1/ref/contrib/gis/geoquerysets/#spatial-lookups\"><span class=\"std std-ref\">spatial lookups</span></a> tersedia untuk kolom geografi:</p>\n<ul class=\"simple\">\n<li><p><a class=\"reference internal\" href=\"/id/6.1/ref/contrib/gis/geoquerysets/#std-fieldlookup-bboverlaps\"><code class=\"xref std std-lookup docutils literal notranslate\"><span class=\"pre\">bboverlaps</span></code></a></p></li>\n<li><p><a class=\"reference internal\" href=\"/id/6.1/ref/contrib/gis/geoquerysets/#std-fieldlookup-coveredby\"><code class=\"xref std std-lookup docutils literal notranslate\"><span class=\"pre\">coveredby</span></code></a></p></li>\n<li><p><a class=\"reference internal\" href=\"/id/6.1/ref/contrib/gis/geoquerysets/#std-fieldlookup-covers\"><code class=\"xref std std-lookup docutils literal notranslate\"><span class=\"pre\">covers</span></code></a></p></li>\n<li><p><a class=\"reference internal\" href=\"/id/6.1/ref/contrib/gis/geoquerysets/#std-fieldlookup-intersects\"><code class=\"xref std std-lookup docutils literal notranslate\"><span class=\"pre\">intersects</span></code></a></p></li>\n</ul>\n<p>Jika anda butuh menggunakan pencarian spasial atau pengumpulan yang tidak mendukung jenis geografi sebagai masukan, anda dapat menggunakan fungsi basisdata <a class=\"reference internal\" href=\"/id/6.1/ref/models/database-functions/#django.db.models.functions.Cast\" title=\"django.db.models.functions.Cast\"><code class=\"xref py py-class docutils literal notranslate\"><span class=\"pre\">Cast</span></code></a> untuk merubah kolom geografi menjadi jenis geometri dalam permintaan:</p>\n<div class=\"code-block\" data-language=\"default\"><div class=\"code-block-toolbar\"><span class=\"code-block-language\">Code</span><button type=\"button\" class=\"copy-button\" data-copy hidden><span class=\"copy-button-label\">Copy</span></button></div><pre role=\"group\" tabindex=\"0\" aria-label=\"Code code\"><code><span class=\"kn\">from</span><span class=\"w\"> </span><span class=\"nn\">django.contrib.gis.db.models</span><span class=\"w\"> </span><span class=\"kn\">import</span> <span class=\"n\">PointField</span>\n<span class=\"kn\">from</span><span class=\"w\"> </span><span class=\"nn\">django.db.models.functions</span><span class=\"w\"> </span><span class=\"kn\">import</span> <span class=\"n\">Cast</span>\n\n<span class=\"n\">Zipcode</span><span class=\"o\">.</span><span class=\"n\">objects</span><span class=\"o\">.</span><span class=\"n\">annotate</span><span class=\"p\">(</span><span class=\"n\">geom</span><span class=\"o\">=</span><span class=\"n\">Cast</span><span class=\"p\">(</span><span class=\"s2\">&quot;geography_field&quot;</span><span class=\"p\">,</span> <span class=\"n\">PointField</span><span class=\"p\">()))</span><span class=\"o\">.</span><span class=\"n\">filter</span><span class=\"p\">(</span>\n    <span class=\"n\">geom__within</span><span class=\"o\">=</span><span class=\"n\">poly</span>\n<span class=\"p\">)</span>\n</code></pre></div>\n<p>For more information, the PostGIS documentation contains a helpful section on\ndetermining <a class=\"reference external\" href=\"https://postgis.net/docs/using_postgis_dbmanagement.html#PostGIS_GeographyVSGeometry\">when to use geography data type over geometry data type</a>.</p>\n<p class=\"rubric\">Catatan kaki</p>\n<aside class=\"footnote-list brackets\">\n<aside class=\"footnote brackets\" id=\"fnogc\" role=\"doc-footnote\">\n<span class=\"label\"><span class=\"fn-bracket\">[</span><a role=\"doc-backlink\" href=\"#id3\">1</a><span class=\"fn-bracket\">]</span></span>\n<p>OpenGIS Consortium, Inc., <a class=\"reference external\" href=\"https://www.ogc.org/standard/sfs/\">Simple Feature Specification For SQL</a>.</p>\n</aside>\n<aside class=\"footnote brackets\" id=\"fnogcsrid\" role=\"doc-footnote\">\n<span class=\"label\"><span class=\"fn-bracket\">[</span><a role=\"doc-backlink\" href=\"#id4\">2</a><span class=\"fn-bracket\">]</span></span>\n<p><em>Lihat id.</em> pada Ch. 2.3.8, p. 39 (Nilai Geometri dan Sustem Acuan Spasial).</p>\n</aside>\n<aside class=\"footnote brackets\" id=\"fnsrid\" role=\"doc-footnote\">\n<span class=\"label\"><span class=\"fn-bracket\">[</span><a role=\"doc-backlink\" href=\"#id7\">3</a><span class=\"fn-bracket\">]</span></span>\n<p>Typically, SRID integer corresponds to an EPSG (<a class=\"reference external\" href=\"https://epsg.org/\">European Petroleum Survey Group</a>) identifier. However, it may also be associated with custom projections defined in spatial database's spatial reference systems table.</p>\n</aside>\n<aside class=\"footnote brackets\" id=\"fnthematic\" role=\"doc-footnote\">\n<span class=\"label\"><span class=\"fn-bracket\">[</span><a role=\"doc-backlink\" href=\"#id8\">4</a><span class=\"fn-bracket\">]</span></span>\n<p>Terry A. Slocum, Robert B. McMaster, Fritz C. Kessler, &amp; Hugh H. Howard, <em>Thematic Cartography and Geographic Visualization</em> (Prentice Hall, edisi ke 2), pada Bab 7.1.3.</p>\n</aside>\n<aside class=\"footnote brackets\" id=\"fndist\" role=\"doc-footnote\">\n<span class=\"label\"><span class=\"fn-bracket\">[</span><a role=\"doc-backlink\" href=\"#id9\">5</a><span class=\"fn-bracket\">]</span></span>\n<p>Batasan ini tidak berlaku pada PostGIS.</p>\n</aside>\n<aside class=\"footnote brackets\" id=\"fngeography\" role=\"doc-footnote\">\n<span class=\"label\"><span class=\"fn-bracket\">[</span><a role=\"doc-backlink\" href=\"#id17\">6</a><span class=\"fn-bracket\">]</span></span>\n<p>Harap mengacu ke dokumentasi <a class=\"reference external\" href=\"https://postgis.net/docs/using_postgis_dbmanagement.html#PostGIS_Geography\">PostGIS Geography Type</a> untuk rincian lebih.</p>\n</aside>\n</aside>\n</section>\n</section>\n</section>","rootId":"module-django.contrib.gis.db.models","toc":[{"title":"Jenis Bidang Spasial","anchor":"spatial-field-types","children":[{"title":"GeometryField","anchor":"geometryfield","children":[]},{"title":"PointField","anchor":"pointfield","children":[]},{"title":"LineStringField","anchor":"linestringfield","children":[]},{"title":"PolygonField","anchor":"polygonfield","children":[]},{"title":"MultiPointField","anchor":"multipointfield","children":[]},{"title":"MultiLineStringField","anchor":"multilinestringfield","children":[]},{"title":"MultiPolygonField","anchor":"multipolygonfield","children":[]},{"title":"GeometryCollectionField","anchor":"geometrycollectionfield","children":[]},{"title":"RasterField","anchor":"rasterfield","children":[]}]},{"title":"Pilihan Bidang Spasial","anchor":"spatial-field-options","children":[{"title":"srid","anchor":"srid","children":[{"title":"Memilih sebuah SRID","anchor":"selecting-an-srid","children":[]}]},{"title":"spatial_index","anchor":"spatial-index","children":[]}]},{"title":"Pilihan Bidang Geometri","anchor":"geometry-field-options","children":[{"title":"dim","anchor":"dim","children":[]},{"title":"geography","anchor":"geography","children":[]},{"title":"max_geom_collections","anchor":"max-geom-collections","children":[{"title":"Jenis Geografi","anchor":"geography-type","children":[]}]}]}],"breadcrumbs":[{"docname":"ref/index","title":"Acuan API","url":"/id/6.1/ref/"},{"docname":"ref/contrib/index","title":"Paket contrib","url":"/id/6.1/ref/contrib/"},{"docname":"ref/contrib/gis/index","title":"GeoDjango","url":"/id/6.1/ref/contrib/gis/"}],"prev":{"docname":"ref/contrib/gis/install/spatialite","title":"Memasang SpatiaLite","url":"/id/6.1/ref/contrib/gis/install/spatialite/"},"next":{"docname":"ref/contrib/gis/db-api","title":"API Basisdata GeoDjango","url":"/id/6.1/ref/contrib/gis/db-api/"},"formats":{"html":"/id/6.1/ref/contrib/gis/model-api/","markdown":"/id/6.1/ref/contrib/gis/model-api.md","json":"/id/6.1/ref/contrib/gis/model-api.json"},"source":"https://github.com/django/django/blob/stable/6.1.x/docs/ref/contrib/gis/model-api.txt","official":"https://docs.djangoproject.com/id/6.1/ref/contrib/gis/model-api/","inVersions":["6.1","6.0","5.2","5.1","5.0","4.2","4.1","4.0","3.2","3.1","3.0","2.2","2.1","2.0","1.11","1.10","1.9"],"inLocales":["en","sv","zh-hans","ga","fr","ja","id","it","pt-br","ko","es","el","pl"]}