Question

I create a table using geodjango with a column location = models.PointField(geography=True).

class Point(models.Model):
    location = models.PointField(geography=True)

Later I want to use ST_snapToGrid method to cluster those locations. But if I use

Point.objects.snap_to_grid(0.001)

I got an error:

function st_snaptogrid(geography, numeric) does not exist
LINE 1: SELECT (ST_SnapToGrid("app_point"."location",000.1)) AS...

This may be caused by the difference between geography and geometry. So how can I use snap_to_grid this method? Thanks!

Was it helpful?

Solution

you could not use Field.geography=True with snap_to_grid.

e.g:

class Point(models.Model):
    location = models.PointField(dim=2)
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top