pythongisgdalgeoip2

Requirements for GIS, PointField, and Distance Calculation with Geography=True, Database question included


Referring to Django: Plugins, packages, or built-in functions.

Do I need to install other plugins to use gis functions "PointField" and distance calculation queries with dwithin? Error now is either something to do with missing PointField in init or asking for GDAL (I am using GeoIP2 w/ maxmind db? Not sure if those are similar or work together) -- Cant find a clear answer as to what is needed and what is not.

Also under assumption that dwithin is the fastest filter for this - granted I have a distance max? That ST_Distance was a slower function and might be to slow for a larger db?

Also will it matter if I am using sqllite3 for now to test? Is it capable of these functions? Keep reading about PostGIS and other limitations.

Thanks you much!


Solution

  • What I ended up doing -- To the best of my recollection:

    So I could have either made Sqlite3 a Spacial Database -- I tried but either had problems with making it spacial or was just my GDAL issues I ran into later that kept me from being successful, planning on using PostgreSQL later anyways I just decided it was time to move over

    Then I decided to swap over to PostgreSQL w/ PostGIS along with OSGeo4W and also pip installed psycopg2 for PostgreSQL.
    When installing PostgreSQL: PostGIS I prefer to "Create Spacial Database" with the name I want to use at install - simply because I have tried to make my own but I dont end up having nearly the functionality that gets added the way its created by the install. (Yes I am new and have no idea how to make a new spacial db on my own lol) Also say yes to all Environment Variables, helps everything find the needed files.

    Not 100% but I believe everything needs to be the same bit, if your using 32 bit python, then you want 32 bit everything else (including OSGeo4W) (I believe this also includes windows as you might not have the 32 bit dll's needed otherwise)

    After installing OSGeo4W you either need to point to your GDAL Dll directly in settings: GDAL_LIBRARY_PATH=your_path_to_the_dll/gdal204.dll
    **set to actual dll you have, django seem to only look for versions 2.2 and lower so if you only put the path it will only find gdal202 and a few older versions.

    (you can edit the libgdal.py file under site-packages.django.contrib.gis.gdal so it searches for the newer versions of gdal)

    I had SERIOUS headaches trying to get this to work on my year old windows 7 64bit install with lots of random Visual Studio installs and such, 32 bit python, 32 bit gdal, ect.. and it was a MESS, Dll errors left and right, several days of thinking I almost had it (I didnt) -- If you have lots of issues, I highly suggest a fresh Windows 10 64bit install and everything 64bit - Or do what seems to be the better suggestion and try to dev on ubuntu.

    TRLR: If you are having to many problems and do not know what to do:
    Install fresh windows 10 64bit follow instructions on Django Site here, using 64 bit versions of everything. https://docs.djangoproject.com/en/2.1/ref/contrib/gis/install/#windows Then dont forget to put your GDAL_LIBRARY_PATH