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

I have found the following to work for windows: Run python to check if your python is 32 or 64 bit. Install corresponding OSGeo4W (32 or 64 bit) into C:\OSGeo4W or C:\OSGeo4W64: Note: Select Express Web-GIS Install and click next. In the ‘Select Packages’ list, ensure that GDAL is selected; MapServer and Apache are also … Read more

Django sort by distance

the .distance(ref_location) is removed in django >=1.9 you should use an annotation instead. from django.contrib.gis.db.models.functions import Distance from django.contrib.gis.measure import D from django.contrib.gis.geos import Point ref_location = Point(1.232433, 1.2323232, srid=4326) yourmodel.objects.filter(location__distance_lte=(ref_location, D(m=2000))) .annotate(distance=Distance(“location”, ref_location)) .order_by(“distance”) also you should narrow down your search with the dwithin operator which uses the spatial index, distance does not use … Read more

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

To elaborate on synecdoche’s answer, the SRID is sometimes called an “EPSG” code. The SRID/EPSG code is a defacto short-hand for the Well-Known-Text representations of projections. You can do a quick search on the SRID table to see if you can find an exact or similar match: SELECT srid, srtext, proj4text FROM spatial_ref_sys WHERE srtext … Read more

GeoDjango GEOSException error

This is my solution (obviously it is ugly, like my English, but works). The problem is that the versions string has an white space unwanted in the RegEx. The error says: GEOSException: Could not parse version info string “3.4.2-CAPI-1.8.2 r3921” And the geos_version_info warns: Regular expression should be able to parse version strings such as … Read more

Getting ‘DatabaseOperations’ object has no attribute ‘geo_db_type’ error when doing a syncdb

The OP was using the GeoDjango buildpack, but in case anyone gets here using Geo buildpack and dj_database_url like I was, in settings.py don’t forget the last line: import dj_database_url DATABASES[‘default’] = dj_database_url.config() DATABASES[‘default’][‘ENGINE’] = ‘django.contrib.gis.db.backends.postgis’ UPDATE dj_database_url directly supports PostGIS. You can do without the last line in the code above if you can … Read more

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)