geodjango

How efficient is it to order by distance (entire table) in geodjango

北战南征 提交于 2019-12-01 06:05:07
问题 Assume that I have the following data model Person(models.Model): id = models.BigAutoField(primary_key=True) name = models.CharField(max_length=50) location = models.PointField(srid=4326) Assume also that I have an app that makes queries to this django backend, and the only purpose of this app is to return a (paginated) list of registered users from closest to farthest. Currently I have this query in mind: # here we are obtaining all users in ordered form current_location = me.location people

GeoDjango could not find GDAL library in Windows 10

家住魔仙堡 提交于 2019-12-01 05:20:54
I am using Django 11.4 on Windows 10 and I am having problems when I try and migrate my models. I receive this error: django.core.exceptions.ImproperlyConfigured: Could not find the GDAL library (tried "gdal201", "gdal20", "gdal111", "gdal110", "gdal19") I followed GeoDjango's installation instructions ( https://docs.djangoproject.com/en/1.11/ref/contrib/gis/install/ ), but I am still having trouble. Everything I have found on this error says to change the system environment variables. I installed OSGe4W and added GDAL_DATA = C:\OSGeo4W\share\gdal as well as PROJ_LIB= C:\OSGeo4W\share\proj . I

GeoDjango could not find GDAL library in Windows 10

落花浮王杯 提交于 2019-12-01 04:01:27
问题 I am using Django 11.4 on Windows 10 and I am having problems when I try and migrate my models. I receive this error: django.core.exceptions.ImproperlyConfigured: Could not find the GDAL library (tried "gdal201", "gdal20", "gdal111", "gdal110", "gdal19") I followed GeoDjango's installation instructions (https://docs.djangoproject.com/en/1.11/ref/contrib/gis/install/), but I am still having trouble. Everything I have found on this error says to change the system environment variables. I

Install Spatialite for python (GeoDjango) on OS X

旧时模样 提交于 2019-12-01 00:15:33
问题 I am tearing my hair out trying to install Spatialite for GeoDjango! I am already using Homebrew, it's generally easy and convenient so I initially tried to follow the Homebrew instructions for GeoDjango. But this stops short of installing any database, i.e. Spatialite. The next step is to try and install Spatialite itself, but there are no Homebrew-specific instructions provided by Django docs. I found this tutorial which looks perfect - a Homebrew and virtualenv-friendly install of

Configuring Amazon Elastic Beanstalk with PostGIS

不想你离开。 提交于 2019-11-30 20:12:46
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 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 Elastic Beanstalk Application to that AMI when spinning up. Here is a good tutorial on how to customize an

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

混江龙づ霸主 提交于 2019-11-30 15:35:16
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-answered post. Of course, I would be more than happy to see any different approach as well!! Question:

Howto merge 2 Django QuerySets in one and make a SELECT DISTINCT

∥☆過路亽.° 提交于 2019-11-30 11:08:19
models.py class SinglePoint(models.Model): attributes = models.TextField(blank=True) name = models.CharField(max_length=100) geom = models.PointField() #Kartenposition objects = models.GeoManager() class Connection(models.Model): name = models.CharField(max_length=100) #points = models.ManyToManyField(SinglePoint) #OLD p1 = models.ForeignKey(SinglePoint, related_name='p1_set') #NEW p2 = models.ForeignKey(SinglePoint, related_name='p2_set') #NEW obs = models.ManyToManyField(Observation, blank=True) conds = models.ManyToManyField(Condition, blank=True) objects = models.GeoManager() class Meta:

How do you know what SRID to use for a shp file?

蹲街弑〆低调 提交于 2019-11-30 10:20:27
问题 I am trying to put a SHP file into my PostGIS database, the the data is just a little off. I think this is because I am using the wrong SRID. The contents of the PRJ file are as follows: GEOGCS["GCS_North_American_1983", DATUM["D_North_American_1983", SPHEROID["GRS_1980",6378137.0,298.257222101]], PRIMEM["Greenwich",0.0], UNIT["Degree",0.0174532925199433]] What SRID does this correlate to? And more generally, how can I look up the SRID based on the information found in the PRJ file? Is there

Latitude/longitude widget for pointfield?

早过忘川 提交于 2019-11-30 08:49:00
Is there a widget for PointField as separate latitude/longitude inputs? Like SplitDateTimeWidget for DateTimeField. Here's my working custom field and widget: class LatLongWidget(forms.MultiWidget): """ A Widget that splits Point input into two latitude/longitude boxes. """ def __init__(self, attrs=None, date_format=None, time_format=None): widgets = (forms.TextInput(attrs=attrs), forms.TextInput(attrs=attrs)) super(LatLongWidget, self).__init__(widgets, attrs) def decompress(self, value): if value: return tuple(reversed(value.coords)) return (None, None) class LatLongField(forms

GeoDjango on Windows: Try setting GDAL_LIBRARY_PATH in your settings

此生再无相见时 提交于 2019-11-30 07:38:12
I've done this a dozen times before, but something isn't working this time.. Following the docs: https://docs.djangoproject.com/en/1.11/ref/contrib/gis/install/#windows I'm trying to set up GeoDjango on a Windows machine (this one is a virtual windows 10 set up on paperspace.com). There seems to be a problem with my PATH settings, but I can't figure out what it is. I've run the commands highlighted in the instructions. I've checked my PATH variables and everything seems ok. I've tried pointing them to both the 32-bit and 64-bit versions of OSGeo4Win. Regardless, I get the following output