geodjango

heroku outputs “error fetching custom buildpack”, but only sometimes

跟風遠走 提交于 2019-12-07 06:28:57
问题 I have a Django project hosted on Heroku with a buildpack forked from cirlabs/heroku-buildpack-geodjango. Sometimes when I push to Heroku it responds with Counting objects: 16, done. Delta compression using up to 4 threads. Compressing objects: 100% (9/9), done. Writing objects: 100% (9/9), 790 bytes, done. Total 9 (delta 7), reused 0 (delta 0) -----> Heroku receiving push -----> Fetching custom buildpack... failed ! Heroku push rejected, error fetching custom buildpack To git@heroku.com

GeoDjango filter by distance from a model field

荒凉一梦 提交于 2019-12-07 06:04:15
问题 My question is pretty much the same as this. But its quite old and it feels like it must be a fairly common scenario that there might be a better solution to. I have a model that is something like: class Person(models.Model): location = models.PointField(srid=4326) willing_to_travel = models.IntegerField() If I want all instances of Person who are within a set distance (e.g. 10 miles) of a point p , I can do it like this: Person.objects.filter(location__distance_lte=(p, D(mi=10))) But I would

Cross-table serialization Django REST Framework

丶灬走出姿态 提交于 2019-12-07 00:12:35
I have two models with a many-to-many relationship and I am trying to return some geojson by using the Django REST Framework. The data I am trying to return is th pub_date and coordinates (represented by a PointField in GeoDjango). Everytime I try and return the geojson I get the error Field name 'city' is not valid for model 'Article' . I'm pretty new to django/geodjango and this is the first time I've used the Django REST Framework. I've gone through the docs but can't work out where I'm going wrong (or maybe even where to start). Here my models and serializers. models.py: class Location

GeoDjango, what SRID to use for PointField interfacing with Google Maps V3 API?

[亡魂溺海] 提交于 2019-12-06 23:19:07
问题 I am a bit confused, what should I set my SRID value to in my GeoDjango PointField to stay accurate in the context of addresses being geocoded via google maps api into coordinates and distances being queried via django-postgis? Im getting mixed opinions reading the threads around the net and stackover flow and am unsure what to do. As you can see my application is using geopy with google maps api to geocode an address. Right now my coordinates field doesn't have an SRID set which defaults to

GeoDjango within a NE, SW box

℡╲_俬逩灬. 提交于 2019-12-06 21:06:42
问题 I'm creating a geo app with Google Maps and I receive bounding box as 2 coordinates: north east south west I have a model with PointField. from django.contrib.gis.db import models class Place(models.Model): name = models.CharField(max_length=200) address = models.CharField(max_length=200) location = models.PointField() How could I perform a query to get all places within bounding box? 回答1: Assuming that the "2 coordinates" are x,y tuples, for example: ne = (50.0, -90) sw = (45.5, -95) You can

Python/django : Cannot import GeoIP

这一生的挚爱 提交于 2019-12-06 16:52:53
I cannot import GeoIP in django. I searched and tested this error two days, but still could not know problem. Surely, I installed GeoDjango. I'm on MacOS 10.8 following is log by tested by django shell 1>>from django.contrib.gis import geoip 2>>module 'django.contrib.gis.geoip' from '/Library/Python/2.7/site-packages/django/contrib/gis/geoip/ init .pyc'> it works. even I could find geoip class at Library/Python/2.7/site-packages/django/contrib/gis/geoip/base.py 3>>> from django.contrib.gis.geoip import geoip Traceback (most recent call last): File "", line 1, in ImportError: cannot import name

How to calculate distance between two PointField?

徘徊边缘 提交于 2019-12-06 09:23:20
I use Postgis with Django to store geographic points. I have a model like the following: from django.contrib.gis.db import models class Event(models.Model) position = models.PointField() I have two events(ev1, ev2). Here is the position value of each: SRID=4326;POINT (-73.6335140000000052 45.5472019999999986) SRID=4326;POINT (-73.6267909999999972 45.5459189999999978) My goal is to get distance in meters between those two points. If i do: ev1.position.distance(ev2.position) I get 0.006844327432269004 How can I convert this value in meters? Thanks! Michael I was able to make it work, but only

Store a Circle in Geodjango + Postgres

霸气de小男生 提交于 2019-12-06 07:51:09
问题 Looking to store a circle in a geodjango field so I can use the geodjango query __contains to find out if a point is in the circle (similar to what can be done with a PolygonField). Currently have it stored as a Decimal radius and GeoDjango Point Field, but need a way to query a list of locations in the DB such that these varying circles (point field and radii) contain my search point (long/lat). Hope it makes sense. 回答1: Technically speaking, PostGIS supports CurvePolygon and CircularString

Installation error while trying to install a gis application using geodjango?

邮差的信 提交于 2019-12-06 04:58:31
django.core.exceptions.ImproperlyConfigured: Cannot determine PostGIS version for database "geodatabase". GeoDjango requires at least PostGIS version 1.3. Was the database created from a spatial database template? This is the error I got when I followed this tutorial http://invisibleroads.com/tutorials/geodjango-googlemaps-build.html I got this error when I didn't properly use the POSTGIS template to create my database (exactly like the error suggests). So did you properly install PostGIS with the spatial database template and did you create your db with -T template_postgis ? createdb -U

How to use GeoDjango Pointfield in Form?

。_饼干妹妹 提交于 2019-12-06 04:43:28
问题 I wanted to know to to use the PointField widget that is automatically generated from a Django form. I am using the generic views for this (CreateView) This is what my model looks like. from django.contrib.gis.db import models class Post(models.Model): title = models.CharField(max_length=60) text = models.CharField(max_length=255) location = models.PointField(geography=True, null=True, blank=True) objects = models.GeoManager() The form is then automatically generated for me and I just call it