Acuan API GeoQuerySetLink to this heading

class GeoQuerySet(model=None)Link to this definition

Pencarian SpasialLink to this heading

The spatial lookups in this section are available for GeometryField and RasterField.

For an introduction, see the spatial lookups introduction. For an overview of what lookups are compatible with a particular spatial backend, refer to the spatial lookup compatibility table.

Pencarian dengan rasterLink to this heading

All examples in the reference below are given for geometry fields and inputs, but the lookups can be used the same way with rasters on both sides. Whenever a lookup doesn't support raster input, the input is automatically converted to a geometry where necessary using the ST_Polygon function. See also the introduction to raster lookups.

The database operators used by the lookups can be divided into three categories:

  • Native raster support N: the operator accepts rasters natively on both sides of the lookup, and raster input can be mixed with geometry inputs.

  • Bilateral raster support B: the operator supports rasters only if both sides of the lookup receive raster inputs. Raster data is automatically converted to geometries for mixed lookups.

  • Geometry conversion support C. The lookup does not have native raster support, all raster data is automatically converted to geometries.

The examples below show the SQL equivalent for the lookups in the different types of raster support. The same pattern applies to all spatial lookups.

Kasus

Cari

Setara SQL

N, B

rast__contains=rst

ST_Contains(rast, rst)

N, B

rast__1__contains=(rst, 2)

ST_Contains(rast, 1, rst, 2)

B, C

rast__contains=geom

ST_Contains(ST_Polygon(rast), geom)

B, C

rast__1__contains=geom

ST_Contains(ST_Polygon(rast, 1), geom)

B, C

poly__contains=rst

ST_Contains(poly, ST_Polygon(rst))

B, C

poly__contains=(rst, 1)

ST_Contains(poly, ST_Polygon(rst, 1))

C

rast__crosses=rst

ST_Crosses(ST_Polygon(rast), ST_Polygon(rst))

C

rast__1__crosses=(rst, 2)

ST_Crosses(ST_Polygon(rast, 1), ST_Polygon(rst, 2))

C

rast__crosses=geom

ST_Crosses(ST_Polygon(rast), geom)

C

poly__crosses=rst

ST_Crosses(poly, ST_Polygon(rst))

Spatial lookups with rasters are only supported for PostGIS backends (denominated as PGRaster in this section).

bbcontainsLink to this heading

Tersedia: PostGIS, MySQL, SpatiaLite, PGRaster (Asli)

Tests if the geometry or raster field's bounding box completely contains the lookup geometry's bounding box.

Contoh:

Code
Zipcode.objects.filter(poly__bbcontains=geom)

Backend

Setara SQL

PostGIS

poly ~ geom

MySQL

MBRContains(poly, geom)

SpatiaLite

MbrContains(poly, geom)

bboverlapsLink to this heading

Tersedia: PostGIS, MySQL, SpatiaLite, PGRaster (Asli)

Tests if the geometry field's bounding box overlaps the lookup geometry's bounding box.

Contoh:

Code
Zipcode.objects.filter(poly__bboverlaps=geom)

Backend

Setara SQL

PostGIS

poly && geom

MySQL

MBROverlaps(poly, geom)

SpatiaLite

MbrOverlaps(poly, geom)

containedLink to this heading

Tersedia: PostGIS, MySQL, SpatiaLite, PGRaster (Asli)

Tests if the geometry field's bounding box is completely contained by the lookup geometry's bounding box.

Contoh:

Code
Zipcode.objects.filter(poly__contained=geom)

Backend

Setara SQL

PostGIS

poly @ geom

MySQL

MBRWithin(poly, geom)

SpatiaLite

MbrWithin(poly, geom)

containsLink to this heading

Tersedia: PostGIS, Oracle, MySQL, SpatiaLite, PGRaster (Timbal balik)

Tests if the geometry field spatially contains the lookup geometry.

Contoh:

Code
Zipcode.objects.filter(poly__contains=geom)

Backend

Setara SQL

PostGIS

ST_Contains(poly, geom)

