geodjango

How to convert the UTM to Lat/Long in Python?

吃可爱长大的小学妹 提交于 2019-12-11 04:26:34
问题 { "type": "MultiPolygon", "coordinates": [[[ [6707794.77817316, 1952512.97762237], [6707794.43138905, 1952566.21209599], [6707897.49942442, 1952567.26754007], [6707897.9039513, 1952513.5347079], [6707794.77817316, 1952512.97762237] ]]] } these are my UTM coordinates for Sacramento city from pyproj import Proj Lat = 52.063098675 Lon = -114.132980348 ZoneNo = "11" #Manually input or from other sources myProj = Proj("+proj=utm +zone="+\ ZoneNo+", +north +ellps=WGS84 +datum=WGS84 +units=m +no

GeoDjango GeoQuerySet.distance() results in 'ST_Distance output only available on GeometryFields' when specifying a reverse relationship in field_name

让人想犯罪 __ 提交于 2019-12-11 03:14:56
问题 From the docs and other questions, sorting a GeoQuerySet by distance should be straightforward, but I'm having trouble getting it work. Here is an example to demonstrate the situation of the problem: Lets say I got two models in two different apps. One model in appA and another in appB as defined below: # appA/models.py class Store(models.Model): title = models.CharField() # appB/models.py from appA.models import Store class StoreLocation(models.Model): store = models.ForiegnKey(Store)

How to integrate Geodjango with Google Maps API 3?

五迷三道 提交于 2019-12-11 01:56:31
问题 I have a geodjango queryset containing several fields but want to use only user_name and location (a point field) which I want to use as a marker in google maps API 3. Bear with me as I don’t know Javascript and I have a series of questions. Take this as conceptual brainstorming for a novice: My SO search suggests that I need to serialize the queryset objects to JSON. I use the built-in serializer module to convert to JSON. I think the JSON objects are converted in views.py (let’s call it

Get projection limits from Postgis

雨燕双飞 提交于 2019-12-11 00:48:35
问题 I receive spatial queries to my API in lat/lon coordinate pairs. My spatial data is in projections that don't cover the entire globe, which follows that some queries are out of bounds. I'd like to respond to wrong queries with helpful error message. Rather than try to find out some in GIS specifications or standards what boundaries each projection has (and getting correct lat/lon pairs from those), I'd like to know wether I could either ask the limits from Postgis or ask if specific point is

Geodjango Exception when importing django.contrib.gis.gdal: OSError: /usr/lib/libgdal.so.1: undefined symbol: sqlite3_column_table_name

僤鯓⒐⒋嵵緔 提交于 2019-12-11 00:27:59
问题 I have followed the tutorial for installing Geodjango on my Ubuntu 14.04. I am using Django 1.10 and Python 3.5, postgres-9.6 and postgis 2.3. I have checked here and here, but found no solution. In a newly installed ubuntu 14.04 Virtual Machine, it worked. But in my installation, when I tried making migrations, I got: OSError: /usr/lib/libgdal.so.1: undefined symbol: sqlite3_column_table_name Investigating a bit further, I tried simply: from django.contrib.gis import gdal And got: Traceback

GeoDjango error: 'DatabaseOperations' object has no attribute 'geo_db_type'

僤鯓⒐⒋嵵緔 提交于 2019-12-10 22:07:48
问题 I've been picking apart this problem for about a week. I have looked at all of the other stackoverflow posts and cant figure it out. Anyway, I'm trying to add a geodjango app to my project. This project is still in development, anyway, I have two databases, the default and one labeled locations_db. I want my geodjango functionality in the locations database and all the other stuff in the default database. The locations database is a postGIS database that is working fine and the default is a

django-rest-framework-gis related field

早过忘川 提交于 2019-12-10 21:25:48
问题 I have a geographical model structure where multiple events can have the same location: class Event(models.Model): name = models.CharField(max_length=128, blank=True, null=True) location = models.ForeignKey('MarketLocation', null=True, blank=True) class EventLocation(models.Model): location = models.PointField(srid=4326) I am using the GeoFeatureModelSerializer provided by django-rest-framework-gis to output a single JSON object but the PointField is being rendered as a string instead of a

installing GeoDjango on Heroku

99封情书 提交于 2019-12-10 17:57:20
问题 I am trying to build a webapp which uses GeoDjango. The app is to be hosted on Heroku, but I am facing issues in it. I am using this buildpack but then this error is coming. Figured out that this is happening because of Cedar 14 but I am not clear as to what should I do next. Also I tried using this buildpack but as discussed here, this issue can be resolved by using the buildpath as $ heroku config:add BUILDPACK_URL=https://github.com/cyberdelia/heroku-geo-buildpack.git#1.3 I tried the same

“Unable to locate the SpatiaLite library.” Django

妖精的绣舞 提交于 2019-12-10 16:49:17
问题 I'm trying to make Django's SQLite3 accept spatial queries. This tutorial suggests that I add this to settings: SPATIALITE_LIBRARY_PATH = 'mod_spatialite' Which produces this error: django.core.exceptions.ImproperlyConfigured: Unable to load the SpatiaLite library extension "mod_spatialite" because: The specified module could not be found. I also tried doing this : SPATIALITE_LIBRARY_PATH = r'C:\\Program Files (x86)\\Spatialite\\mod_spatialite-4.3.0a-win-x86\\mod_spatialite-4.3.0a-win-x86\

How to calculate distance between two PointField?

狂风中的少年 提交于 2019-12-10 11:08:26
问题 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