<div>Hi all,</div><div><br></div><div>I have two datasets. On is a quadrate grid, and the other is the boundaries of all countries.</div><div>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.</div>
<div><br></div><div>First i convert my country polygon dataset into line features:</div><div><div>select gwcode, gwsyear, gweyear, ST_Boundary(the_geom) AS line Into cshapes_line from cshapes;</div><div><br></div><div>Next i calculate the distance from the centroid of each cell to the nearest border where the gwcode (country code) of the cell is the same as the gwcode in the line feature.</div>
<div>drop table if exists borddisttest;</div><div>select pgfinal2008.cell, pgfinal2008.gwcode, ST_ShortestLine(pgfinal2008.centroid, st_boundary(cshapes.the_geom)) </div><div>AS shortestline, ST_Distance(geography(pgfinal2008.centroid), st_boundary(cshapes.the_geom))/1000 AS borddist </div>
<div>into borddisttest </div><div>from cshapes, pgfinal2008 </div><div>where cshapes.gwcode = pgfinal2008.gwcode;</div></div><div><br></div><div>The problem here is that when using ST_Boundary, it converts all boundaries into lines, while i only want to get the boundaries where two polygons with different gwcodes meet.</div>
<div>The lines where two countries meet are overlapping, meaning these borders have two gwcodes but in different line entries.</div><div><br></div><div>Is there a way to calculate the overlaps within one dataset? If i could do this, then i could put a clause so the measurement only measures to lines with 2 or more gwcodes.</div>
<div><br></div><div>Thanks.</div>