GEOS APILink to this heading

CúlraLink to this heading

Cad é GEOS?Link to this heading

GEOS stands for Geometry Engine - Open Source, and is a C++ library, ported from the Java Topology Suite. GEOS implements the OpenGIS Simple Features for SQL spatial predicate functions and spatial operators. GEOS, now an OSGeo project, was initially developed and maintained by Refractions Research of Victoria, Canada.

GnéitheLink to this heading

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 objects may be used outside of a Django project/application. In other words, no need to have DJANGO_SETTINGS_MODULE set or use a database, etc.

  • Is féidir athraitheacht: :class: rudaí Geosgeometry a mhodhnú.

  • Cross-platform tested.

Ranganna teagaiscLink to this heading

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

Coiméadras a chruthúLink to this heading

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:

Python console
>>> 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 object may be created by passing in the X and Y coordinates into its constructor:

Python console
>>> 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:

Python console
>>> 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:

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

Is iad na geoiméadraí PythonicLink to this heading

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:

Python console
>>> 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:

Python console
>>> 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 returns a coordinate tuple:

Python console
>>> 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:

Python console
>>> 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

Python console
>>> 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

Python console
>>> 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))

Rudaí GeoiméadLink to this heading

``Geoiméadracht ``Link to this heading

class GEOSGeometry(geo_input, srid=None, *, max_geom_collections=198)Link to this definition
Paraiméadair:
  • geo_input -- Luach ionchuir geoiméadais (teaghrán nó: aicme: memoryview)

  • srid (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 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:

Python console
>>> 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.

classmethod GEOSGeometry.from_gml(gml_string)Link to this definition

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

AiríonnaLink to this heading

GEOSGeometry.coordsLink to this definition

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

GEOSGeometry.dimsLink to this definition

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.emptyLink to this definition

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

GEOSGeometry.geom_typeLink to this definition

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

Python console
>>> pnt = GEOSGeometry("POINT(5 23)")
>>> pnt.geom_type
'Point'
GEOSGeometry.geom_typeidLink to this definition

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

GEOSGeometry.num_coordsLink to this definition

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

GEOSGeometry.num_geomLink to this definition

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

GEOSGeometry.haszLink to this definition

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

GEOSGeometry.hasmLink to this definition

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

GEOSGeometry.ringLink to this definition

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

GEOSGeometry.simpleLink to this definition

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 object is not simple if it intersects itself. Thus, LinearRing and Polygon objects are always simple because they cannot intersect themselves, by definition.

GEOSGeometry.validLink to this definition

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

GEOSGeometry.valid_reasonLink to this definition

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

GEOSGeometry.sridLink to this definition

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

Python console
>>> pnt = Point(5, 23)
>>> print(pnt.srid)
None
>>> pnt.srid = 4326
>>> pnt.srid
4326

Airíonna AschuirLink to this heading

The properties in this section export the GEOSGeometry object into a different. This output may be in the form of a string, buffer, or even another object.

GEOSGeometry.ewktLink to this definition

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).

GEOSGeometry.hexLink to this definition

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 property instead).

GEOSGeometry.hexewkbLink to this definition

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.jsonLink to this definition

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.geojsonLink to this definition

Alias le haghaidh: attr: GeosGeometry.JSON.

GEOSGeometry.kmlLink to this definition

Returns a KML (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.ogrLink to this definition

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

GEOSGeometry.wkbLink to this definition

Returns the WKB (Well-Known Binary) representation of this Geometry as a Python buffer. SRID value is not included, use the GEOSGeometry.ewkb property instead.

GEOSGeometry.ewkbLink to this definition

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.wktLink to this definition

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

Modhanna Predicate SpásúlaLink to this heading

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)Link to this definition

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

GEOSGeometry.covers(other)Link to this definition

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)Link to this definition

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 líne agus limistéar) ``0******** (le haghaidh dhá chuar).

GEOSGeometry.disjoint(other)Link to this definition

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

GEOSGeometry.equals(other)Link to this definition

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)Link to this definition

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)Link to this definition

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)Link to this definition

Tuairisceann True ife:meth: Geosgeometry.disjoint False.

GEOSGeometry.overlaps(other)Link to this definition

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)Link to this definition

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)Link to this definition

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

GEOSGeometry.within(other)Link to this definition

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íochaLink to this heading

GEOSGeometry.buffer(width, quadsegs=8)Link to this definition

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)Link to this definition

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)Link to this definition

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)Link to this definition
GEOSGeometry.interpolate_normalized(distance)Link to this definition

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)Link to this definition

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

GEOSGeometry.project(point)Link to this definition
GEOSGeometry.project_normalized(point)Link to this definition

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)Link to this definition

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)Link to this definition

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)Link to this definition

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)Link to this definition

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íochaLink to this heading

GEOSGeometry.boundaryLink to this definition

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

GEOSGeometry.centroidLink to this definition

Returns a Point object representing the geometric center of the geometry. The point is not guaranteed to be on the interior of the geometry.

GEOSGeometry.convex_hullLink to this definition

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

GEOSGeometry.envelopeLink to this definition

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_surfaceLink to this definition

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_unionLink to this definition

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 EileLink to this heading

GEOSGeometry.areaLink to this definition

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

GEOSGeometry.extentLink to this definition

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

GEOSGeometry.clone()Link to this definition

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

GEOSGeometry.distance(geom)Link to this definition

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).

