geodjango

GeoDjango GEOSException error

故事扮演 提交于 2019-11-28 15:47:01
Trying to install a GeoDjango on my machine. I'm really new to Python and being brought into a project that has been a very tricky install for the other team members. I installed Python 2.7 and GEOS using brew, and running PSQL 9.2.4 but keep getting this error when I try to get the webserver running: __import__(name) File "/Users/armynante/Desktop/uclass-files/uclass-env/lib/python2.7/site packages/django/contrib/gis/geometry/backend/geos.py", line 1, in <module> from django.contrib.gis.geos import ( File "/Users/armynante/Desktop/uclass-files/uclass-env/lib/python2.7/site packages/django

How to make/use a custom database function in Django

左心房为你撑大大i 提交于 2019-11-28 10:15:25
Prologue: This is a question arising often in SO: Equivalent of PostGIS ST_MakeValid in Django GEOS Geodjango: How to Buffer From Point Get random point from django PolygonField Django custom for complex Func (sql function) and can be applied to the above as well as in the following: Django F expression on datetime objects I wanted to compose an example on SO Documentation but since it got shut down on August 8, 2017, I will follow the suggestion of this widely upvoted and discussed meta answer and write my example as a self-answered post. Of course, I would be more than happy to see any

3d distance calculations with GeoDjango

回眸只為那壹抹淺笑 提交于 2019-11-28 05:52:21
问题 I am using python 2.7.12 django 1.10.6 postgreSQL 9.5.6 postGIS 2.2.2 First question I need to use GeoDjango to calculate distance between two points. When I checked the documentation it says that GeoQuerySet.distance() is deprecated and instead use Distance() from django.contrib.gis.db.models.functions . The following code works OK: from django.contrib.gis.db.models.functions import Distance p1 = Instrument.objects.get(pk=151071000).coordinates p2 = Instrument.objects.filter(pk=151071008)

django json serializer does not implement geojson

孤街浪徒 提交于 2019-11-28 05:48:38
问题 I am in the process of building a website on geodjango. On the front end I have a map on openlayers and I want to be able to fire ajax queries at some django url and get back geojson. The problem is that the standard django json serializer doesn't do geojson. So I have a model like: class Asset (models.Model): objects = models.GeoManager() url_name = models.CharField(max_length=200) name = models.CharField(max_length=200) point = models.PointField(srid=4326) def __unicode__(self): return self

How to debug: Internal Error current transaction is aborted, commands ignored until end of transaction block

此生再无相见时 提交于 2019-11-28 05:06:06
Hi Stackoverflow people, I do my first steps with GeoDjango and I am looking for better options to check faulty sql statements. So far, I simply wanted to safe a lng+lat point in my postgresql table. The model is defined with: geolocation = models.PointField(_('Geo Location'), geography=True, null = True, blank = True, help_text=_('Geolocation with Longitude and Latitude')) objects = models.GeoManager() In my view, I try to execute the following command savedProject.geolocation = GEOSGeometry('POINT(%s %s)' %(u_lng,u_lat)) but I receive the following error when I try to save the form:

Rendering spatial data of GeoQuerySet in a custom view on GeoDjango

纵然是瞬间 提交于 2019-11-28 03:43:32
I have just started my first project on GeoDjango. As a matter of fact, with GeoDjango powered Admin application we all have a great possibility to view/edit spatial data, associated with the current object. The problem is that after the objects having been populated I need to render several objects' associated geometry at once on a single map . I might implement it as a model action, redirecting to a custom view. I just don't know, how to include the OpenLayers widget in the view and how to render there my compound geometry from my GeoQuerySet. I would be very thankful for any hint from an

Calculate point based on distance and direction

大憨熊 提交于 2019-11-27 20:23:11
问题 I would like to calculate a point based on direction and distance using GeoDjango or GeoPy. For example, If I have a point that is (-24680.1613, 6708860.65389) I would like to find out a point 1KM North, 1KM East, 1KM Sourh and 1KM west using Vincenty distance formula. I closest thing I can find is a "destination" function in distance.py (https://code.google.com/p/geopy/source/browse/trunk/geopy/distance.py?r=105). Although I cannot find this documented anywhere and I'm yet to figure out how

Calculating distance between two points using latitude longitude and altitude (elevation)

旧时模样 提交于 2019-11-27 17:03:31
问题 I'm trying to calculate distance between two points, using latitude longitude and altitude (elevation). I was using euklides formula in order to get my distance: D=√((Long1-Long2)²+(Lat1-Lat2)²+(Alt1-Alt2)²) My points are geographical coordinates and ofcourse altitude is my height above the sea. I only have lat and lng, I'm using GOOGLE API Elevation to get my altitude. I'm developing an application which calculates my traveled distance (on my skis). Every application which I have used, gets

How do I convert kilometres to degrees in Geodjango/GEOS?

两盒软妹~` 提交于 2019-11-27 14:23:32
I'm using the "buffer" method from the GEOS API to create a circle based on a point and a radius in GeoDjango, according to this answer: GeoDjango: How to create a circle based on point and radius As one commenter noted, you'll have to convert the radius in km to degrees... but how? I guess it's a quick formula but it's greek to me. I'd be grateful for any pointers. The answer may depend upon location on earth. Near the equator, 1km is going to equal roughly 0.008 degrees (1 km / 40,000 km * 360 degrees) of latitude and longitude, but near the poles, 1km is going to equal roughly 0.008 degrees

GeoDjango GEOSException error

ⅰ亾dé卋堺 提交于 2019-11-27 09:23:21
问题 Trying to install a GeoDjango on my machine. I'm really new to Python and being brought into a project that has been a very tricky install for the other team members. I installed Python 2.7 and GEOS using brew, and running PSQL 9.2.4 but keep getting this error when I try to get the webserver running: __import__(name) File "/Users/armynante/Desktop/uclass-files/uclass-env/lib/python2.7/site packages/django/contrib/gis/geometry/backend/geos.py", line 1, in <module> from django.contrib.gis.geos