geodjango

Django - how can I find the distance between two locations?

风流意气都作罢 提交于 2019-12-31 10:46:30
问题 I have some users registered in my Django app and I want to simply be able to figure out the distance, geographically, between two users based on their zip code and then sort a list based on that. I would imagine this functionality isn't built into Django. I was looking at some options and stumbled across geodjango which seems like it might be overkill for what my needs are. 回答1: Following tcarobruce's suggestion, here is my above comment as an answer: The Zip Code Database Project has a

Testing a GeoDjango app with a PostGIS database

余生长醉 提交于 2019-12-31 03:07:12
问题 I am trying to enable testing on a brand new Django app. It has to run geometry tests. My Postgres installation in Postgres.app (with Postgis 2), my default database runs just fine (no problems with Django app syncing, creating, etc), but when I run manage.py test I get an error: django.db.utils.ProgrammingError: type "geography" does not exist LINE 4: "geom" geography(GEOMETRY,4326) NOT NULL Full errors: https://gist.github.com/dyve/11dcd455aa5a25628773 I know that Django creates a Postgres

GeoDjango: PostgreSQL not running migrations, object has no attribute 'geo_db_type

有些话、适合烂在心里 提交于 2019-12-30 17:29:48
问题 Django v1.11.5 I'm trying to install GeoDjango to play around with GoogleMaps. I installed PostgreSQL app for MAC and installed pip install psycopg2 . I also used home-brew to install GDAL. Edited settings.py to add: DATABASES = { 'default': { 'ENGINE': 'django.db.backends.postgresql', 'NAME': 'djangodb', 'USER': 'admin', 'PASSWORD': '', 'HOST': 'localhost', 'PORT': '5432', } } However, when I run python manage.py migrate I get: AttributeError: 'DatabaseOperations' object has no attribute

Configuring Amazon Elastic Beanstalk with PostGIS

↘锁芯ラ 提交于 2019-12-30 06:29:09
问题 Does anyone have any experience setting up Amazon Elastic Beanstalk with PostGIS (so that I can take advantage of Geodjango)? There are a number of features that the default setup (RDS, featuring MySQL) does not currently support out of box: 1. PostgreSQL + PostGIS 2. The ability to install C/C++ libraries such as GEOS and Proj.4 Thanks in advance 回答1: If you want to use geodjango with Amazon Elastic Beanstalk you need to create a custom AMI where you can install PostGIS and then point your

Configuring Amazon Elastic Beanstalk with PostGIS

回眸只為那壹抹淺笑 提交于 2019-12-30 06:29:05
问题 Does anyone have any experience setting up Amazon Elastic Beanstalk with PostGIS (so that I can take advantage of Geodjango)? There are a number of features that the default setup (RDS, featuring MySQL) does not currently support out of box: 1. PostgreSQL + PostGIS 2. The ability to install C/C++ libraries such as GEOS and Proj.4 Thanks in advance 回答1: If you want to use geodjango with Amazon Elastic Beanstalk you need to create a custom AMI where you can install PostGIS and then point your

Using GeoJson data format how can we write dynamic query for “properties dictionary fields ”?

╄→гoц情女王★ 提交于 2019-12-24 10:22:40
问题 I have data in geojson format. Here is my data : { "type" : "FeatureCollection", "features" : [ { "type" : "Feature", "properties" : { "year" : 2015, "season" : "rabbi", "crop" : "banana", "district" : "pune", "taluka" : "haveli", "circle" : "uralikanchan", "farmer" : 100 }, "geometry" : { "type" : "Polygon", "coordinates" : [ [ 74.129992, 18.505494 ], [ 74.129047, 18.505494 ], [ 74.128275, 18.504436 ], [ 74.127588, 18.503052 ], [ 74.114456, 18.498331 ], [ 74.113941, 18.498331 ], [ 74.112482,

Setting up a SRID to a Leaflet - Geodjango

不打扰是莪最后的温柔 提交于 2019-12-24 05:58:30
问题 I have data in my Postgres DB which are in 31277 projection. Anyway, I am using Leaflet map to show them with Geodjango. Right now, my data are moved somewhere down in the map, so I need to change the projection of the Leaflet map. In documentation (http://django-leaflet.readthedocs.io/en/latest/advanced.html) is written just to add SRID attribute to LEAFLET_CONFIG variable, which I did. Like here: LEAFLET_CONFIG = { 'DEFAULT_ZOOM': 13, 'MIN_ZOOM': 2, 'MAX_ZOOM': 18, 'SRID':31277 } But after

OSError in Geodjango: [WinError 127] : The specified procedure could not be found

妖精的绣舞 提交于 2019-12-24 05:47:55
问题 Im trying to use Django with Geodjango , I followed all documentation steps, but still got this error when trying to make migrations: OSError: [WinError 127] : The specified procedure could not be found The models.py is correct, I'm using from geodjango site, and this is my settings.py import os # Build paths inside the project like this: os.path.join(BASE_DIR, ...) BASE_DIR = os.path.dirname(os.path.dirname(os.path.abspath(__file__))) # Quick-start development settings - unsuitable for

Geodjango distance query not retrieving correct results

岁酱吖の 提交于 2019-12-24 03:12:44
问题 I am trying to retrieve some posts depending on their proximity geographically. As you can see in the code I am using GeoDjango and the code is executed within a view. The issue is that the distance filter seems to be completely disregarded. When I check the distances on the queryset I get the expected distances (1m and 18km) but the 18km post should not have been retrieved. def get(self, request, format=None): latlon=request.query_params pnt = GEOSGeometry('SRID=28992;POINT(%s %s)'%(latlon[

Django: Annotation on Subquery

点点圈 提交于 2019-12-24 03:04:29
问题 I'm trying to annotate a queryset of Station s with the id of the nearest neighbouring Station using Django 2.0.3 and PostGIS (GeoDjango) functions. Simplified Station model: class Station(models.Model): name = models.CharField(max_length=128) location = models.PointField() objects = StationQuerySet.as_manager() The problem I'm having is trying to compute the closest distance, which involves annotating a subquery which refers to the location in the outer queryset. from django.db.models import