GEOSGeometry.lengthLink to this definition

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.preparedLink to this definition

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.srsLink to this definition

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)Link to this definition

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.

GEOSGeometry.make_valid()Link to this definition

Tugann sé coibhéis bailí:class: GeosGeometry ar ais, ag iarraidh gan aon cheann de na beartacha ionchuir a chailleadh. Má tá an geoiméadra bailí cheana féin, cuirtear ar ais gan teagmháil leis. Tá sé seo cosúil leis an bhfeidhm bunachar sonraí:: class: ~django.contrib.gis.db.models.functions.MakeValid. Éilíonn GEOS 3.8.

GEOSGeometry.normalize(clone=False)Link to this definition

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:

Python console
>>> 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)

PointLink to this heading

class Point(x=None, y=None, z=None, srid=None)Link to this definition

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:

Python console
>>> 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:

Python console
>>> pnt = Point()
>>> pnt = Point([])

LínestringLink to this heading

class LineString(*args, **kwargs)Link to this definition

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:

Python console
>>> 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:

Python console
>>> 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:

Python console
>>> ls = LineString()
>>> ls = LineString([])
closedLink to this definition

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

LínearLink to this heading

class LinearRing(*args, **kwargs)Link to this definition

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:

Python console
>>> 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_counterclockwiseLink to this definition

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

PolygónLink to this heading

class Polygon(*args, **kwargs)Link to this definition

Polygon objects may be instantiated by passing in parameters that represent the rings of the polygon. The parameters must either be LinearRing instances, or a sequence that may be used to construct a LinearRing:

Python console
>>> 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)Link to this definition

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

num_interior_ringsLink to this definition

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

Bailiúcháin GéLink to this heading

IlphointLink to this heading

class MultiPoint(*args, **kwargs)Link to this definition

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

Python console
>>> mp = MultiPoint(Point(0, 0), Point(1, 1))
>>> mp = MultiPoint((Point(0, 0), Point(1, 1)))

MultilinestringLink to this heading

class MultiLineString(*args, **kwargs)Link to this definition

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í:

Python console
>>> ls1 = LineString((0, 0), (1, 1))
>>> ls2 = LineString((2, 2), (3, 3))
>>> mls = MultiLineString(ls1, ls2)
>>> mls = MultiLineString([ls1, ls2])
mergedLink to this definition

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

closedLink to this definition

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

MultipolygonLink to this heading

class MultiPolygon(*args, **kwargs)Link to this definition

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

Python console
>>> 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éadrachLink to this heading

class GeometryCollection(*args, **kwargs)Link to this definition

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

Python console
>>> 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í ullmhaiLink to this heading

In order to obtain a prepared geometry, access the 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.

Mar shampla:

Python console
>>> 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 ullmhaitheLink to this heading

class PreparedGeometryLink to this definition

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

contains(other)Link to this definition
contains_properly(other)Link to this definition
covers(other)Link to this definition
crosses(other)Link to this definition
disjoint(other)Link to this definition
intersects(other)Link to this definition
overlaps(other)Link to this definition
touches(other)Link to this definition
within(other)Link to this definition

Monarchana GeoimseLink to this heading

fromfile(file_h)Link to this definition
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:

Python console
>>> from django.contrib.gis.geos import fromfile
>>> g = fromfile("/home/bob/geom.wkt")
fromstr(string, srid=None)Link to this definition
Paraiméadair:
  • string (str) -- teaghrán ina bhfuil sonraí spásúla

  • srid (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:

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

Cuspóirí I/OLink to this heading

Réadanna LéitheoraLink to this heading

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 WKBReaderLink to this definition

Sampla:

Python console
>>> from django.contrib.gis.geos import WKBReader
>>> wkb_r = WKBReader()
>>> wkb_r.read("0101000000000000000000F03F000000000000F03F")
<Point object at 0x103a88910>
class WKTReaderLink to this definition

Sampla:

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

Rudaí ScríbhneoirLink to this heading

All writer objects have a write(geom) method that returns either the WKB or WKT of the given geometry. In addition, 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)Link to this definition

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 documentation for more details about the dim argument.

write(geom)Link to this definition

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

Python console
>>> 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)Link to this definition

Returns WKB of the geometry in hexadecimal. Example:

Python console
>>> from django.contrib.gis.geos import Point, WKBWriter
>>> pnt = Point(1, 1)
>>> wkb_w = WKBWriter()
>>> wkb_w.write_hex(pnt)
'0101000000000000000000F03F000000000000F03F'
byteorderLink to this definition

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:

Python console
>>> 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'
outdimLink to this definition

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:

Python console
>>> 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'
sridLink to this definition

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

Python console
>>> 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)Link to this definition

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)Link to this definition

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

Python console
>>> from django.contrib.gis.geos import Point, WKTWriter
>>> pnt = Point(1, 1)
>>> wkt_w = WKTWriter()
>>> wkt_w.write(pnt)
'POINT (1.0000000000000000 1.0000000000000000)'
outdimLink to this definition

Féach: attr: WKBWriter.outdim.

trimLink to this definition

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

Python console
>>> 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)'
precisionLink to this definition

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

Code
>>> 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í

SocruitheLink to this heading

CONAIR_LEABHARLANNA_GEOSLink to this heading

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).

EisceachtaíLink to this heading

exception GEOSExceptionLink to this definition

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