Oracle

SDO_CONTAINS(poly, geom)

MySQL

MBRContains(poly, geom)

SpatiaLite

Contains(poly, geom)

contains_properlyLink to this heading

Tersedia: PostGIS, PGRaster (Timbal balik)

Returns true if the lookup geometry intersects the interior of the geometry field, but not the boundary (or exterior).

Contoh:

Code
Zipcode.objects.filter(poly__contains_properly=geom)

Backend

Setara SQL

PostGIS

ST_ContainsProperly(poly, geom)

coveredbyLink to this heading

Tersedia: PostGIS, Oracle, PGRaster (Timbal balik)

Tests if no point in the geometry field is outside the lookup geometry. [3]

Contoh:

Code
Zipcode.objects.filter(poly__coveredby=geom)

Backend

Setara SQL

PostGIS

ST_CoveredBy(poly, geom)

Oracle

SDO_COVEREDBY(poly, geom)

coversLink to this heading

Tersedia: PostGIS, Oracle, PGRaster (Timbal balik)

Tests if no point in the lookup geometry is outside the geometry field. [3]

Contoh:

Code
Zipcode.objects.filter(poly__covers=geom)

Backend

Setara SQL

PostGIS

ST_Covers(poly, geom)

Oracle

SDO_COVERS(poly, geom)

crossesLink to this heading

Tersedia: PostGIS, SpatiaLite, PGRaster (Perubahan)

Tests if the geometry field spatially crosses the lookup geometry.

Contoh:

Code
Zipcode.objects.filter(poly__crosses=geom)

Backend

Setara SQL

PostGIS

ST_Crosses(poly, geom)

SpatiaLite

Crosses(poly, geom)

disjointLink to this heading

Tersedia: PostGIS, Oracle, MySQL, SpatiaLite, PGRaster (Timbal balik)

Tests if the geometry field is spatially disjoint from the lookup geometry.

Contoh:

Code
Zipcode.objects.filter(poly__disjoint=geom)

Backend

Setara SQL

PostGIS

ST_Disjoint(poly, geom)

Oracle

SDO_GEOM.RELATE(poly, 'DISJOINT', geom, 0.05)

MySQL

MBRDisjoint(poly, geom)

SpatiaLite

Disjoint(poly, geom)

equalsLink to this heading

Tersedia: PostGIS, Oracle, MySQL, SpatiaLite, PGRaster (Perubahan)

exact, same_asLink to this heading

Tersedia: PostGIS, Oracle, MySQL, SpatiaLite, PGRaster (Timbal balik)

intersectsLink to this heading

Tersedia: PostGIS, Oracle, MySQL, SpatiaLite, PGRaster (Timbal balik)

Tests if the geometry field spatially intersects the lookup geometry.

Contoh:

Code
Zipcode.objects.filter(poly__intersects=geom)

Backend

Setara SQL

PostGIS

ST_Intersects(poly, geom)

Oracle

SDO_OVERLAPBDYINTERSECT(poly, geom)

MySQL

MBRIntersects(poly, geom)

SpatiaLite

Intersects(poly, geom)

isvalidLink to this heading

Tersedia: PostGIS, Oracle, SpatiaLite

Coba jika geometri adalah sah.

Contoh:

Code
Zipcode.objects.filter(poly__isvalid=True)

Backend

Setara SQL

Availability: PostGIS, Oracle, SpatiaLite

ST_IsValid(poly)

Oracle

SDO_GEOM.VALIDATE_GEOMETRY_WITH_CONTEXT(poly, 0.05) = 'TRUE'

overlapsLink to this heading

Tersedia: PostGIS, Oracle, MySQL, SpatiaLite, PGRaster (Timbal balik)

relateLink to this heading

Tersedia: PostGIS, Oracle, SpatiaLite, PGRaster (Perubahan)

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

PostGIS & SpatiaLiteLink to this heading

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

Contoh geometri:

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

PostGIS SQL Setara:

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

SpatiaLite SQL setara:

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

Raster example:

