geodjango

GeoDjango serialize GeoJSON skipping 'id' field

和自甴很熟 提交于 2019-12-12 19:05:55
问题 I've been using the Geo-Django GeoJSON serializer so that I can retrieve some objects from a PostGIS database and display them on an OpenLayers map. I'm obtaining the objects for display in the following way: gqs = self.model.objects.filter(point__distance_lte=(pnt, long(dist))) type(gqs) <class 'django.contrib.gis.db.models.query.GeoQuerySet'> and the Geo-Objects include all the model fields as expected: self.model._meta.get_fields() (<django.db.models.fields.AutoField: id>, <django.db

Unable to syncdb in GeoDjango App

随声附和 提交于 2019-12-12 09:40:06
问题 I am having a real trouble in setting up spatial database and syncing it with GeoDjango. I was able to setup the spatial database as per the geodjango documentation and create a django app but when i run python manage.py sqlall world I am getting this, Traceback (most recent call last): File "manage.py", line 10, in <module> execute_from_command_line(sys.argv) File "/home/smaranh/django-env/local/lib/python2.7/site-packages/django/core/management/__init__.py", line 443, in execute_from

django point definition

混江龙づ霸主 提交于 2019-12-12 05:59:00
问题 my models: class Mod(models.model) name = models.CharField(max_length = 255) co_x = models.DecimalField(max_digits = 11, decimal_places = 8) co_y = models.DecimalField(max_digits = 11, decimal_places = 8) my views: def closedPoint(request): location_name = str(request.POST.get("lo", default="")) nokta_x = int(float(request.POST.get("x")) nokta_y = int(float(request.POST.get("y")) poi = Point(nokta_x, nokta_y, srid = 900913) sk = Mod() poi_s = Point(sk.co_x, co_y, srid = 900913) resut_poi =

'NoneType' object has no attribute 'encode'

可紊 提交于 2019-12-12 05:00:31
问题 I'm trying to use GeoAdmin in GeoDjango. I have a table planet_osm_point and I would like to see it in the admin interface. I'm a beginner in django. I have this problem : Environment: Request Method: GET Request URL: http://127.0.0.1:8000/admin/api/planetosmpoint/ Django Version: 1.5.1 Python Version: 2.7.3 Installed Applications: ('django.contrib.auth', 'django.contrib.contenttypes', 'django.contrib.sessions', 'django.contrib.sites', 'django.contrib.messages', 'django.contrib.staticfiles',

Distance Spatial Queries with Tastypie

半世苍凉 提交于 2019-12-12 01:45:51
问题 Not sure how to use distance_lte spatial filters with tasty-pie. I can use the contains spatial filter i am unable to figure out the format for the distance_lte filter. Here is what I have tried: http://www.domain.com/myapp/api/v1/location/?format=json&coord__distance_lte={"type": "Point", "coordinates": [153.09537, -27.52618]},D(m=5) Which returns {"error": "Invalid resource lookup data provided (mismatched type)."} 回答1: From the tastypie sourcecode: # If we are filtering on a

Configuring a Postgresql POSTGIS database

大憨熊 提交于 2019-12-12 01:36:36
问题 First off, I am new to django. I am trying to use GeoLite(GeoIP2) datasets in my POSTGIS database in Django 1.10. When I attempt to configure the myapp/settings.py file, i get error messages.There seem to be database backends in different paths in the django directory;Can you please clarify why? django\contrib\gis\db\backends\postgis django\db\backends After activating my python3 virtual environment, when i try to set the default database in my settings.py file as postgresql('django.db

Calling transform() with no SRID set is not supported

家住魔仙堡 提交于 2019-12-12 01:07:08
问题 On production server I receive the attached error, not emerging on the development server. Both environments are identical (same Django 1.6 and Python 2.7 versions, using virtualenvs same RDBMS version - a postgresql 9.1 server, running locally with a reasonably similar configuration than on production). The offending code, I suppose, is in views.py : from djgeojson.views import GeoJSONLayerView class FilteredMapLayer(GeoJSONLayerView): def get_queryset(self): qs = super(FilteredMapLayer,

Geodjango: How to Buffer From Point

不羁的心 提交于 2019-12-11 11:36:05
问题 I want to have a radius based distance search. To do this, I want to create a buffer around a point object in order to filter objects that are inside it. Here is where I am at with it: >>> lat = 37.7762179974 >>> lon = -122.411562492 >>> from django.contrib.gis.geos import Point >>> pnt = Point(lat, lon) >>> buf = pnt.buffer(0.0001) But I am having problems filtering the Thing objects based on whether they are inside the buffer: >>> z = Thing.objects.filter(pnt__intersects=buf) ( I know that

Pointfield with geodjango, javascript and google maps

空扰寡人 提交于 2019-12-11 08:36:33
问题 I'm trying to display and plot a line from lattitude and longitude points stored in my database. Heres my code (I've removed some nonessential variables for brevity) Here is my model: class GpsLog(models.Model): device=models.ForeignKey(Device,related_name="logs") coordinates=models.PointField() objects = models.GeoManager() def __unicode__(self): return '%s %s ' % ( self.coordinates.x, self.coordinates.y) And here is my views: def index(request): device_table = DeviceTable(Device.objects.all

GeoDjango: How can I get the distance between two points?

有些话、适合烂在心里 提交于 2019-12-11 04:27:27
问题 My Profile model has this field: location = models.PointField(geography=True, dim=2, srid=4326) I'd like to calculate the distance between the two of these locations (taking into account that the Earth is a spheroid) using GeoDjango, so that I can store this distance in the database. How can I calculate this distance with GeoDjango? What units are the results in? Is there a 'best' way to store this data? Float? Decimal? I've reviewed previous, similar questions, and haven't found them useful.