Hi Daniel
13 minutes for two counties sounds like a long time. I must admit that it's not a fast process but I was able to perform a similar operation for the 99 municipalities in Denmark. This took around 23 minutes and resulted in 372 borders.
The red lines are the internal borders between the municipalities, and where there is only a blue line visible, that's where the municipality border water and a neighboring country.
I'm using MapInfo Pro v2019 and can take advantage of the new option to create a derived spatial object in my query. This means that I can use the polygons as they are and create the borders as a polyline.
I create a small buffer of 5 cm around the boundary and only keep the part of the neighboring boundary that is within this slightly bigger boundary.
One issue with the query above is that I'll create two border lines for all borders, one from each side of the borderline. I tried to change the last condition from
t1.SomeIDColumn <> t2. SomeIDColumn
to
t1.SomeIDColumn < t2. SomeIDColumn
. This should limit the query to only return the borderlines from one of the two sides, and it also speeds up the processing as there are fewer joins to consider.
The query returned 186 records in 19 minutes.
Here's the final query I used:
Select t1.KOMKODE + "-" + t2.KomKode "BorderName"
, Overlap(CartesianBuffer(t1.obj, 12, 5, "cm"), ConvertToPline(t2.obj)) object
From Kommune_99_poster As "t1", Kommune2 As "t2"
Where t1.KOMKODE < t2.KomKode
And t1.Obj Intersects t2.obj
Into Selection
I don't want to estimate how long it will take to do this for all counties in the US...
One way that might boost the performance would be to create a MapBasic application to run through each polygon at a time and delete this to avoid it being used again.
------------------------------
Peter Horsbøll Møller
Principal Presales Consultant | Distinguished Engineer
Precisely | Trust in Data
------------------------------
Original Message:
Sent: 01-04-2021 14:29
From: Daniel Ems
Subject: Select shared borders of polygons
How can I select the portion of a polygon that shares a border with another polygon? Specifically, how can I select the shared border of two counties?
I'd like to have a different style for the portions that share a border with another county. I don't want to include portions of the county that border water such as a river within the county or a lake on the edge of the county.
I have a Counties table with one record for each county and each county is a single object. My first idea was to convert the region/polyline object to lines, then use this SQL to select lines that intersect another line in a different county.
Select *From Counties, Counties2WHERE Counties.A2_Code <> Counties2.A2_Codeand Counties.Obj Intersects Counties2.ObjInto Selection
I tried it on a sample of two counties, and it took 13 minutes. The whole US or even a single state would take forever.
Is there another/better way to do this?
------------------------------
Daniel Ems
KINDRED HEALTHCARE LLC
Louisville KY
------------------------------