<div dir="ltr"><div dir="ltr">Cory and list;</div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Sun, Jan 31, 2021 at 9:48 AM Cory Albrecht <<a href="mailto:osgeo@cory.albrecht.name">osgeo@cory.albrecht.name</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div dir="ltr"><div style="font-family:monospace"><span style="color:rgb(80,0,80);font-family:Arial,Helvetica,sans-serif"><div style="font-family:monospace">> <span style="font-family:Arial,Helvetica,sans-serif">Not completely following you here but the normal thing is to do a "join" between two tables on a common attribute.</span></div><div style="font-family:monospace"><span style="font-family:Arial,Helvetica,sans-serif"><br></span></div></span><div><span style="font-family:Arial,Helvetica,sans-serif">No, I don't want to do a join. In any case, a join still requires that there be that common value in the one table to point to the other table to do the join with in the first place.</span></div><span style="color:rgb(80,0,80);font-family:Arial,Helvetica,sans-serif"><div style="font-family:monospace"><span style="font-family:Arial,Helvetica,sans-serif"><br></span></div><div style="font-family:monospace"><span style="font-family:Arial,Helvetica,sans-serif">> </span><span style="font-family:Arial,Helvetica,sans-serif">It would help if you would post some examples with real "numbers".</span></div><div style="font-family:monospace"><span style="font-family:Arial,Helvetica,sans-serif"><br></span></div></span><div><span style="font-family:Arial,Helvetica,sans-serif">Borders separate two places. I want my border features to have foreign keys to the places they separate.</span></div></div></div></blockquote><div><br></div><div>"borders separate two places" - well, depending on their specific geometry.  The eastern border of France separates that country from Belgium, Luxembourg, Germany, Switzerland and Italy.</div><div><br></div><div>Of course, you might have France's eastern border split up into the segments that separate it from its neighbours.  But then again, you might not.</div><div> <br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div dir="ltr"><div style="font-family:monospace"><div><span style="font-family:Arial,Helvetica,sans-serif"><br></span></div><div><span style="font-family:Arial,Helvetica,sans-serif">layer countries:</span><br></div><div style="font-family:Arial,Helvetica,sans-serif">feature_a: feature_uuid = '24910f94-5721-4b97-b7f7-1b209b34687b', name = 'Lower Canada'</div><div style="font-family:Arial,Helvetica,sans-serif">feature_b: feature_uuid = 'd60ac5b7-d1e0-421d-b77e-c215882f5857', name = 'United States of America'</div><div style="font-family:Arial,Helvetica,sans-serif"><br></div><div style="font-family:Arial,Helvetica,sans-serif">layer borders:</div><div style="font-family:Arial,Helvetica,sans-serif">feature_1: north_east_name = NULL, north_east_feature = NULL, south_west_name = NULL, south_west_feature = NULL</div><div style="font-family:Arial,Helvetica,sans-serif"><br></div><div style="font-family:Arial,Helvetica,sans-serif">Select those three features and take the values from countries.feature_a and place them into the borders.feature_1.north_east_{name|feature} attributes. Then do the same with feature_b's values in the south_west_* attributes.</div></div></div></blockquote><div><br></div><div>Perhaps I'm missing something here but separating the geographical relationship between two countries as either north & east or south & west seems too... approximate.</div><div><br></div><div>For example if you look at the border between Washington and British Columbia, you will see that the great majority of BC is north and/or east of Washington; but a small chunk to the west is south and west of the north west part of Washington.</div><div><br></div><div>Another example, France and Switzerland.  Another, US and México (think the Texas panhandle).</div><div><br></div><div>Aaaaaaaanyway. </div><div><br></div><div>Assuming your countries layer is formed of polygons and the polygons are snapped together along their borders (not always a great assumption), you can generate a list of polygon pairs that touch each other.  I'm not exactly certain how to do this in QGIS, but it's dead simple in PostGIS with for example the "TOUCHES" function in an SQL query <a href="https://postgis.net/docs/ST_Touches.html">https://postgis.net/docs/ST_Touches.html</a></div><div><br></div><div>Then if you generate polygon centroids from your countries layer, you can join them to the "touches" table.  I know you said you didn't want to do joins, but maybe you could rethink that.</div><div><br></div><div>At this point you should have something more or less like this:</div><div><br></div><div>(Canada centroid lat-lon),(Canada attributes),(USA attributes),(USA centroid lat-lon)</div><div>(USA centroid lat-lon),(USA attributes),(México attributes),(México centroid lat-lon)</div><div><br></div><div>etc.</div><div><br></div><div>Having said all of this, note that it's possible that country centroids don't end up inside the country (I bet Malaysia's centroid is in the South China Sea).</div><div><br></div><div>Having that table, you can then come up with a calculate rule to assign your north-east and south-west attribute values based on the relation of the centroids.  Since you will have "bi directional pairs" in this table, ie</div><div><br></div><div>(Canada centroid lat-lon),(Canada attributes),(USA attributes),(USA centroid lat-lon)<br></div><div>(USA centroid lat-lon),(USA attributes),(Canada attributes),(Canada centroid lat-lon)</div><div><br></div><div>At this point you can delete all the pairs where the first country's centroid isn't north or east of the second country's centroid.</div><div><br></div><div>Then you can add the attributes north_east_name,north_east_feature,south_west_name,south_west_feature to the remaining pairs.</div><div><br></div><div>Then you can set:</div><div><br></div><div>north_east_name = first country name</div><div>north_east_feature = first country feature</div><div>south_west_name = second country name</div><div>south_west_feature = second country feature<br></div><div><br></div><div>At this point, you'll have your table EXCEPT it won't be spatial.  I couldn't tell if this is important or not.</div><div><br></div><div>Does this help?</div><div><br></div><div>If you need the border layer to be spatial, then you have some geometry work to do.  You'll have to make sure that the lines are segmented into pieces that only separate two countries.  If you have borders that are coastlines or out in the water, you're going to have to figure out what to do with them (since they don't - probably - touch two countries).</div><div><br></div><div>You could try buffering the border lines you have, then unioning those buffers with the country polygons, then looking at the attributes in the union to find buffer parts with a country on each side.  Of course where borders are wind-y you could end up with some odd results and it's likely you'll have countries showing up as both north and south of each other.  It might be best at this point just to record that country A and country B are adjacent within this buffer and therefore along the original segment.</div><div><br></div><div>Or you could try using the "TOUCHES" feature between lines and polygons in your two layers.  I've never done that but it could be a worthwhile experiment.</div><div><br></div><div>The point in any of these is that the unique ID of the border segments you have (or have created) is connected up to the countries separated.  Once you have that, you could start up in the above directions with the part about generating centroids.</div><div><br></div><div>Does this help?</div><div><br></div><div>[stuff deleted] </div></div><br clear="all"><div><br></div>-- <br><div dir="ltr" class="gmail_signature"><div dir="ltr">Chris Hermansen · clhermansen "at" gmail "dot" com<br><br>C'est ma façon de parler.</div></div></div>