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

PostGIS – convert multipolygon to single polygon

I used ST_DUMP to convert a table of multipolygon geometries in PostgreSQL to a new table with polygon geometries and other columns of data. CREATE TABLE poly AS –poly will be the new polygon table WITH dump AS ( SELECT id, test, –columns from your multipolygon table (ST_DUMP(geometry)).geom AS geometry FROM multi –the name of … Read more

PostgreSQL latitude longitude query

Here’s another example using the point operator: Initial setup (only need to run once): create extension cube; create extension earthdistance; And then the query: select (point(-0.1277,51.5073) <@> point(-74.006,40.7144)) as distance; distance —————— 3461.10547602474 (1 row) Note that points are created with LONGITUDE FIRST. Per the documentation: Points are taken as (longitude, latitude) and not vice … 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

How do I add PostGIS to PostgreSQL pgAdmin?

Connect to the database using a superuser account (most often the user named postgres but in more recent versions the id of the user who installed the application.) Then issue the following SQL commands to enable PostGIS functionality. CREATE EXTENSION postgis; CREATE EXTENSION postgis_topology; You can do this from within pgAdmin or via psql -U … Read more

What’s the “E” before a Postgres string?

As per the PostgreSQL documentation https://www.postgresql.org/docs/9.0/sql-syntax-lexical.html (emphasis mine) PostgreSQL also accepts “escape” string constants, which are an extension to the SQL standard. An escape string constant is specified by writing the letter E (upper or lower case) just before the opening single quote, e.g., E’foo’. (When continuing an escape string constant across lines, write E … Read more

What is ST in PostGIS?

From the manual: PostGIS has begun a transition from the existing naming convention to an SQL-MM-centric convention. As a result, most of the functions that you know and love have been renamed using the standard spatial type (ST) prefix. Previous functions are still available, though are not listed in this document where updated functions are … Read more

JPA/Hibernate Native Queries do not recognize Parameters

The use of named parameters is not defined for native queries. From the JPA specification (section 3.6.3 Named Parameters): Named parameters follow the rules for identifiers defined in Section 4.4.1. The use of named parameters applies to the Java Persistence query language, and is not defined for native queries. Only positional parameter binding may be … Read more

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