Code
Zipcode.objects.filter(poly__relate=(rast, 1, 'T*T***FF*'))
Zipcode.objects.filter(rast__2__relate=(rast, 1, 'T*T***FF*'))

PostGIS SQL Setara:

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

OracleLink to this heading

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

Contoh:

Code
Zipcode.objects.filter(poly__relate=(geom, 'anyinteract'))

Oracle SQL setara:

Code
SELECT ... WHERE SDO_RELATE(poly, geom, 'anyinteract')

touchesLink to this heading

Tersedia: PostGIS, Oracle, MySQL, SpatiaLite

Tests if the geometry field spatially touches the lookup geometry.

Contoh:

Code
Zipcode.objects.filter(poly__touches=geom)

Backend

Setara SQL

PostGIS

ST_Touches(poly, geom)``

MySQL

MBRTouches(poly, geom)

Oracle

SDO_TOUCH(poly, geom)

SpatiaLite

Touches(poly, geom)

withinLink to this heading

Tersedia: PostGIS, Oracle, MySQL, SpatiaLite, PGRaster (Timbal balik)

Tests if the geometry field is spatially within the lookup geometry.

Contoh:

Code
Zipcode.objects.filter(poly__within=geom)

Backend

Setara SQL

PostGIS

ST_Within(poly, geom)

MySQL

MBRWithin(poly, geom)

Oracle

SDO_INSIDE(poly, geom)

SpatiaLite

Within(poly, geom)

leftLink to this heading

Tersedia: PostGIS, PGRaster (Perubahan)

Tests if the geometry field's bounding box is strictly to the left of the lookup geometry's bounding box.

Contoh:

Code
Zipcode.objects.filter(poly__left=geom)

PostGIS Setara:

Code
SELECT ... WHERE poly << geom

overlaps_leftLink to this heading

Tersedia: PostGIS, PGRaster (Timbal balik)

Tests if the geometry field's bounding box overlaps or is to the left of the lookup geometry's bounding box.

Contoh:

Code
Zipcode.objects.filter(poly__overlaps_left=geom)

PostGIS Setara:

Code
SELECT ... WHERE poly &< geom

overlaps_rightLink to this heading

Tersedia: PostGIS, PGRaster (Timbal balik)

Tests if the geometry field's bounding box overlaps or is to the right of the lookup geometry's bounding box.

Contoh:

Code
Zipcode.objects.filter(poly__overlaps_right=geom)

PostGIS Setara:

Code
SELECT ... WHERE poly &> geom

overlaps_aboveLink to this heading

Tersedia: PostGIS, PGRaster (Perubahan)

Tests if the geometry field's bounding box overlaps or is above the lookup geometry's bounding box.

Contoh:

Code
Zipcode.objects.filter(poly__overlaps_above=geom)

PostGIS Setara:

Code
SELECT ... WHERE poly |&> geom

overlaps_belowLink to this heading

Tersedia: PostGIS, PGRaster (Perubahan)

Tests if the geometry field's bounding box overlaps or is below the lookup geometry's bounding box.

Contoh:

Code
Zipcode.objects.filter(poly__overlaps_below=geom)

PostGIS Setara:

Code
SELECT ... WHERE poly &<| geom

strictly_aboveLink to this heading

Tersedia: PostGIS, PGRaster (Perubahan)

Tests if the geometry field's bounding box is strictly above the lookup geometry's bounding box.

Contoh:

Code
Zipcode.objects.filter(poly__strictly_above=geom)

PostGIS Setara:

Code
SELECT ... WHERE poly |>> geom

strictly_belowLink to this heading

Tersedia: PostGIS, PGRaster (Perubahan)

Tests if the geometry field's bounding box is strictly below the lookup geometry's bounding box.

Contoh:

Code
Zipcode.objects.filter(poly__strictly_below=geom)

PostGIS Setara:

Code
SELECT ... WHERE poly <<| geom

Pencarian JarakLink to this heading

Tersedia: PostGIS, Oracle, SpatiaLite, PGRaster (Asli)

