3

I have a map with many counties, and I estimated the length of the common borders using one of the answers from this question posted a year ago.

The properties of my layer look like this:

enter image description here

I did the following:

Layer > Add Layer > Add/Edit Virtual Layer

And then entered this query:

select a.id as poly1_id,
       b.id as poly2_id,
       st_intersection(a.geometry, b.geometry) as geometry,
       st_length(st_intersection(a.geometry, b.geometry)) as border_length
from units_1 a
join units_1 b on st_intersects(a.geometry, b.geometry)
              and a.id < b.id 

enter image description here

I got the following results, which don't seem right:

enter image description here

I believe I am getting the length in the map's units which are probably degrees but I am not sure. Does anyone know what is going on and how to get the results in kilometers?

1
  • 4
    Looks like degrees, since you're using WGS84 (first image) Commented Jul 16, 2021 at 1:41

1 Answer 1

3

Your coordinates are in degrees (4326) so the length is also in degrees - which is meaningless.

You can use the version of st_length that accept a boolean parameter to use (or not) the elipsoid when computing distances. It will return a distance in meters

st_length(st_intersection(a.geometry, b.geometry),true) as border_length

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.