{"title":"API Múnla GeodJango","version":"6.0","locale":"ga","docname":"ref/contrib/gis/model-api","url":"/ga/6.0/ref/contrib/gis/model-api/","canonical":"https://djangodocs.dev/ga/6.0/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 Múnla 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>Cineálacha Réimse spású<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>Is éard atá i réimsí spásúla sraith cineálacha réimse geoiméadrachta agus cineál réimse raster amháin. Freagraíonn gach ceann de na cineálacha réimse geoiméadair do shonraíocht Gnéithe Simple OpenGIS [#fnogc] _. Níl aon chaighdeán den sórt sin ann do shonraí raster.</p>\n<section id=\"geometryfield\">\n<h3><code class=\"docutils literal notranslate\"><span class=\"pre\">Réimse</span> <span class=\"pre\">Geoiméadraithe</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>An bunaicme do réimsí geoiméadrachta.</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>Stórais a: aicme: ~django.contrib.gis.geos.point.</p>\n</section>\n<section id=\"linestringfield\">\n<h3><code class=\"docutils literal notranslate\"><span class=\"pre\">Línestringfield</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>Stórais a: aicme: ~django.contrib.gis.geos.lineString.</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>Stórais a: aicme: ~django.contrib.gis.geos.polygon.</p>\n</section>\n<section id=\"multipointfield\">\n<h3><code class=\"docutils literal notranslate\"><span class=\"pre\">Réimse</span> <span class=\"pre\">Ilphoint</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>Stórais a: aicme: ~django.contrib.gis.geos.multipoint.</p>\n</section>\n<section id=\"multilinestringfield\">\n<h3><code class=\"docutils literal notranslate\"><span class=\"pre\">Páirc</span> <span class=\"pre\">Illíneach</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>Stórais a: aicme: ~django.contrib.gis.geos.multilineString.</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>Stórais a: aicme: ~django.contrib.gis.geos.multipolygon.</p>\n</section>\n<section id=\"geometrycollectionfield\">\n<h3><code class=\"docutils literal notranslate\"><span class=\"pre\">Réimse</span> <span class=\"pre\">Bailiúcháin</span> <span class=\"pre\">Geoimetrach</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>Stórais a: aicme: ~django.contrib.gis.geos.geometryCollection.</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>Stórais a:aicme: ~django.contrib.gis.gdal.gdalraster.</p>\n<p>Ní chuirtear <a href=\"#id1\"><span class=\"problematic\" id=\"id2\">`</span></a>Rasterfield <a href=\"#id3\"><span class=\"problematic\" id=\"id4\">``</span></a>i bhfeidhm faoi láthair ach amháin don chúltaca PostGIS.</p>\n</section>\n</section>\n<section id=\"spatial-field-options\">\n<h2>Roghanna Réimse spásúla<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>Chomh maith leis na rialt:ref: common-model-field-options atá ar fáil do réimsí samhail Django, tá na roghanna breise seo a leanas ag réimsí spásúla. Tá gach ceann roghnach.</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>Socraíonn an SRID [#fnogcsrid] _ (Aitheantas Córais Tagartha Spásúil) an réimse geoiméadrach don luach a thugtar. Réamhshocraithe go 4326 (ar a dtugtar <a class=\"reference external\" href=\"https://en.wikipedia.org/wiki/WGS84\">WGS84</a> freisin, tá aonaid i gcéimeanna fadmhéad agus domhanleithead).</p>\n<section id=\"selecting-an-srid\">\n<span id=\"id6\"></span><h4>SRID a roghnú<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\">Note</p>\n<p>&lt;geography-type&gt;Más mian leat ceisteanna achair treallacha a dhéanamh ag baint úsáide as geoiméadraí neamh-phointe i WGS84 i PostGIS agus ba mhaith leat feidhmíocht mhaith, cumasaigh an eochairfhocal: attr: Geometryfield.geography ionas go n-úsáidtear: ref: <a href=\"#id1\"><span class=\"problematic\" id=\"id2\">`</span></a>cineál bunachar sonraí tíreolaíochta <a href=\"#id3\"><span class=\"problematic\" id=\"id4\">`</span></a>ina ionad.</p>\n</aside>\n<p>Acmhainní Breise:</p>\n<ul class=\"simple\">\n<li><p><a class=\"reference external\" href=\"https://spatialreference.org/\">spatialreference.org</a>: Bunachar sonraí faoi thiomáint Django de chórais tagartha spásúla.</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\">Innéacsa_spáis</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\">Note</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>Roghanna Réimse Céim<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>Tá roghanna breise ar fáil do réimsí Geoiméadra. Tá na roghanna seo a leanas go léir roghnach.</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\">Note</p>\n<p>Ag an am seo tá tacaíocht 3D teoranta do na cúltaca PostGIS agus Spatialite.</p>\n</aside>\n</section>\n<section id=\"geography\">\n<h3><code class=\"docutils literal notranslate\"><span class=\"pre\">Geografa</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\">Note</p>\n<p>Tá tacaíocht tíreolaíochta teoranta do PostGIS agus cuirfidh sé iallach ar an SRID a bheith 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=\"/ga/6.0/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=\"(in 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>Cineál Tíreolaíochta<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>Toisc go bhfuil níos mó matamaitice i gceist le ríomhanna tíreolaíochta, níl ach fo-thacar de na cuardaigh spásúla PostGIS ar fáil don chineál tíreolaíochta. &lt;spatial-lookups&gt;Go praiticiúil, &lt;distance-lookups&gt;ciallaíonn sé seo nach bhfuil ach na cuardach breise seo a leanas: ref: cuardaigh spásúla `ar fáil do cholúin tíreolaíochta, i dteann:ref: `cuardach achair:</p>\n<ul class=\"simple\">\n<li><p><a class=\"reference internal\" href=\"/ga/6.0/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=\"/ga/6.0/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=\"/ga/6.0/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=\"/ga/6.0/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>Más gá duit cuardach spásúil nó comhiomlán a úsáid nach dtacaíonn leis an gcineál tíreolaíochta mar ionchur, is féidir leat feidhm bhunachar sonraí: class: <a href=\"#id1\"><span class=\"problematic\" id=\"id2\">`</span></a>~django.db.Models.functions.cast a úsáid chun an colún tíreolaíochta a thiontú go cineál geoiméadrach san fhiosrúchán:</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\">Fonótaí</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 href=\"#id18\"><span class=\"problematic\" id=\"id19\">`Sonraíocht Gné Simplí Do SQL`_</span></a>. &lt; <a class=\"reference external\" href=\"https://www.ogc.org/standard/sfs/\">https://www.ogc.org/standard/sfs/</a>&gt;</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>Féach id.</em> ag Ch. 2.3.8, lch. 39 (Luachanna Coiméadrachta agus Córais Tagartha Spásúla).</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>Cartografaíocht Téamach agus Amharc Geografach</em> (Halla Prentice, 2ú eagrán), ag Ch. 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>Ní bhaineann an teorannú seo le 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>Féach do thoil do dhoiciméadú <a href=\"#id1\"><span class=\"problematic\" id=\"id2\">`</span></a>Cineál Tíreolaíochta PostGIS <a href=\"#id3\"><span class=\"problematic\" id=\"id4\">`</span></a>_ le haghaidh tuilleadh son&lt; <a class=\"reference external\" href=\"https://postgis.net/docs/using_postgis_dbmanagement.html#PostGIS_Geography\">https://postgis.net/docs/using_postgis_dbmanagement.html#PostGIS_Geography</a>&gt; raí.</p>\n</aside>\n</aside>\n</section>\n</section>\n</section>","rootId":"module-django.contrib.gis.db.models","toc":[{"title":"Cineálacha Réimse spású","anchor":"spatial-field-types","children":[{"title":"Réimse Geoiméadraithe","anchor":"geometryfield","children":[]},{"title":"Pointfield","anchor":"pointfield","children":[]},{"title":"Línestringfield","anchor":"linestringfield","children":[]},{"title":"Polygonfield","anchor":"polygonfield","children":[]},{"title":"Réimse Ilphoint","anchor":"multipointfield","children":[]},{"title":"Páirc Illíneach","anchor":"multilinestringfield","children":[]},{"title":"Multipolygonfield","anchor":"multipolygonfield","children":[]},{"title":"Réimse Bailiúcháin Geoimetrach","anchor":"geometrycollectionfield","children":[]},{"title":"Rasterfield","anchor":"rasterfield","children":[]}]},{"title":"Roghanna Réimse spásúla","anchor":"spatial-field-options","children":[{"title":"Srid","anchor":"srid","children":[{"title":"SRID a roghnú","anchor":"selecting-an-srid","children":[]}]},{"title":"Innéacsa_spáis","anchor":"spatial-index","children":[]}]},{"title":"Roghanna Réimse Céim","anchor":"geometry-field-options","children":[{"title":"`dim","anchor":"dim","children":[]},{"title":"Geografa","anchor":"geography","children":[]},{"title":"max_geom_collections","anchor":"max-geom-collections","children":[{"title":"Cineál Tíreolaíochta","anchor":"geography-type","children":[]}]}]}],"breadcrumbs":[{"docname":"ref/index","title":"Tagairt API","url":"/ga/6.0/ref/"},{"docname":"ref/contrib/index","title":"Pacáistí contrib","url":"/ga/6.0/ref/contrib/"},{"docname":"ref/contrib/gis/index","title":"GeodJango","url":"/ga/6.0/ref/contrib/gis/"}],"prev":{"docname":"ref/contrib/gis/install/spatialite","title":"Suiteáil SpatiaLite","url":"/ga/6.0/ref/contrib/gis/install/spatialite/"},"next":{"docname":"ref/contrib/gis/db-api","title":"API Bunachar Sonraí GeodJango","url":"/ga/6.0/ref/contrib/gis/db-api/"},"formats":{"html":"/ga/6.0/ref/contrib/gis/model-api/","markdown":"/ga/6.0/ref/contrib/gis/model-api.md","json":"/ga/6.0/ref/contrib/gis/model-api.json"},"source":"https://github.com/django/django/blob/stable/6.0.x/docs/ref/contrib/gis/model-api.txt","official":"https://docs.djangoproject.com/ga/6.0/ref/contrib/gis/model-api/","inVersions":["6.1","6.0","5.2"],"inLocales":["en","sv","zh-hans","ga","fr","ja","id","it","pt-br","ko","es","el","pl"]}