For an overview on performing distance queries, please refer to the distance queries introduction.

Pencarian jarak mengambil formulir berikut:

Code
<field>__<distance lookup>=(<geometry/raster>, <distance value>[, 'spheroid'])
<field>__<distance lookup>=(<raster>, <band_index>, <distance value>[, 'spheroid'])
<field>__<band_index>__<distance lookup>=(<raster>, <band_index>, <distance value>[, 'spheroid'])

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

On every distance lookup except dwithin, an optional element, 'spheroid', may be included to use the more accurate spheroid distance calculation functions on fields with a geodetic coordinate system.

Pada PostgreSQL, pilihan 'spheroid' menggunakan ST_DistanceSpheroid daripada ST_DistanceSphere. Fungsi ST_Distance paling sederhana digunakan dengan sistem kordinat yang sudah dihitung. Raster dirubah ke geometri untuk pencarian berdasarkan spheroid.

distance_gtLink to this heading

Returns models where the distance to the geometry field from the lookup geometry is greater than the given distance value.

Contoh:

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

Backend

Setara SQL

PostGIS

ST_Distance/ST_Distance_Sphere(poly, geom) > 5

Oracle

SDO_GEOM.SDO_DISTANCE(poly, geom, 0.05) > 5

SpatiaLite

Distance(poly, geom) > 5

distance_gteLink to this heading

Returns models where the distance to the geometry field from the lookup geometry is greater than or equal to the given distance value.

Contoh:

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

Backend

Setara SQL

PostGIS

ST_Distance/ST_Distance_Sphere(poly, geom) >= 5

Oracle

SDO_GEOM.SDO_DISTANCE(poly, geom, 0.05) >= 5

SpatiaLite

Distance(poly, geom) >= 5

distance_ltLink to this heading

Returns models where the distance to the geometry field from the lookup geometry is less than the given distance value.

Contoh:

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

Backend

Setara SQL

PostGIS

ST_Distance/ST_Distance_Sphere(poly, geom) < 5

Oracle

SDO_GEOM.SDO_DISTANCE(poly, geom, 0.05) < 5

SpatiaLite

Distance(poly, geom) < 5

distance_lteLink to this heading

Returns models where the distance to the geometry field from the lookup geometry is less than or equal to the given distance value.

Contoh:

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

Backend

Setara SQL

PostGIS

ST_Distance/ST_Distance_Sphere(poly, geom) <= 5

Oracle

SDO_GEOM.SDO_DISTANCE(poly, geom, 0.05) <= 5

SpatiaLite

Distance(poly, geom) <= 5

dwithinLink to this heading

Returns models where the distance to the geometry field from the lookup geometry are within the given distance from one another. Note that you can only provide Distance objects if the targeted geometries are in a projected system. For geographic geometries, you should use units of the geometry field (e.g. degrees for WGS84) .

Contoh:

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

Backend

Setara SQL

PostGIS

ST_DWithin(poly, geom, 5)

Oracle

SDO_WITHIN_DISTANCE(poly, geom, 5)

SpatiaLite

PtDistWithin(poly, geom, 5)

Cara GeoQuerySetLink to this heading

GeoQuerySet methods specify that a spatial operation be performed on each spatial operation on each geographic field in the queryset and store its output in a new attribute on the model (which is generally the name of the GeoQuerySet method).

Ada juga metode pengumpulan GeoQuerySet yang mengembalikan nilai tunggal daripada queryset. Bagian ini akan menggambarkan API dan ketersediaan dari setiap metode GeoQuerySet tersedia dalam GeoDjango.

With a few exceptions, the following keyword arguments may be used with all GeoQuerySet methods:

Argumen Katakunci

Deskripsi

field_name

By default, GeoQuerySet methods use the first geographic field encountered in the model. This keyword should be used to specify another geographic field (e.g., field_name='point2') when there are multiple geographic fields in a model.

On PostGIS, the field_name keyword may also be used on geometry fields in models that are related via a ForeignKey relation (e.g., field_name='related__point').

model_att

