geodjango

Setting up Django with GeoDjango Support in AWS Beanstalk or EC2 Instance

自古美人都是妖i 提交于 2019-12-19 04:21:45
问题 So I have at one point had this going via Beanstalk, using Amazon Instance (2013.09) ami-35792c5c . At the time this ebextension scripts worked great when placed in the root of your repo in .ebextensions/ 00_repo.config packages: rpm: pgdg-redhat93-9.3-1: 'http://yum.postgresql.org/9.3/redhat/rhel-6-x86_64/pgdg-redhat93-9.3-1.noarch.rpm' remi: 'http://rpms.famillecollet.com/enterprise/remi-release-6.rpm' files: "/etc/yum.repos.d/pgdg-93-redhat.repo": mode: "000644" owner: root group: root

How to calculate 3D distance (including altitude) between two points in GeoDjango

倖福魔咒の 提交于 2019-12-18 17:00:07
问题 Prologue: This is a question arising often in SO: 3d distance calculations with GeoDjango Calculating distance between two points using latitude longitude and altitude (elevation) Distance between two 3D point in geodjango (postgis) I wanted to compose an example on SO Documentation but the geodjango chapter never took off and since the Documentation 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

GeoDjango: How to create a circle based on point and radius

删除回忆录丶 提交于 2019-12-18 11:10:13
问题 I have the following (simplified) Model: class Zone(gismodels.Model): name = gismodels.CharField() poly = gismodels.PolygonField() I want to create and save a polygon that represents a circle, based upon a given point and radius. The only way I can figure out how to achieve this, is to call the postgis ST_Buffer function using raw SQL. I'm really hoping that there is another way. Is it possible to access the GEOS buffer methods? 回答1: Yes, it is possible to use the geos buffer method: >>> from

Rendering spatial data of GeoQuerySet in a custom view on GeoDjango

亡梦爱人 提交于 2019-12-17 17:29:31
问题 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

GeoDjango on Windows: “Could not find the GDAL library” / “OSError: [WinError 126] The specified module could not be found”

为君一笑 提交于 2019-12-17 06:11:18
问题 I've been trying to setup my windows computer such that I can have a local postgreSQL with PostGIS extension. With this installed I hope to be able to create a project with geodjango locally before putting it in the cloud. I have been working with Django for a little while now on my local machine with the SQLite DB, but since the next project will partly be based on coordinate based data I wanted to setup the right environment. Import note: I've installed mini-conda to run in a seperate

GeoDjango query: all point that are contained into a multi polygon

|▌冷眼眸甩不掉的悲伤 提交于 2019-12-13 15:35:17
问题 I have two models: Model_A that contains a GeoDjango Point; Model_B that contains a GeoDjnago MultiPololygon; For every element in Model_A I have to check if the point is contained into some m_polygon of Model_B element; I'm able to make this simple query. But I also thought: I have a lot of elements in Model_A and few elements in Model_B. So, probably is more efficient to iterate all elements in Model_B and check if exist some element in Model_A that it is contained into the current Model_B

GeoDjango distance query for a ForeignKey Relationship

不羁的心 提交于 2019-12-13 14:14:01
问题 I have the following models (simplified) from django.contrib.gis.db import models as geomodels modelB (geomodels.Model): objects = geomodels.GeoManager() modelA (geomodels.Model): point = geomodels.PointField(unique=True) mb = models.ForeignKey(modelB,related_name='modela') objects = geomodels.GeoManager() I am trying to find all modelB objects and sort them by distance from a given location (where distance is defined as distance between a given location and the point object of associated

How to hook up GMap to GeoDjango?

两盒软妹~` 提交于 2019-12-13 07:07:58
问题 models.py: class Location(models.Model): name = models.CharField(max_length=100) coords = gis_models.PointField(srid=4326, blank=True, null=True) forms.py: class LocationForm(gis_forms.ModelForm): class Meta: model = Location fields = ['coords', 'name'] In the add_location.html such code was automatically generated for 'coords': <div id="div_id_coords" class="form-group"> <div class="controls "> <div id="id_coords_div_map"> <div id="id_coords_map"></div> <span class="clear_features"> <a href=

Get random point from django PolygonField

佐手、 提交于 2019-12-13 04:18:55
问题 TL,DR ; I want to get a random point from a polygon (potentially) using ST_GeneratePoints. Background I'm making a GeoDjango web service and have a collection of UK Postcodes with respective boundaries like so: from django.db import models as dj_models from django.contrib.gis.db import models as gis_models class Postcode(gis_models.Model): pretty_postcode = dj_models.CharField( max_length=8 ) coords = gis_models.PolygonField( default='POLYGON EMPTY' ) I've found a delightful little PostGIS

creating a polygon from points around a point in postgis

[亡魂溺海] 提交于 2019-12-13 00:42:13
问题 I have a postgresql db using postgis 2.0 and a table of thousands of points, I would like create a polygon of the furthest points originating around a particular central location. I haven't got a clue how this would be done, any ideas anyone?? 回答1: Filter and aggregate the points, and return the convex hull of the points. So to select the points in mytable that are within a distance of 10 from id=123, and return the enclosing polygon: SELECT ST_ConvexHull(ST_Collect(A.geom)) FROM mytable A,