Skip to content

Instantly share code, notes, and snippets.

@hanneshapke
Created April 15, 2013 14:00
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save hanneshapke/5388257 to your computer and use it in GitHub Desktop.
Save hanneshapke/5388257 to your computer and use it in GitHub Desktop.
PostGreSQL/PostGIS query for closest point to giving location > raw SQL Django query
data_point = WindData.objects.raw('SELECT * FROM meteo_winddata ORDER BY location <-> ST_SetSRID(ST_MakePoint(%s, %s),4326) LIMIT 1', [location.x, location.y])[0]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment