geodjango

GeoDjango - GDAL library giving error

纵然是瞬间 提交于 2019-12-03 23:08:21
I am trying to get GeoDjango running on ubuntu and have hit a problem with GDAL. I have downloaded and installed GDAL without problem. I had to add the following line to my project settings: GDAL_LIBRARY_PATH = '/usr/local/lib/libgdal.so.1.15.1' When I check in the shell all is good: In [1]: from django.contrib.gis import gdal In [2]: gdal.HAS_GDAL Out[2]: True However when I try and run ogrinfo as in the official tutorial I get the following error: $ ogrinfo world/data/TM_WORLD_BORDERS-0.3.shp ogrinfo: error while loading shared libraries: libgdal.so.1: cannot open shared object file: No such

Adding custom Feature attributes to ESRI Shapefile with Python

这一生的挚爱 提交于 2019-12-03 14:48:53
I am seeking a way to take an existing ESRI Shapefile that has a Feature set of 200 countries. Each country Feature has an attribute of "NAME." My objective is to create a Python script that adds an arbitrary (for now) additional attribute, say, "POPULATION". Of course I have the OSGeo and GeoDjango modules installed. I'm as far as: from osgeo import ogr infile = ogr.Open('sample.shp', 1) #'sample.shp' is a pre-existing ESRI shapefile described above inlyr = infile.GetLayerByIndex(0) Am I missing an OGR function that will allow me to insert Feature attribute fields into an existing Shapefile?

Django : is GeoDjango a Good Fit for my Website?

折月煮酒 提交于 2019-12-03 09:14:34
I'm building a real estate site in Django and have a Home model, which stores various information including the address. Database backend is using MySQL. Want to create a Yelp like search. A search where users can enter in zip code or city name, then get Home results in that area. Users can also choose the radius(5 mi, 10 mi...) from the point and get more/less results. Search results will be on google map and users can zoom in/out to get new search results within the map. Is Geo Django a good fit here? Guessing not too many people use GeoDjango, because I can't find many docs to solve

How can I query all my data within a distance of 5 meters?

江枫思渺然 提交于 2019-12-03 08:52:21
I am using GeoDjango with PostGIS. Then I am into trouble on how to query my postgres db table to get all data within a distance of 5 meters. UPDATES1 I am using GeoDjango 1.2.7 I found something from this url https://docs.djangoproject.com/en/dev/ref/contrib/gis/geoquerysets/#std:fieldlookup-distance_lte Zipcode.objects.filter( poly__distance_lte =( geom , D (* m *=5))) But don't know on how to prepare the parameter and variables. what is poly_distance_lte ? is a function? what is geom ? is a variable? how to create it? what is D ? is a function? if yes, m is a parameter name of D function?

Error Saving geodjango PointField

▼魔方 西西 提交于 2019-12-03 06:30:51
问题 I have a geo model with a PointField property. Everything works perfectly locally, but when I try to save an instance on the server, I get the following error: django.db.utils.DatabaseError: invalid byte sequence for encoding "UTF8": 0x00 I dug into the source and found that the values are being serialized differently; specifically, that value isn't being escaped before the query is executed on the server. It looks like the escaping is being done by psycopg2.Binary.getquoted() and sure enough

GeoDjango, difference between dwithin and distance_lt?

感情迁移 提交于 2019-12-03 01:49:01
Using geoDjango, what is the difference between myObj.objects.filter(point__dwithin(...etc.)) and myObj.objects.filter(point__distance_lt(...etc.)) ? Are they the same thing, or are they doing subtly different things? Ok, I did some research but I don't know if the results are of any use ;) I looked at the unit tests that they use to test the DB queries but they don't give real hints (to me). I tried to compare the generated SQL: I have already a geo application using a PostgreSQL databse. When I perform this query with __distance_lt : Place.objects.filter(location__distance_lt=(p.location, D

Django - how can I find the distance between two locations?

旧街凉风 提交于 2019-12-02 21:05:54
I have some users registered in my Django app and I want to simply be able to figure out the distance, geographically, between two users based on their zip code and then sort a list based on that. I would imagine this functionality isn't built into Django. I was looking at some options and stumbled across geodjango which seems like it might be overkill for what my needs are. Following tcarobruce's suggestion, here is my above comment as an answer: The Zip Code Database Project has a database of the latitudes and longitudes of the US zip codes, either as SQL or as CSV. They also provide the

Error Saving geodjango PointField

风流意气都作罢 提交于 2019-12-02 20:21:38
I have a geo model with a PointField property. Everything works perfectly locally, but when I try to save an instance on the server, I get the following error: django.db.utils.DatabaseError: invalid byte sequence for encoding "UTF8": 0x00 I dug into the source and found that the values are being serialized differently; specifically, that value isn't being escaped before the query is executed on the server. It looks like the escaping is being done by psycopg2.Binary.getquoted() and sure enough, it doesn't return the correct value on the server. On my machine: from psycopg2 import Binary Binary(

Postgis / Geodjango: Cannot determine PostGIS version for database

狂风中的少年 提交于 2019-12-02 18:57:50
I'm attempting to launch a GeoDjango app. I've installed Postgres & PostGIS using brew on Lion. I created a database using template_postgis: createdb -T template_postgis test . When I run python manage.py syncdb , I get the following error: django.core.exceptions.ImproperlyConfigured: Cannot determine PostGIS version for database "test". GeoDjango requires at least PostGIS version 1.3. Was the database created from a spatial database template? How can I track down the source of the error? I've checked that the user & pass in the config have access to the database etc. As a first debugging step

GeoDjango dwithin errors when using django.contrib.gis.measure.D

瘦欲@ 提交于 2019-12-02 13:48:20
问题 First off: Python 2.7.6, Django 1.6.5, Postgres 9.3.4, PostGIS 2.1.3, psycopg2 2.5.3 on RHEL 6.5 Here's the relevant model: class Location(models.Model): name = models.CharField(max_length=255) geometry = models.MultiPolygonField(blank=True, default=None, null=True) objects = models.GeoManager() # override the default manager with a GeoManager instance parent = models.ForeignKey('self', blank=True, default=None, null=True) def __unicode__(self): return self.name This query should work