Re: [postgis-users] Nearest Neighbor on Large Datasets

2013-04-08 Thread Spencer Gardner
Users Discussion > Subject: Re: [postgis-users] Nearest Neighbor on Large Datasets > > Thanks! That did the trick. I had previously tried a slightly > different version of your solution but it was far less efficient. > > > > From: postgis-users-boun...@lists.osgeo.org [mailt

Re: [postgis-users] Nearest Neighbor on Large Datasets

2013-04-08 Thread Pierre Racine
.osgeo.org] On Behalf Of Pierre Racine > Sent: Monday, April 08, 2013 10:41 AM > To: PostGIS Users Discussion > Subject: Re: [postgis-users] Nearest Neighbor on Large Datasets > > > > Try this: > > > > SELECT grid.pk_uid, point.pk_uid AS el_id, point.elevation &g

Re: [postgis-users] Nearest Neighbor on Large Datasets

2013-04-08 Thread Spencer Gardner
Users Discussion Subject: Re: [postgis-users] Nearest Neighbor on Large Datasets Try this: SELECT grid.pk_uid, point.pk_uid AS el_id, point.elevation FROM grid_rail_lines grid, elev_rail_combined point WHERE point.pk_uid = (SELECT point.pk_uid id2 FROM grid_rail_lines point ORDER

Re: [postgis-users] Nearest Neighbor on Large Datasets

2013-04-08 Thread Pierre Racine
ostgis-users-boun...@lists.osgeo.org [mailto:postgis-users-boun...@lists.osgeo.org] On Behalf Of Spencer Gardner Sent: Monday, April 08, 2013 11:08 AM To: 'PostGIS Users Discussion' Subject: [postgis-users] Nearest Neighbor on Large Datasets I have a layer of grid cells and a layer of

[postgis-users] Nearest Neighbor on Large Datasets

2013-04-08 Thread Spencer Gardner
I have a layer of grid cells and a layer of discreet points representing elevation samples. My grid layer has a total of about 430,000 cells, the elevation data contains about 320,000 points, and both datasets have spatial indexes on them. I need to join each grid cell with the nearest elevation