Re: [postgis-users] Measure distance to nearest border

2010-10-22 Thread Andreas Forø Tollefsen
Thanks. Solved! That worked like a charm. Exactly what i wanted. Andreas 2010/10/21 Nicklas Avén > Ok > > still don't get the second query. If I understand you right you could try > this: > > CREATE TABLE borddisttest2 AS > select a.gid, a.cell, MIN(ST_Distance(a.centroid, b.the_geom)) AS dist

Re: [postgis-users] Measure distance to nearest border

2010-10-21 Thread Nicklas Avén
Ok still don't get the second query. If I understand you right you could try this: CREATE TABLE borddisttest2 ASselect a.gid, a.cell, MIN(ST_Distance(a.centroid, b.the_geom)) AS distance FROM pgfinal2008 a, cshapes b, cshapes c WHERE a.gwcode != b.gwcode AND b.gwsyear <= 2008 AND b.gweyear >= 2

Re: [postgis-users] Measure distance to nearest border

2010-10-21 Thread Andreas Forø Tollefsen
Ok. I will try to explain more in detail. I have a vector grid consisting of 64818 grid cells. Each of these cells are stored in the pgfinal2008 table, with two geometries variables: centroid (point) and cell (polygon). Each grid cell have a gwcode variable which is the country code. In addition i

Re: [postgis-users] Measure distance to nearest border

2010-10-21 Thread Nicklas Avén
hmm, I have to admit I don't really understand what you are trying to do, but there are some thingsI don't think you really mean. select a.gid, MIN(ST_Distance(a.centroid, b.the_geom)) AS distance FROM pgfinal2008 a, cshapes b, cshapes c WHERE a.gwcode != b.gwcode AND b.gwsyear <= 2008 AND b.gw

Re: [postgis-users] Measure distance to nearest border

2010-10-21 Thread Andreas Forø Tollefsen
Thanks. I have found a way to do this calculation. However, since i gave 64818 cells and almost 200 countries, the distance from every cell to every country is calculated before the minimum distance is selected. This takes awful lot of time. Any ideas on how to increase the performance? DROP TABL

Re: [postgis-users] Measure distance to nearest border

2010-10-13 Thread Nicklas Avén
Hi You can not cast to geography that way (if I haven't missed something essential) And if you could you would mix geometry and geograph type in ST_Distance, which wouldn't work. St_Distance for geometry vs geography uses totally differnt algorithms. The geography calculations is far more advanc

Re: [postgis-users] Measure distance to nearest border

2010-10-13 Thread Andreas Forø Tollefsen
Hi Thanks, I will give it a try. The reason I used the geography types in the distance query, were to get the distance in meters instead of degrees. Andreas 2010/10/13 Nicklas Avén > Hi > > As I understand you you want to get the distance from each cell to the > closest neighbour country. The

Re: [postgis-users] Measure distance to nearest border

2010-10-13 Thread Nicklas Avén
Hi As I understand you you want to get the distance from each cell to the closest neighbour country. Then, why don't you just query the distance from your cell to closest country with other gwcode?Maybe something like: Create table borddisttest asSelect ST_Distance(st_collect(b.the_geom), c.cent

[postgis-users] Measure distance to nearest border

2010-10-13 Thread Andreas Forø Tollefsen
Hi all, I have two datasets. On is a quadrate grid, and the other is the boundaries of all countries. What i want to do is to measure the distance from each centroid of the grid cells to the nearest border, but not all borders. Only the international. First i convert my country polygon dataset in