---
title: "GEOS API"
version: 6.1
locale: ga
source: https://docs.djangoproject.com/ga/6.1/ref/contrib/gis/geos/
canonical: https://djangodocs.dev/ga/6.1/ref/contrib/gis/geos/
---
# GEOS API

## Cúlra

### Cad é GEOS?

[GEOS](https://libgeos.org/) stands for **Geometry Engine - Open Source**,
and is a C++ library, ported from the  [Java Topology Suite](https://sourceforge.net/projects/jts-topo-suite/). GEOS
implements the OpenGIS [Simple Features for SQL](https://www.ogc.org/standard/sfs/) spatial predicate functions
and spatial operators. GEOS, now an OSGeo project, was initially developed and
maintained by [Refractions Research](http://www.refractions.net/) of Victoria, Canada.

### Gnéithe

Cuireann GeodJango fillteán Python ardleibhéil i bhfeidhm don leabharlann GEOS, tá a ghnéithe tá:

- Comhéadan ceadúnaithe BSD le gnáthaimh geoiméadachta GEOS, a chuirtear i bhfeidhm i Python amháin ag baint úsáide as ctype\`.
- Loosely-coupled to GeoDjango. For example, [`GEOSGeometry`](#django.contrib.gis.geos.GEOSGeometry) objects
  may be used outside of a Django project/application. In other words,
  no need to have [`DJANGO_SETTINGS_MODULE`](/ga/6.1/topics/settings/#envvar-DJANGO_SETTINGS_MODULE) set or use a database, etc.
- Is féidir athraitheacht: :class: rudaí Geosgeometry a mhodhnú.
- Cross-platform tested.

## Ranganna teagaisc

Sa chuid seo tá réamhrá gairid agus teagaisc teagaisc maidir le rudaí: aicme: GeosGeometry a úsáid.

### Coiméadras a chruthú

[`GEOSGeometry`](#django.contrib.gis.geos.GEOSGeometry) objects may be created in a few ways. The first is
to simply instantiate the object on some spatial input -- the following
are examples of creating the same geometry from WKT, HEX, WKB, and GeoJSON:

```pycon
>>> from django.contrib.gis.geos import GEOSGeometry
>>> pnt = GEOSGeometry("POINT(5 23)")  # WKT
>>> pnt = GEOSGeometry("010100000000000000000014400000000000003740")  # HEX
>>> pnt = GEOSGeometry(
...     memoryview(
...         b"\x01\x01\x00\x00\x00\x00\x00\x00\x00\x00\x00\x14@\x00\x00\x00\x00\x00\x007@"
...     )
... )  # WKB
>>> pnt = GEOSGeometry(
...     '{ "type": "Point", "coordinates": [ 5.000000, 23.000000 ] }'
... )  # GeoJSON
```

Another option is to use the constructor for the specific geometry type
that you wish to create. For example, a [`Point`](#django.contrib.gis.geos.Point) object may be
created by passing in the X and Y coordinates into its constructor:

```pycon
>>> from django.contrib.gis.geos import Point
>>> pnt = Point(5, 23)
```

Glacann na tógálaí seo go léir an argóint eochairfhocal `srid`. Mar shampla:

```pycon
>>> from django.contrib.gis.geos import GEOSGeometry, LineString, Point
>>> print(GEOSGeometry("POINT (0 0)", srid=4326))
SRID=4326;POINT (0 0)
>>> print(LineString((0, 0), (1, 1), srid=4326))
SRID=4326;LINESTRING (0 0, 1 1)
>>> print(Point(0, 0, srid=32140))
SRID=32140;POINT (0 0)
```

Faoi dheireadh, tá an modh monarcha:func: fromfile ann a thugann réad a:class: GeosGeometry ó chomhad:

```pycon
>>> from django.contrib.gis.geos import fromfile
>>> pnt = fromfile("/path/to/pnt.wkt")
>>> pnt = fromfile(open("/path/to/pnt.wkt"))
```

> **Líontar mo logaí le hearráidí a bhaineann le Geos**
>
> Faigheann tú go leor eisceachtaí `TypeError` nó `AttributeError` ag líonadh comhaid log do fhreastalaí gréasáin. Ciallaíonn sé seo go ginearálta go bhfuil tú ag cruthú rudaí GEOS ag barrleibhéal cuid de do mhodúil Python. Ansin, mar gheall ar riocht rása sa bhailitheoir truflais, bailítear do mhodúl truflais roimh réad GEOS. Chun é seo a chosc, cruthaigh rudaí:class: GeosGeometry taobh istigh de raon feidhme áitiúil do fheidhmeanna/modhanna.

### Is iad na geoiméadraí Pythonic

[`GEOSGeometry`](#django.contrib.gis.geos.GEOSGeometry) objects are 'Pythonic', in other words components may
be accessed, modified, and iterated over using standard Python conventions.
For example, you can iterate over the coordinates in a [`Point`](#django.contrib.gis.geos.Point):

```pycon
>>> pnt = Point(5, 23)
>>> [coord for coord in pnt]
[5.0, 23.0]
```

Le haon réad geoiméadrach, is féidir an maoin: attr: Geosgeometry.coords a úsáid chun na comhordanáidí geoiméadrachta a fháil mar thúpla Python:

```pycon
>>> pnt.coords
(5.0, 23.0)
```

You can get/set geometry components using standard Python indexing
techniques. However, what is returned depends on the geometry type
of the object. For example, indexing on a [`LineString`](#django.contrib.gis.geos.LineString)
returns a coordinate tuple:

```pycon
>>> from django.contrib.gis.geos import LineString
>>> line = LineString((0, 0), (0, 50), (50, 50), (50, 0), (0, 0))
>>> line[0]
(0.0, 0.0)
>>> line[-2]
(50.0, 0.0)
```

Cé go gcuirfidh innéacsú ar a: aicme: Polygon an fáinne (a: aicme: Línearing réad) a fhreagraíonn don innéacs ar ais:

```pycon
>>> from django.contrib.gis.geos import Polygon
>>> poly = Polygon(((0.0, 0.0), (0.0, 50.0), (50.0, 50.0), (50.0, 0.0), (0.0, 0.0)))
>>> poly[0]
<LinearRing object at 0x1044395b0>
>>> poly[0][-2]  # second-to-last coordinate of external ring
(50.0, 0.0)
```

Ina theannta sin, féadfar comhordáití/comhpháirteanna an geoiméadrachta a chur leis nó a mhodhnú, díreach cosúil le liosta

```pycon
>>> line[0] = (1.0, 1.0)
>>> line.pop()
(0.0, 0.0)
>>> line.append((1.0, 1.0))
>>> line.coords
((1.0, 1.0), (0.0, 50.0), (50.0, 50.0), (50.0, 0.0), (1.0, 1.0))
```

Tacaíonn geoiméadraí le hoibreoirí cosúil le tac

```pycon
>>> from django.contrib.gis.geos import LineString
>>> ls1 = LineString((0, 0), (2, 2))
>>> ls2 = LineString((1, 1), (3, 3))
>>> print(ls1 | ls2)  # equivalent to `ls1.union(ls2)`
MULTILINESTRING ((0 0, 1 1), (1 1, 2 2), (2 2, 3 3))
>>> print(ls1 & ls2)  # equivalent to `ls1.intersection(ls2)`
LINESTRING (1 1, 2 2)
>>> print(ls1 - ls2)  # equivalent to `ls1.difference(ls2)`
LINESTRING(0 0, 1 1)
>>> print(ls1 ^ ls2)  # equivalent to `ls1.sym_difference(ls2)`
MULTILINESTRING ((0 0, 1 1), (2 2, 3 3))
```

> **Ní sheiceálann oibreoir comhionannas spásúil**
>
> Úsáideann an oibreoir comhionannais: Class: ~GeosGeometry: meth: ~Geosgeometry.Equals\_exact, not:meth: ~GeosGeometry.EQUALS, ie éilíonn sé go mbeadh na comhordanáidí céanna ag na comhordanáidí céanna sna suíomhanna céanna leis na SRIDanna céanna:
>
> ```pycon
> >>> from django.contrib.gis.geos import LineString
> >>> ls1 = LineString((0, 0), (1, 1))
> >>> ls2 = LineString((1, 1), (0, 0))
> >>> ls3 = LineString((1, 1), (0, 0), srid=4326)
> >>> ls1.equals(ls2)
> True
> >>> ls1 == ls2
> False
> >>> ls3 == ls2  # different SRIDs
> False
> ```

## Rudaí Geoiméad

### Geoiméadracht \`\`

#### `class GEOSGeometry(geo_input, srid=None, * (Keyword-only parameters separator (PEP 3102)), max_geom_collections=198)`

**Paraiméadair:** - `geo_input` -- Luach ionchuir geoiméadais (teaghrán nó: aicme: memoryview)
- `srid` ([`int`](https://docs.python.org/3/library/functions.html#int)) -- aitheantas tagartha spásúil
- `max_geom_collections` -- maximum number of nested (WKT) or total (WKB)
  geometry collections accepted before parsing is refused

This is the base class for all GEOS geometry objects. It initializes on the
given `geo_input` argument, and then assumes the proper geometry subclass
(e.g., `GEOSGeometry('POINT(1 1)')` will create a [`Point`](#django.contrib.gis.geos.Point) object).

Socraítear an paraiméadar `srid`, má thugtar é, mar SRID an geoiméadra cruthaithe mura bhfuil SRID ag geo\_input\`. Má chuirtear SRIDanna éagsúla ar fáil tríd na paraiméadair geo\_input\` agus `srid`, ardaítear `LuaeError`:

```pycon
>>> from django.contrib.gis.geos import GEOSGeometry
>>> GEOSGeometry("POINT EMPTY", srid=4326).ewkt
'SRID=4326;POINT EMPTY'
>>> GEOSGeometry("SRID=4326;POINT EMPTY", srid=4326).ewkt
'SRID=4326;POINT EMPTY'
>>> GEOSGeometry("SRID=1;POINT EMPTY", srid=4326)
Traceback (most recent call last):
...
ValueError: Input geometry already has SRID: 1.
```

Glactar leis na formáidí ionchuir seo a leanas, mar aon lena gcineálacha comhfhreagracha Python:

| Formáid | Cineál Ionchuir |
| --- | --- |
| WKT/EWKT | `` `str `` |
| HEICSEACH/HEXEWKB | `` `str `` |
| WKB/EWKB | `amharc cuimhneach` |
| \<7946\>:rfc: GeoJSON \` | `` `str `` |

Maidir leis an bhformáid GeoJSON, socraítear an SRID bunaithe ar an bhall `crs`. Mura gcuirtear `crs` ar fáil, réamhshocraíonn an SRID go 4326.

> **Changed in Django 5.2.17**
>
> The `max_geom_collections` parameter was added.

#### `classmethod GEOSGeometry.from_gml(gml_string)`

Tógann a: aicme: Geosgeometry ón sreang GML a thugtar.

#### Airíonna

#### `GEOSGeometry.coords`

Tugann comhordanáidí an ghéimseadrachta ar ais mar thuple.

#### `GEOSGeometry.dims`

Tugann sé gné an geoiméadrachta ar ais:

- `0` le haghaidh: aicme: Points agus:aicme: Multipoints
- `1` le haghaidh: aicme: LíneStrings agus:aicme: Multilinestrings
- `2` le haghaidh: aicme: Polygons agus:aicme: Multipolygons
- `-1` le haghaidh folam:class: GeometryCollections
- gné uasta a chuid eilimintí le haghaidh neamh-fholm:class: GeometryCollections

#### `GEOSGeometry.empty`

Tugann sé ar ais cibé an bhfuil an tacar pointí sa ghéiméadracht folamh nó nach bhfuil.

#### `GEOSGeometry.geom_type`

Returns a string corresponding to the type of geometry. For example:

```pycon
>>> pnt = GEOSGeometry("POINT(5 23)")
>>> pnt.geom_type
'Point'
```

#### `GEOSGeometry.geom_typeid`

Returns the GEOS geometry type identification number. The following table
shows the value for each geometry type:

| Coiméadras | ID |
| --- | --- |
| [`Point`](#django.contrib.gis.geos.Point) | 0 |
| [`LineString`](#django.contrib.gis.geos.LineString) | 1 |
| [`LinearRing`](#django.contrib.gis.geos.LinearRing) | 2 |
| [`Polygon`](#django.contrib.gis.geos.Polygon) | 3 |
| [`MultiPoint`](#django.contrib.gis.geos.MultiPoint) | 4 |
| [`MultiLineString`](#django.contrib.gis.geos.MultiLineString) | 5 |
| [`MultiPolygon`](#django.contrib.gis.geos.MultiPolygon) | 6 |
| [`GeometryCollection`](#django.contrib.gis.geos.GeometryCollection) | 7 |

#### `GEOSGeometry.num_coords`

Filleann líon na gcomhordanáidí sa ghéiméadracht.

#### `GEOSGeometry.num_geom`

Returns the number of geometries in this geometry. In other words, will
return 1 on anything but geometry collections.

#### `GEOSGeometry.hasz`

Returns a boolean indicating whether the geometry has the Z dimension.

#### `GEOSGeometry.hasm`

> **New in Django 6.0**

Returns a boolean indicating whether the geometry has the M dimension.
Requires GEOS 3.12.

#### `GEOSGeometry.ring`

Tugann sé boolean a thugann le fios an bhfuil an geoiméadra ina Línearing\`.

#### `GEOSGeometry.simple`

Returns a boolean indicating whether the geometry is 'simple'. A geometry
is simple if and only if it does not intersect itself (except at boundary
points). For example, a [`LineString`](#django.contrib.gis.geos.LineString) object is not simple if it
intersects itself. Thus, [`LinearRing`](#django.contrib.gis.geos.LinearRing) and [`Polygon`](#django.contrib.gis.geos.Polygon) objects
are always simple because they cannot intersect themselves, by definition.

#### `GEOSGeometry.valid`

Tugann sé boolean ar ais a thugann le fios an bhfuil an geoiméadracht bailí.

#### `GEOSGeometry.valid_reason`

Tugann teaghrán ar ais ag cur síos ar an gcúis go bhfuil geoiméadacht neamhbhail

#### `GEOSGeometry.srid`

Property that may be used to retrieve or set the SRID associated with the
geometry. For example:

```pycon
>>> pnt = Point(5, 23)
>>> print(pnt.srid)
None
>>> pnt.srid = 4326
>>> pnt.srid
4326
```

#### Airíonna Aschuir

The properties in this section export the [`GEOSGeometry`](#django.contrib.gis.geos.GEOSGeometry) object into
a different. This output may be in the form of a string, buffer, or even
another object.

#### `GEOSGeometry.ewkt`

Returns the "extended" Well-Known Text of the geometry. This representation
is specific to PostGIS and is a superset of the OGC WKT standard. [^1]
Essentially the SRID is prepended to the WKT representation, for example
`SRID=4326;POINT(5 23)`.

> **Note**
>
> Ní chuimsíonn an t-aschur ón maoin seo an fhaisnéis 3dm, 3dz, agus 4d a dtacaíonn PostGIS ina ionadaíochtaí EWKT.

#### `GEOSGeometry.hex`

Returns the WKB of this Geometry in hexadecimal form. Please note
that the SRID value is not included in this representation
because it is not a part of the OGC specification (use the
[`GEOSGeometry.hexewkb`](#django.contrib.gis.geos.GEOSGeometry.hexewkb) property instead).

#### `GEOSGeometry.hexewkb`

Returns the EWKB of this Geometry in hexadecimal form. This is an
extension of the WKB specification that includes the SRID value
that are a part of this geometry.

#### `GEOSGeometry.json`

Tugann ionadaíocht GeoJSON ar an geoiméadra ar ais. Tabhair faoi deara nach struchtúr iomlán GeoJSON é an toradh ach ach príomhábhar “geoiméadracht” de struchtúr GeoJSON amháin. Féach freis:doc: /ref/contrib/gis/serializers.

#### `GEOSGeometry.geojson`

Alias le haghaidh: attr: GeosGeometry.JSON.

#### `GEOSGeometry.kml`

Returns a [KML](https://developers.google.com/kml/documentation/) (Keyhole Markup Language) representation of the
geometry. This should only be used for geometries with an SRID of
4326 (WGS84), but this restriction is not enforced.

#### `GEOSGeometry.ogr`

Tugann sé ar:class: ~django.contrib.gis.gdal.ogrGeometry réad a fhreagraíonn don geoiméadacht GEOS.

#### `GEOSGeometry.wkb`

Returns the WKB (Well-Known Binary) representation of this Geometry
as a Python buffer. SRID value is not included, use the
[`GEOSGeometry.ewkb`](#django.contrib.gis.geos.GEOSGeometry.ewkb) property instead.

#### `GEOSGeometry.ewkb`

Tabhair ar ais ionadaíocht EWKB an Céiméadracht seo mar mhaolán Python. Is síneadh é seo ar shonraíocht WKB a chuimsíonn aon luach SRID atá mar chuid den ghéiméadracht seo.

#### `GEOSGeometry.wkt`

Tugann sé an Téacs Aitheanta den ghéiméadracht (caighdeán OGC) ar ais.

#### Modhanna Predicate Spásúla

Glacann gach ceann de na modhanna réamhdhéanta spásúla seo a leanas eile: class: Geosgeometry (eile ) mar pharaiméadar, agus cuireann sé boolean ar ais.

#### `GEOSGeometry.contains(other)`

\<GEOSGeometry.within\>Tuairisceann `True` ife:meth: other.within (this) \`filleann \`\`True\`.

#### `GEOSGeometry.covers(other)`

Tugann sé ar ais `True` má chlúdaíonn an geoiméadacht seo an geoiméadra sonraithe.

Tá na sainmhínithe coibhéiseach seo a leanas ag an réamhchúiseach `clúdaithe`

- Is pointe den ghéiméadracht seo é gach pointe den ghéimseadracht eile.
- Is é T\*\*\*\*\*FF\*\`, `*T****FF*`, `***T**FF*`, `***T**FF*`, \*\*\*T\*\*FF\*\`, nó `****T*FF*`.

Má tá ceachtar geoiméadair folamh, filleann sé `False`.

Tá an predicate seo cosúil le:meth: Geosgeometry.contains, ach tá sé níos cuimsitheach (ie tuairisceann `True` le haghaidh tuilleadh cásanna). Go háirithe, nach cosúil:meth: ~ Geosgeometry.Contains ní dhéanann sé idirdhealú idir pointí sa teorainn agus ar an taobh istigh de na geoiméadraí. Maidir le formhór na gcásanna, ba chóir go mbeadh clúdaigh () \`\`níos fearr ná: meth: \`~ Geosgeometry.contains. Mar shochar breise, tá clúdaigh () níos inúsáidte le barrfheabhsú agus dá bhrí sin ba chóir go mbeadh feidhm níos faide ná: meth: ~Geosgeometry.contains.

#### `GEOSGeometry.crosses(other)`

Tugann sé ar ais `True` más é T\*T\*\*\*\*\*\*\` an maitrís trasna DE-9IM don dá Geoiméadair ```(le haghaidh pointe agus cuar, pointe agus limistéar nó líne agus limistéar) ``0********``` (le haghaidh dhá chuar).

#### `GEOSGeometry.disjoint(other)`

Tugann sé ar ais `True` más é FF\*FF\*\*\*\*\` an maitrís trasna DE-9IM don dá ghéiméadracht.

#### `GEOSGeometry.equals(other)`

Tugann sé ar ais `True` más é T\* F\*\*FFF\*\` an maitrís trasna DE-9IM don dá ghéiméadracht.

#### `GEOSGeometry.equals_exact(other, tolerance=0)`

Returns true if the two geometries are exactly equal, up to a
specified tolerance. The `tolerance` value should be a floating
point number representing the error tolerance in the comparison, e.g.,
`poly1.equals_exact(poly2, 0.001)` will compare equality to within
one thousandth of a unit.

#### `GEOSGeometry.equals_identical(other)`

Tugann sé “Fíor” ar ais má tá an dá ghéiméadracht coibhéiseach pointe trí sheiceáil go bhfuil struchtúr, ordú agus luachanna gach beart comhionann i ngach toise. Meastar go bhfuil luachanna `Nan` comhionann le luachanna `Nan` eile. Éilíonn GEOS 3.12.

#### `GEOSGeometry.intersects(other)`

Tuairisceann `True` ife:meth: Geosgeometry.disjoint `False`.

#### `GEOSGeometry.overlaps(other)`

Tugann sé fíor más é an maitrís trasna DE-9IM don dá ghéiméadracht `T*T***T**` (le haghaidh dhá phointe nó dhá dhromchla) `1* T***T**` (le haghaidh dhá chuar).

#### `GEOSGeometry.relate_pattern(other, pattern)`

Tugann `True` ar ais má mheaitríonn na heilimintí i maitrís trasna DE-9IM don ghéiméadracht seo agus an ceann eile leis an ```patrún ``a thugtar -- sreang de naoi charachtar ón aibítir: {``T```, F\`, \*\`, 0\`}.

#### `GEOSGeometry.touches(other)`

Tugann sé ar ais `True` más é FT\*\*\*\*\*\*\*\`, F\*\*T\*\*\*\*\*\` nó `F***T****` nó `F***T****` an maitrís trasna DE-9IM don dá ghéiméadracht.

#### `GEOSGeometry.within(other)`

Tugann sé ar ais `True` más é T\*F\*\*F\*\*\*\` an maitrís trasna DE-9IM don dá ghéiméadracht `T*F**F***`.

#### Modhanna Topolaíocha

#### `GEOSGeometry.buffer(width, quadsegs=8)`

Tuairisceáin a:aicme: Geosgeoiméadr a léiríonn gach pointe a bhfuil a n-achar ón gcéiméadra seo níos lú ná nó cothrom leis an leithead a thugtar. Socraíonn an eochairfhocal roghnach quadsegs' líon na ndeighleoga a úsáidtear chun ceathrú ciorcal a mheas (is é 8 na réamhshocraithe).

#### `GEOSGeometry.buffer_with_style(width, quadsegs=8, end_cap_style=1, join_style=1, mitre_limit=5.0)`

Mar an gcéanna le: meth: maolán , ach ceadaíonn sé stíl an maoláin a shaincheapadh.

- Is féidir le `end_cap_style` a bheith cruinn (`1`), cothrom (`2`), nó cearnach (`3`).
- Is féidir le `join_style` a bheith cruinn (`1`), mitre (`2`), nó bevel (`3`).
- Níl i bhfeidhm ach ar an teorainn cóimheas mitre (mitre\_limit\`) ar stíl comhcheangail mitre.

#### `GEOSGeometry.difference(other)`

Tuairisceáin a: aicme: GeosGeometry a léiríonn na pointí a chuimsíonn an geoiméadracht seo nach ndéanann suas eile.

#### `GEOSGeometry.interpolate(distance)`

#### `GEOSGeometry.interpolate_normalized(distance)`

Mar gheall ar achar (snámhphointe), filleann sé an pointe (nó an pointe is gaire) laistigh den ghéiméadracht (:class: Linestring nó:class: MultilineString) ag an achar sin. Tógann an leagan normalaithe an fad mar snámhphointe idir 0 (tionscnamh) agus 1 (críochphointe).

Iomsaigh de:meth: Geosgeometry.Project.

#### `GEOSGeometry.intersection(other)`

Tuairisceáin a: aicme: GeosGeometry a léiríonn na pointí atá roinnte ag an geoiméadacht seo agus eile.

#### `GEOSGeometry.project(point)`

#### `GEOSGeometry.project_normalized(point)`

Filleann sé an fad (snámhphointe) ó bhunús an ghéiméadrachta (:class: Linestring nó:class: MultilineString) go dtí an pointe a réamhaítear ar an geoiméadra (is é sin go pointe den líne is gaire don phointe ar leith). Tugann an leagan normalaithe an fad ar ais mar snámhphointe idir 0 (tionscnamh) agus 1 (críochphointe).

Iomsaigh de:meth: Geosgeometry.interpolate.

#### `GEOSGeometry.relate(other)`

Filleann sé an maitrís trasna DE-9IM (sreang) a léiríonn an gaol topolaíoch idir an geoiméadacht seo agus an ceann eile.

#### `GEOSGeometry.simplify(tolerance=0.0, preserve_topology=False)`

Filleann sé nua:class: GeosGeometry, a shimpliú go dtí an lamháltas sonraithe ag baint úsáide as an algartam Douglas-Peucker. Tugann luach lamháltais níos airde le tuiscint níos lú pointí san aschur. Mura gcuirtear aon lamháltas ar fáil, réamhshocraíonn sé go 0.

De réir réamhshocraithe, ní chaomhnóidh an fheidhm seo topolaíocht. Mar shampla, :class: Is féidir rudaí Polygon a roinnt, iad a thitim ina línte, nó imeacht. :class: Is féidir poill Polygon a chruthú nó a imirt, agus féadfaidh línte trasnú. Trí shonrú `preserve_topology=True`, beidh an toise agus an líon comhpháirteanna céanna ag an toradh leis an ionchur; tá sé seo i bhfad níos moille, áfach.

#### `GEOSGeometry.sym_difference(other)`

Tuairisceáin a: aicme: GeosGeometry a chomhcheanglaíonn na pointí sa ghéimseadracht seo nach bhfuil i bpointí eile, agus na pointí eile nach bhfuil sa ghéiméadracht seo.

#### `GEOSGeometry.union(other)`

Tuairisceáin a: aicme: GeosGeometry a léiríonn na pointí go léir sa ghéimseadracht seo agus an ceann eile.

#### Airíonna Topolaíocha

#### `GEOSGeometry.boundary`

Tugann sé an teorainn ar ais mar réad Coiméadra nua-leithdháil

#### `GEOSGeometry.centroid`

Returns a [`Point`](#django.contrib.gis.geos.Point) object representing the geometric center of
the geometry. The point is not guaranteed to be on the interior
of the geometry.

#### `GEOSGeometry.convex_hull`

Filleann sé an beag:class: Polygon ina bhfuil na pointí go léir sa ghéimseadracht.

#### `GEOSGeometry.envelope`

Tuairisceáin a: aicme: Polygon a léiríonn clúdach teorainneach an geoiméadair seo. Tabhair faoi deara gur féidir leis a: class: Point a thabhairt ar ais freisin más pointe é an geoiméadra ionchuir.

#### `GEOSGeometry.point_on_surface`

Ráthaítear go mbeidh Point ar an taobh istigh den ghéiméadracht seo a ríomh agus tuairisceann a: aicme: Point

#### `GEOSGeometry.unary_union`

Ríomhann aontas na n-eilimintí uile den ghéiméadracht seo.

Cloíonn an toradh don chonradh seo a leanas:

- Tá an éifeacht ag aontú tacar de:class: Linestrings an obair líne a nochtadh agus a dhíscaoileadh go hiomlán.
- Ag aontú sraith de:class: Polygons, tabharfar ar ais i gcónaí a:class: Polygon nó:class: Multipolygon geoiméadracht (gan amhail: meth: Geosgeometry.Union, a d'fhéadfadh geoiméadraí de ghné níos ísle a thabhairt ar ais má tharlaíonn titim topaolaíochta).

#### Airíonna & Modhanna Eile

#### `GEOSGeometry.area`

Tugann an maoin seo limistéar an Céiméadracht ar ais.

#### `GEOSGeometry.extent`

Tugann an maoin seo méid an geoiméadra seo ar ais mar 4-tuple, comhdhéanta de `(xmin, ymin, xmax, ymax)`.

#### `GEOSGeometry.clone()`

Tugann an modh seo a: class: GeosGeometry is clón den bhunaidh é.

#### `GEOSGeometry.distance(geom)`

Tugann sé an fad idir na pointí is gaire ar an geoiméadacht seo agus an geom\` a thugtar (rud eile: aicme: GeosGeometry réad).

> **Note**
>
> Tá ríomhanna achair GEOS líneach - is é sin le rá, ní dhéanann GEOS ríomh sféarúil fiú má shonraíonn an SRID córas comhordaithe geografach.

#### `GEOSGeometry.length`

Tugann sé ar ais fad an ghéiméadracht seo (m.sh., 0 do aicme a: Point, fad a: aicme a: LíneString, nó imlíne a:aicme: Polygon).

#### `GEOSGeometry.prepared`

Filleann GEOS `PrepareidGeometry` le haghaidh ábhar an geoiméadra seo. Déantar rudaí Geoiméadracht ullmhaithe “a bharrfheabhsú le haghaidh na n-ábhar, trasna, clúdaigh, croisí, neamhchoitianta, forluí, teagmhálacha agus laistigh d'oibríochtaí. Féach ar an doiciméadach:ref: ullmhai-geoiméadraitheach le haghaidh tuilleadh faisnéise.

#### `GEOSGeometry.srs`

Tuairisceáin a:class: ~django.contrib.gis.gdal.spatialReference réad a fhreagraíonn do SRID an geoiméadair nó `None`.

#### `GEOSGeometry.transform(ct, clone=False)`

Athraíonn sé an geoiméadra de réir an pharaiméadar claochlaithe comhordaithe tugtha (ct\`), a d'fhéadfadh a bheith ina SRID sláimhir, teaghrán spásúil WKT, teaghrán PROJ, a:class: ~django.contrib.gis.gdal.spatialReference réad, nó a:class: ~django.contrib.gis.gdal.coordTransform. De réir réamhshocraithe, déantar an geoiméadra a athrú in áit agus ní thugtar aon rud ar ais Mar sin féin má shocraítear an eochairfhocal “clón”, ansin ní mhodhnaítear an geoiméadra agus cuirtear clón claochlaithe den ghéiméadracht ar ais ina ionad sin.

> **Note**
>
> Ardaithe:Class: ~django.contrib.gis.geos.geosException mura bhfuil GDAL ar fáil nó má tá SRID an geoiméadra `None` nó níos lú ná 0. Ní chuireann sé aon srianta ar SRID an ghéiméadrachta má thugtar air le réad a:class: ~django.contrib.gis.gdal.coordTransform.

#### `GEOSGeometry.make_valid()`

Returns a valid [`GEOSGeometry`](#django.contrib.gis.geos.GEOSGeometry) equivalent, trying not to lose any of
the input vertices. If the geometry is already valid, it is returned
untouched. This is similar to the
[`MakeValid`](/ga/6.1/ref/contrib/gis/functions/#django.contrib.gis.db.models.functions.MakeValid) database
function.

#### `GEOSGeometry.normalize(clone=False)`

Athraíonn sé an geoiméadra seo go foirm canónach. Má shocraítear an eochairfhocal clón\`, ansin ní mhodhnaítear an geoiméadra agus cuirtear clón normalaithe den ghéimseata ar ais ina ionad sin:

```pycon
>>> g = MultiPoint(Point(0, 0), Point(2, 2), Point(1, 1))
>>> print(g)
MULTIPOINT (0 0, 2 2, 1 1)
>>> g.normalize()
>>> print(g)
MULTIPOINT (2 2, 1 1, 0 0)
```

### `Point`

#### `class Point(x=None, y=None, z=None, srid=None)`

Déantar rudaí `Point` a thionscnamh ag baint úsáide as argóintí a léiríonn comhordanáidí comhpháirteanna an phointe nó le comhordanáidí seicheamh amháin. Mar shampla, tá na nithe seo a leanas coibhéiseach:

```pycon
>>> pnt = Point(5, 23)
>>> pnt = Point([5, 23])
```

Féadfar rudaí folmha `Point` a chur isteach trí aon argóintí nó seicheamh folamh a chur ar aghaidh. Tá na nithe seo a leanas comhionann:

```pycon
>>> pnt = Point()
>>> pnt = Point([])
```

### `Línestring`

#### `class LineString(*args, **kwargs)`

Déantar rudaí LíneString\` a ionchasadh ag baint úsáide as argóintí atá ina seicheamh comhordanáidí nó: aicme: Point rudaí. Mar shampla, tá na nithe seo a leanas coibhéiseach:

```pycon
>>> ls = LineString((0, 0), (1, 1))
>>> ls = LineString(Point(0, 0), Point(1, 1))
```

Ina theannta sin, féadfar rudaí LíneString\` a chruthú freisin trí sheicheamh amháin de rudaí comhordaithe nó: aicme: Point a rith i seacham amháin:

```pycon
>>> ls = LineString(((0, 0), (1, 1)))
>>> ls = LineString([Point(0, 0), Point(1, 1)])
```

Féadfar rudaí folmha `LíneString` a thionscnamh trí aon argóintí nó seicheamh folamh a chur ar aghaidh. Tá na nithe seo a leanas comhionann:

```pycon
>>> ls = LineString()
>>> ls = LineString([])
```

#### `closed`

Tugann sé ar ais cibé an bhfuil an Linestring\` seo dúnta nó nach bhfuil.

### `Línear`

#### `class LinearRing(*args, **kwargs)`

Tógtar rudaí Línearing\` ar an mbealach céanna le rudaí: aicme: LíneString, ach caithfidh na comhordanáidí\* a bheith dúnta, is é sin le rá, caithfidh na chéad chomhordanáidí a bheith mar an gcéanna leis na comhordanáidí deireanacha. Mar shampla:

```pycon
>>> ls = LinearRing((0, 0), (0, 1), (1, 1), (0, 0))
```

Tabhair faoi deara gurb é `(0, 0)` an chéad chomhordú agus an comhordú deireanach - mura mbeadh siad comhionann, ardófaí earráid.

#### `is_counterclockwise`

Tugann sé ar ais cibé an bhfuil an Línearing\` seo i gcoinne.

### `Polygón`

#### `class Polygon(*args, **kwargs)`

`Polygon` objects may be instantiated by passing in parameters that
represent the rings of the polygon. The parameters must either be
[`LinearRing`](#django.contrib.gis.geos.LinearRing) instances, or a sequence that may be used to construct
a [`LinearRing`](#django.contrib.gis.geos.LinearRing):

```pycon
>>> ext_coords = ((0, 0), (0, 1), (1, 1), (1, 0), (0, 0))
>>> int_coords = ((0.4, 0.4), (0.4, 0.6), (0.6, 0.6), (0.6, 0.4), (0.4, 0.4))
>>> poly = Polygon(ext_coords, int_coords)
>>> poly = Polygon(LinearRing(ext_coords), LinearRing(int_coords))
```

#### `classmethod from_bbox(bbox)`

Tugann sé réad polagún ar ais ón mbosca teorainn a thugtar, 4 tuipéil ina bhfuil `(xmin, ymin, xmax, ymax)`.

#### `num_interior_rings`

Filleann líon na bhfáinní taobh istigh sa geoiméadracht seo.

> **Déan comparáid idir Polagáin**
>
> Tabhair faoi deara gur féidir rudaí `Polygon` a chur i gcomparáid go díreach le `<` nó `>`, ach de réir mar a dhéantar an comparáid trí Polygon's:class: Linestring, ní chiallaíonn sé mórán (ach tá sé comhsheasmhach agus tapa). Is féidir leat an comparáid a chur i gcónaí leis an maoin: attr: ~ Geosgeometry.Area:
>
> ```pycon
> >>> if poly_1.area > poly_2.area:
> ...     pass
> ...
> ```

## Bailiúcháin Gé

### `Ilphoint`

#### `class MultiPoint(*args, **kwargs)`

Féadfar rudaí `multipoint` a chur isteach trí rudaí: aicme: Point a rith mar argóintí, nó seicheamh amháin de:class: Point rudaí:

```pycon
>>> mp = MultiPoint(Point(0, 0), Point(1, 1))
>>> mp = MultiPoint((Point(0, 0), Point(1, 1)))
```

### `Multilinestring`

#### `class MultiLineString(*args, **kwargs)`

Féadfar rudaí `MultilineString` a chur isteach trí rudaí: class: Linestring a chur isteach mar argóintí, nó seicheamh amháin de:class: LineString rudaí:

```pycon
>>> ls1 = LineString((0, 0), (1, 1))
>>> ls2 = LineString((2, 2), (3, 3))
>>> mls = MultiLineString(ls1, ls2)
>>> mls = MultiLineString([ls1, ls2])
```

#### `merged`

Tuairisceáin a: aicme: LíneString a léiríonn cumasc líne na gcomhpháirteanna go léir sa Multilinestring\` seo.

#### `closed`

Tugann sé “Fíor” ar ais má tá gach eilimint dúnta agus amháin má tá gach eilimint dúnta.

### `Multipolygon`

#### `class MultiPolygon(*args, **kwargs)`

Féadfar rudaí Multipolygon\` a thionscnamh trí rudaí pas:class: Polygon mar argóintí, nó seicheamh amháin de:class: Polygon rudaí:

```pycon
>>> p1 = Polygon(((0, 0), (0, 1), (1, 1), (0, 0)))
>>> p2 = Polygon(((1, 1), (1, 2), (2, 2), (1, 1)))
>>> mp = MultiPolygon(p1, p2)
>>> mp = MultiPolygon([p1, p2])
```

### `Bailiúchán Geoiméadrach`

#### `class GeometryCollection(*args, **kwargs)`

Féadfar rudaí `Geoimetrach` a thionscnamh trí:class: GeosGeometry eile a rith mar argóintí, nó seicheamh amháin de:class: Geosgeoimetrry rudaí:

```pycon
>>> poly = Polygon(((0, 0), (0, 1), (1, 1), (0, 0)))
>>> gc = GeometryCollection(Point(0, 0), MultiPoint(Point(0, 0), Point(1, 1)), poly)
>>> gc = GeometryCollection((Point(0, 0), MultiPoint(Point(0, 0), Point(1, 1)), poly))
```

## Geoiméadraí ullmhai

In order to obtain a prepared geometry, access the
[`GEOSGeometry.prepared`](#django.contrib.gis.geos.GEOSGeometry.prepared) property. Once you have a `PreparedGeometry`
instance its spatial predicate methods, listed below, may be used with other
`GEOSGeometry` objects. An operation with a prepared geometry can be orders
of magnitude faster -- the more complex the geometry that is prepared, the
larger the speedup in the operation. For more information, please consult the
[GEOS wiki page on prepared geometries](https://trac.osgeo.org/geos/wiki/PreparedGeometry).

Mar shampla:

```pycon
>>> from django.contrib.gis.geos import Point, Polygon
>>> poly = Polygon.from_bbox((0, 0, 5, 5))
>>> prep_poly = poly.prepared
>>> prep_poly.contains(Point(2.5, 2.5))
True
```

### `Geoiméadracht ullmhaithe`

#### `class PreparedGeometry`

Glacann gach modh ar `Réamh-Geoiméadracht` argóint eile , a chaithfidh a bheith ina sampla a:class: Geosgeoimetrry.

#### `contains(other)`

#### `contains_properly(other)`

#### `covers(other)`

#### `crosses(other)`

#### `disjoint(other)`

#### `intersects(other)`

#### `overlaps(other)`

#### `touches(other)`

#### `within(other)`

## Monarchana Geoimse

#### `fromfile(file_h)`

**Paraiméadair:** `file_h` (a Python `file` object or a string path to the file) -- comhad ionchuir ina bhfuil sonraí spásúla

**cineál tuairisceáin:** a: aicme: GeosGeometry a fhreagraíonn do na sonraí spásúla sa chomhad

Sampla:

```pycon
>>> from django.contrib.gis.geos import fromfile
>>> g = fromfile("/home/bob/geom.wkt")
```

#### `fromstr(string, srid=None)`

**Paraiméadair:** - `string` ([`str`](https://docs.python.org/3/library/stdtypes.html#str)) -- teaghrán ina bhfuil sonraí spásúla
- `srid` ([`int`](https://docs.python.org/3/library/functions.html#int)) -- aitheantas tagartha spásúil

**cineál tuairisceáin:** a: aicme: Geosgeometry a fhreagraíonn do na sonraí spásúla sa sreangán

\<GEOSGeometry\>Tá fromstr (string, srid) comhionann le:aicme: GeosGeometracht (string, srid) .

Sampla:

```pycon
>>> from django.contrib.gis.geos import fromstr
>>> pnt = fromstr("POINT(-90.5 29.5)", srid=4326)
```

## Cuspóirí I/O

### Réadanna Léitheora

Tugann ranganna I/O an léitheora a: class: GeosGeometry ar ais ón ionchur WKB agus/nó WKT a thugtar dá modh léite (geom) \`.

#### `class WKBReader`

Sampla:

```pycon
>>> from django.contrib.gis.geos import WKBReader
>>> wkb_r = WKBReader()
>>> wkb_r.read("0101000000000000000000F03F000000000000F03F")
<Point object at 0x103a88910>
```

#### `class WKTReader`

Sampla:

```pycon
>>> from django.contrib.gis.geos import WKTReader
>>> wkt_r = WKTReader()
>>> wkt_r.read("POINT(1 1)")
<Point object at 0x103a88b50>
```

### Rudaí Scríbhneoir

All writer objects have a `write(geom)` method that returns either the
WKB or WKT of the given geometry. In addition, [`WKBWriter`](#django.contrib.gis.geos.WKBWriter) objects
also have properties that may be used to change the byte order, and or
include the SRID value (in other words, EWKB).

#### `class WKBWriter(dim=2)`

`WKBWriter` provides the most control over its output. By default it
returns OGC-compliant WKB when its `write` method is called. However,
it has properties that allow for the creation of EWKB, a superset of the
WKB standard that includes additional information. See the
[`WKBWriter.outdim`](#django.contrib.gis.geos.WKBWriter.outdim) documentation for more details about the `dim`
argument.

#### `write(geom)`

Tugann sé WKB an ghéimseadracht a thugtar ar ais mar réad Python `buffer`. Sampla:

```pycon
>>> from django.contrib.gis.geos import Point, WKBWriter
>>> pnt = Point(1, 1)
>>> wkb_w = WKBWriter()
>>> wkb_w.write(pnt)
<read-only buffer for 0x103a898f0, size -1, offset 0 at 0x103a89930>
```

#### `write_hex(geom)`

Returns WKB of the geometry in hexadecimal. Example:

```pycon
>>> from django.contrib.gis.geos import Point, WKBWriter
>>> pnt = Point(1, 1)
>>> wkb_w = WKBWriter()
>>> wkb_w.write_hex(pnt)
'0101000000000000000000F03F000000000000F03F'
```

#### `byteorder`

Féadfar an maoin seo a shocrú chun ordú báite na léiriúcháin geoiméadrachta a athrú.

| Luach Byteorder | Cur síos |
| --- | --- |
| 0 | Big Endian (m.sh., comhoiriúnach le córais RISC) |
| 1 | Little Endian (m.sh., comhoiriúnach le córais x86) |

Sampla:

```pycon
>>> from django.contrib.gis.geos import Point, WKBWriter
>>> wkb_w = WKBWriter()
>>> pnt = Point(1, 1)
>>> wkb_w.write_hex(pnt)
'0101000000000000000000F03F000000000000F03F'
>>> wkb_w.byteorder = 0
'00000000013FF00000000000003FF0000000000000'
```

#### `outdim`

This property may be set to change the output dimension of the geometry
representation. In other words, if you have a 3D geometry then set to 3
so that the Z value is included in the WKB.

| Luach Outdim | Cur síos |
| --- | --- |
| 2 | An réamhshocraithe, aschur 2D WKB. |
| 3 | Aschur 3D WKB. |

Sampla:

```pycon
>>> from django.contrib.gis.geos import Point, WKBWriter
>>> wkb_w = WKBWriter()
>>> wkb_w.outdim
2
>>> pnt = Point(1, 1, 1)
>>> wkb_w.write_hex(pnt)  # By default, no Z value included:
'0101000000000000000000F03F000000000000F03F'
>>> wkb_w.outdim = 3  # Tell writer to include Z values
>>> wkb_w.write_hex(pnt)
'0101000080000000000000F03F000000000000F03F000000000000F03F'
```

#### `srid`

Set this property with a boolean to indicate whether the SRID of the
geometry should be included with the WKB representation. Example:

```pycon
>>> from django.contrib.gis.geos import Point, WKBWriter
>>> wkb_w = WKBWriter()
>>> pnt = Point(1, 1, srid=4326)
>>> wkb_w.write_hex(pnt)  # By default, no SRID included:
'0101000000000000000000F03F000000000000F03F'
>>> wkb_w.srid = True  # Tell writer to include SRID
>>> wkb_w.write_hex(pnt)
'0101000020E6100000000000000000F03F000000000000F03F'
```

#### `class WKTWriter(dim=2, trim=False, precision=None)`

Ligeann an rang seo léiriú WKT de ghéiméadracht a chur amach. Féach na tréithe: attr: wkbwriter.outdim, :attr: trim, agus:attr: precision le haghaidh sonraí faoi argóintí an tógálaí.

#### `write(geom)`

Tugann sé ar ais WKT an ghéiméadracht a thugtar. Sampla:

```pycon
>>> from django.contrib.gis.geos import Point, WKTWriter
>>> pnt = Point(1, 1)
>>> wkt_w = WKTWriter()
>>> wkt_w.write(pnt)
'POINT (1.0000000000000000 1.0000000000000000)'
```

#### `outdim`

Féach: attr: WKBWriter.outdim.

#### `trim`

Úsáidtear an maoin seo chun gearradh deochlacha gan ghá a chumasú nó a dhíchumasú.

```pycon
>>> from django.contrib.gis.geos import Point, WKTWriter
>>> pnt = Point(1, 1)
>>> wkt_w = WKTWriter()
>>> wkt_w.trim
False
>>> wkt_w.write(pnt)
'POINT (1.0000000000000000 1.0000000000000000)'
>>> wkt_w.trim = True
>>> wkt_w.write(pnt)
'POINT (1 1)'
```

#### `precision`

Rialaíonn an maoin seo cruinneas timpeallaithe na gcomhordanáidí; má tá sé socraithe go `None` díchumasaítear an timpeallú.

```
>>> from django.contrib.gis.geos import Point, WKTWriter
>>> pnt = Point(1.44, 1.66)
>>> wkt_w = WKTWriter()
>>> print(wkt_w.precision)
None
>>> wkt_w.write(pnt)
'POINT (1.4399999999999999 1.6599999999999999)'
>>> wkt_w.precision = 0
>>> wkt_w.write(pnt)
'POINT (1 2)'
>>> wkt_w.precision = 1
>>> wkt_w.write(pnt)
'POINT (1.4 1.7)'
```

**Fonótaí**

[^1]: \< [https://postgis.net/docs/using\_postgis\_dbmanagement.html#EWKB\_EWKT](https://postgis.net/docs/using_postgis_dbmanagement.html#EWKB_EWKT)\>\*Féach\* , doiciméadú PostGIS ag Ch. 4.1.2.

## Socruithe

### `CONAIR_LEABHARLANNA_GEOS`

A string specifying the location of the GEOS C library. Typically,
this setting is only used if the GEOS C library is in a non-standard
location (e.g., `/home/bob/lib/libgeos_c.so`).

> **Note**
>
> Caithfidh an socrú gurb é an cosán *iomlán* chuig an leabharlann roinnte\*\*C\*\*; i bhfocail eile ba mhaith leat `libgeos_c.so` a úsáid, ní `libgeos.so`.

## Eisceachtaí

#### `exception GEOSException`

Léiríonn an buneisceacht GEOS earráid a bhaineann le GEOS.