By default, GeoQuerySet methods typically attach their output in an attribute with the same name as the GeoQuerySet method. Setting this keyword with the desired attribute name will override this default behavior. For example, qs = Zipcode.objects.centroid(model_att='c') will attach the centroid of the Zipcode geometry field in a c attribute on every model rather than in a centroid attribute.

This keyword is required if a method name clashes with an existing GeoQuerySet method -- if you wanted to use the area() method on model with a PolygonField named area, for example.

PengukuranLink to this heading

Tersedia: PostGIS, Oracle, SpatiaLite

areaLink to this heading

GeoQuerySet.area(**kwargs)Link to this definition

Returns the area of the geographic field in an area attribute on each element of this GeoQuerySet.

distanceLink to this heading

GeoQuerySet.distance(geom, **kwargs)Link to this definition

This method takes a geometry as a parameter, and attaches a distance attribute to every model in the returned queryset that contains the distance (as a Distance object) to the given geometry.

In the following example (taken from the GeoDjango distance tests), the distance from the Tasmanian city of Hobart to every other PointField in the AustraliaCity queryset is calculated:

Code
>>> pnt = AustraliaCity.objects.get(name='Hobart').point
>>> for city in AustraliaCity.objects.distance(pnt): print(city.name, city.distance)
Wollongong 990071.220408 m
Shellharbour 972804.613941 m
Thirroul 1002334.36351 m
Mittagong 975691.632637 m
Batemans Bay 834342.185561 m
Canberra 598140.268959 m
Melbourne 575337.765042 m
Sydney 1056978.87363 m
Hobart 0.0 m
Adelaide 1162031.83522 m
Hillsdale 1049200.46122 m

lengthLink to this heading

GeoQuerySet.length(**kwargs)Link to this definition

Returns the length of the geometry field in a length attribute (a Distance object) on each model in the queryset.

perimeterLink to this heading

GeoQuerySet.perimeter(**kwargs)Link to this definition

Returns the perimeter of the geometry field in a perimeter attribute (a Distance object) on each model in the queryset.

Hubungan Geometri.Link to this heading

The following methods take no arguments, and attach geometry objects each element of the GeoQuerySet that is the result of relationship function evaluated on the geometry field.

centroidLink to this heading

GeoQuerySet.centroid(**kwargs)Link to this definition

Tersedia: PostGIS, Oracle, SpatiaLite

Returns the centroid value for the geographic field in a centroid attribute on each element of the GeoQuerySet.

envelopeLink to this heading

GeoQuerySet.envelope(**kwargs)Link to this definition

Tersedia: PostGIS, SpatiaLite

Returns a geometry representing the bounding box of the geometry field in an envelope attribute on each element of the GeoQuerySet.

point_on_surfaceLink to this heading

GeoQuerySet.point_on_surface(**kwargs)Link to this definition

Tersedia: PostGIS, Oracle, SpatiaLite

Returns a Point geometry guaranteed to lie on the surface of the geometry field in a point_on_surface attribute on each element of the queryset; otherwise sets with None.

Penyunting GeometriLink to this heading

force_rhrLink to this heading

GeoQuerySet.force_rhr(**kwargs)Link to this definition

Tersedia: PostGIS

Returns a modified version of the polygon/multipolygon in which all of the vertices follow the Right-Hand-Rule, and attaches as a force_rhr attribute on each element of the queryset.

reverse_geomLink to this heading

GeoQuerySet.reverse_geom(**kwargs)Link to this definition

Tersedia: PostGIS, Oracle

Reverse the coordinate order of the geometry field, and attaches as a reverse attribute on each element of the queryset.

scaleLink to this heading

GeoQuerySet.scale(x, y, z=0.0, **kwargs)Link to this definition

Tersedia: PostGIS, SpatiaLite

snap_to_gridLink to this heading

GeoQuerySet.snap_to_grid(*args, **kwargs)Link to this definition

Snap all points of the input geometry to the grid. How the geometry is snapped to the grid depends on how many numeric (either float, integer, or long) arguments are given.

Jumlah Argumen

