我将在我的项目中使用Spatial fields之一,但我不知道所有这些之间的区别,Django documentation有两个示例(PolygonField和RasterField)
模型:
from django.contrib.gis.db import models
class Zipcode(models.Model):
code = models.CharField(max_length=5)
poly = models.PolygonField()
class Elevation(models.Model):
name = models.CharField(max_length=100)
rast = models.RasterField()
数据库api示例:
>>> from zipcode.models import Zipcode
>>> z = Zipcode(code=77096, poly='POLYGON(( 10 10, 10 20, 20 20, 20 15, 10 10))')
>>> z.save()
>>> from elevation.models import Elevation
>>> dem = Elevation(name='Volcano', rast='/path/to/raster/volcano.tif')
>>> dem.save()
我想要other fields的示例代码来理解它们:
GeometryField
PointField
LineStringField
MultiPointField
MultiLineStringField
MultiPolygonField
GeometryCollectionField