Please help me out in solving this issue.
class RecievingImages(models.Model):
"""Original and Masked Images"""
name = models.CharField(max_length = 100, unique = True, primary_key=True)
cordinate_X = models.FloatField()
cordinate_Y = models.FloatField()
point = models.PointField(srid=4326, geography=True, default='POINT(0.0 0.0)')
def __str__(self):
return self.name
class Meta:
verbose_name_plural = 'Image Mapping'
I have coordinates that I got from google maps API Example here
cordinate_X : 21.2166277
cordinate_Y : 72.7763859
Technically, These coordinates are of Gujrat, India actual link of the coordinates
Now to plot on leaflet I converted that into point field with reference to this link https://stackoverflow.com/a/48293443/7999665
from django.contrib.gis.geos import Point
for l in RecievingImages.objects.all():
... l.point = Point(x=l.cordinate_X, y=l.cordinate_Y, srid=4326)
... l.save()
Now when I went back to Django admin page it's marking the coordinates wrongly somewhere in Sea
Thanks for your time.
Regards
Update
After a good amount of googling, I found that there could be an issue of srid used that is, google maps might be using '3587' and I have used '4326' I tried to change this but am getting an error.
raise NotSupportedError('PostGIS only supports geography columns with an SRID of 4326.')
django.db.utils.NotSupportedError: PostGIS only supports geography columns with an SRID of 4326.
The database I have used is PostGIS.
I think your coordinates are swapped. X is longitude, Y is latitude.
Your link shows coordinates here: 21°12'59.9"N 72°46'35.0"E. Google puts latitude first.
Try this:
cordinate_X : 72.7763859
cordinate_Y : 21.2166277