Deskripsi

1

A single size to snap bot the X and Y grids to.

2

X and Y sizes to snap the grid to.

4

X, Y sizes and the corresponding X, Y origins.

transformLink to this heading

GeoQuerySet.transform(srid=4326, **kwargs)Link to this definition

Tersedia: PostGIS, Oracle, SpatiaLite

The transform method transforms the geometry field of a model to the spatial reference system specified by the srid parameter. If no srid is given, then 4326 (WGS84) is used by default.

Contoh:

Code
>>> qs = Zipcode.objects.all().transform() # Transforms to WGS84
>>> qs = Zipcode.objects.all().transform(32140) # Transforming to "NAD83 / Texas South Central"
>>> print(qs[0].poly.srid)
32140
>>> print(qs[0].poly)
POLYGON ((234055.1698884720099159 4937796.9232223574072123 ...

translateLink to this heading

GeoQuerySet.translate(x, y, z=0.0, **kwargs)Link to this definition

Tersedia: PostGIS, SpatiaLite

Translates the geometry field to a new location using the given numeric parameters as offsets.

Geometry OperationsLink to this heading

Tersedia: PostGIS, Oracle, SpatiaLite

The following methods all take a geometry as a parameter and attach a geometry to each element of the GeoQuerySet that is the result of the operation.

differenceLink to this heading

GeoQuerySet.difference(geom)Link to this definition

Returns the spatial difference of the geographic field with the given geometry in a difference attribute on each element of the GeoQuerySet.

intersectionLink to this heading

GeoQuerySet.intersection(geom)Link to this definition

Returns the spatial intersection of the geographic field with the given geometry in an intersection attribute on each element of the GeoQuerySet.

sym_differenceLink to this heading

GeoQuerySet.sym_difference(geom)Link to this definition

Returns the symmetric difference of the geographic field with the given geometry in a sym_difference attribute on each element of the GeoQuerySet.

unionLink to this heading

GeoQuerySet.union(geom)Link to this definition

Returns the union of the geographic field with the given geometry in an union attribute on each element of the GeoQuerySet.

Keluaran GeometriLink to this heading

The following GeoQuerySet methods will return an attribute that has the value of the geometry field in each model converted to the requested output format.

geohashLink to this heading

GeoQuerySet.geohash(precision=20, **kwargs)Link to this definition

Attaches a geohash attribute to every model the queryset containing the GeoHash representation of the geometry.

geojsonLink to this heading

GeoQuerySet.geojson(**kwargs)Link to this definition

Tersedia: PostGIS, SpatiaLite

Attaches a geojson attribute to every model in the queryset that contains the GeoJSON representation of the geometry.

Argumen Katakunci

Deskripsi

ketelitian

It may be used to specify the number of significant digits for the coordinates in the GeoJSON representation -- the default value is 8.

crs

Setel ini menjadi True jika anda ingin sistem acuan kordinat untuk disertakan dalam GeoJSON yang dikembalikan.

bbox

Setel ini menjadi True jika anda ingin membatasi kotak untuk disertakan dalam GeoJSON yang dikembalikan.

gmlLink to this heading

GeoQuerySet.gml(**kwargs)Link to this definition

Tersedia: PostGIS, Oracle, SpatiaLite

Attaches a gml attribute to every model in the queryset that contains the Geographic Markup Language (GML) representation of the geometry.

Contoh:

Code
>>> qs = Zipcode.objects.all().gml()
>>> print(qs[0].gml)
<gml:Polygon srsName="EPSG:4326"><gml:OuterBoundaryIs>-147.78711,70.245363 ...  -147.78711,70.245363</gml:OuterBoundaryIs></gml:Polygon>

Argumen Katakunci

Deskripsi

ketelitian

This keyword is for PostGIS only. It may be used to specify the number of significant digits for the coordinates in the GML representation -- the default value is 8.

versi

This keyword is for PostGIS only. It may be used to specify the GML version used, and may only be values of 2 or 3. The default value is 2.

kmlLink to this heading

GeoQuerySet.kml(**kwargs)Link to this definition

Tersedia: PostGIS, SpatiaLite

Attaches a kml attribute to every model in the queryset that contains the Keyhole Markup Language (KML) representation of the geometry fields. It should be noted that the contents of the KML are transformed to WGS84 if necessary.

Contoh:

Code
>>> qs = Zipcode.objects.all().kml()
>>> print(qs[0].kml)
<Polygon><outerBoundaryIs><LinearRing><coordinates>-103.04135,36.217596,0 ... -103.04135,36.217596,0</coordinates></LinearRing></outerBoundaryIs></Polygon>

Argumen Katakunci

Deskripsi

ketelitian

This keyword may be used to specify the number of significant digits for the coordinates in the KML representation -- the default value is 8.

svgLink to this heading

GeoQuerySet.svg(**kwargs)Link to this definition

Tersedia: PostGIS, SpatiaLite

Attaches a svg attribute to every model in the queryset that contains the Scalable Vector Graphics (SVG) path data of the geometry fields.

Argumen Katakunci

Deskripsi

relative

If set to True, the path data will be implemented in terms of relative moves. Defaults to False, meaning that absolute moves are used instead.

ketelitian

This keyword may be used to specify the number of significant digits for the coordinates in the SVG representation -- the default value is 8.

Bermacam-macamLink to this heading

mem_sizeLink to this heading

GeoQuerySet.mem_size(**kwargs)Link to this definition

Tersedia: PostGIS

Returns the memory size (number of bytes) that the geometry field takes in a mem_size attribute on each element of the GeoQuerySet.

num_geomLink to this heading

GeoQuerySet.num_geom(**kwargs)Link to this definition

Tersedia: PostGIS, Oracle, SpatiaLite

Returns the number of geometries in a num_geom attribute on each element of the GeoQuerySet if the geometry field is a collection (e.g., a GEOMETRYCOLLECTION or MULTI* field); otherwise sets with None.

num_pointsLink to this heading

GeoQuerySet.num_points(**kwargs)Link to this definition

Tersedia: PostGIS, Oracle, SpatiaLite

Returns the number of points in the first linestring in the geometry field in a num_points attribute on each element of the GeoQuerySet; otherwise sets with None.

Fungsi KumpulanLink to this heading

Django provides some GIS-specific aggregate functions. For details on how to use these aggregate functions, see the topic guide on aggregation.

Argumen Katakunci

Deskripsi

tolerance

This keyword is for Oracle only. It is for the tolerance value used by the SDOAGGRTYPE procedure; the Oracle documentation has more details.

Contoh:

Code
>>> from django.contrib.gis.db.models import Extent, Union
>>> WorldBorder.objects.aggregate(Extent('mpoly'), Union('mpoly'))

CollectLink to this heading

class Collect(geo_field)Link to this definition

Tersedia: PostGIS, SpatiaLite

Returns a GEOMETRYCOLLECTION or a MULTI geometry object from the geometry column. This is analogous to a simplified version of the Union aggregate, except it can be several orders of magnitude faster than performing a union because it simply rolls up geometries into a collection or multi object, not caring about dissolving boundaries.

ExtentLink to this heading

class Extent(geo_field)Link to this definition

Tersedia: PostGIS, Oracle, SpatiaLite

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

Contoh:

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

Extent3DLink to this heading

class Extent3D(geo_field)Link to this definition

Tersedia: PostGIS

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

Contoh:

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

MakeLineLink to this heading

class MakeLine(geo_field)Link to this definition

Tersedia: PostGIS, SpatiaLite

Returns a LineString constructed from the point field geometries in the QuerySet. Currently, ordering the queryset has no effect.

Contoh:

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

UnionLink to this heading

class Union(geo_field)Link to this definition

Tersedia: PostGIS, Oracle, SpatiaLite

This method returns a GEOSGeometry object comprising the union of every geometry in the queryset. Please note that use of Union is processor intensive and may take a significant amount of time on large querysets.

Contoh:

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

Catatan kaki