geodjango

In PostGIS a polygon bigger than half the world is treated as it's opposite

我只是一个虾纸丫 提交于 2019-12-10 04:26:47
问题 I'm using GeoDjango with PostGIS and trying to use a polygon to get records from a database which fall inside it. If I define a polygon which is bigger than half the area of the earth it assumes the 'inside' of my polygon is the smaller area which I intended as the 'outside' and returns only results which are outside it. I can just use this smaller, wrong area to exclude results. Polygon.area seems to know what I intend so I can use this to determine when to make my search inclusive or

How To Install GEOS for GeoDjango on Windows

南笙酒味 提交于 2019-12-08 15:40:47
问题 I'm starting a GeoDjango project using Python 2.5, Django 1.2, MySQL and Apache. The project will be uploaded to a Linux server but the development will be on a Windows. The problem is I just can't get passed installing GEOS, how is it done? 回答1: I follow the instructions in http://docs.djangoproject.com/en/dev/ref/contrib/gis/install/#windows For the instalation of GEOS library in windows i use this: http://trac.osgeo.org/osgeo4w/ 回答2: what I did is to install GDAL from this answer, Unable

Django: Filtering Queryset From Two Model Fields

拜拜、爱过 提交于 2019-12-08 13:37:46
问题 My model has two fields (latitude and longitude) that I want to combine to form a point object. However, I cannot figure out how to filter based on a combination of those values: For example: >>> from django.contrib.gis.geos import Point >>> lat = 5 >>> lon = 1 >>> pnt = Point(lat, lon) >>> buf = pnt.buffer(0.0001) >>> z = Thing.objects.filter(pnt__intersects=buf) FieldError: Cannot resolve keyword 'pnt' into field. ## I dont have a model field named pnt I realize this is not the right

Set serializer geo_field as PointField from another model - Django

北战南征 提交于 2019-12-08 07:26:59
问题 I have two models and need to serialize Article as Geojson by setting the geo_field attribute as point from the Location model. After following the solution given here I get the error: Got AttributeError when attempting to get a value for field `point` on serializer `ArticleSerializer`. The serializer field might be named incorrectly and not match any attribute or key on the `Article` instance. Original exception text was: 'ManyRelatedManager' object has no attribute 'point'. Here are my

Python/django : Cannot import GeoIP

那年仲夏 提交于 2019-12-08 06:53:00
问题 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

Cross-table serialization Django REST Framework

 ̄綄美尐妖づ 提交于 2019-12-08 05:45:17
问题 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

Get Django GeometryField's coordinates with values()

你离开我真会死。 提交于 2019-12-08 02:29:13
问题 I have a model with a GeometryField . Like this - from django.contrib.gis.db import models as geo_models class School(BaseModel): # Some fields centroid = geo_models.GeometryField(blank=True, null=True) And I'm filtering the values with the values() method because I have to generate a JSON out of the QuerySet - class SearchView(View, JSONResponseMixin): def get(self, *args, **kwargs): params = self.request.GET results = {} schools = School.objects.values('id', 'code', 'name') # More stuff

Beanstalk Migration Failing for Geodjango

家住魔仙堡 提交于 2019-12-08 01:56:54
问题 I want to deploy geodjango in aws beanstalk. I have already tried this solution. It worked before. commands: 01_yum_update: command: sudo yum -y update 02_epel_repo: command: sudo yum-config-manager -y --enable epel 03_install_gdal_packages: command: yum --enablerepo=epel -y install gdal gdal-devel packages: yum: git: [] postgresql96-devel: [] gettext: [] libjpeg-turbo-devel: [] libffi-devel: [] But right now it's showing this error. AttributeError: /usr/lib64/libgdal.so.1: undefined symbol:

How to filter geodjango based on longitude and latitude

别等时光非礼了梦想. 提交于 2019-12-07 13:50:55
问题 I have an application that has been storing longitude and latitude now i want to integrate it with geodjango the application looks like this. class Location(models.Model): #other fields here lat = models.CharField(blank=True, max_length=100) lng = models.CharField(blank=True, max_length=100) now I will like to filter locations based on a distance say filter all location 1km away from location with pk = 1 using django.contrib.gis.measure import D and GEOSGeometry or should i refactor the model

GeoDjango PointField admin visualization

我们两清 提交于 2019-12-07 09:55:13
问题 I was wondering how I could change the default PointField visualization (the Openstreetmap) in admin so that I could enter simple latitude/longitude instead of select a point on the map? I looked at this one Latitude/longitude widget for pointfield? but could not get it working in any way in Django 1.6b4 Thanks 回答1: As Bibhas says you can override the widget used for the field, but the simple text input may not be usefull. So here is an example with a full widget that can be used for