Announcement

Collapse
No announcement yet.
X
  • Filter
  • Time
  • Show
Clear All
new posts

  • Identifying area of overlap from geoinpoly


    Hello everyone

    I'm working with two maps of the UK, with polygons of similar sizes. Specifically, I'm looking at NUTS3 areas and travel-to-work areas. I would like to create a unique match between NUTS3 areas and TTWAs, i.e. identify the TTWA with the highest overlap for each NUTS3 area. So far, I've managed to identify the overlapping areas using Robert Picard's geoinpoly. However, this only tells me that two areas overlap, but not by how much. Is it possible to calculate the area of overlap, to identify that with the highest overlap?

    I think one way to approach this problem would be to use mergepoly to create all the overlapping polygons and calculate their area. Unfortunately I couldn't find a command that calculates the area of polygons, so any hints in this direction would also be appreciated.

    Many thanks

    Carolin

  • #2
    Is it possible to get the lat/long coordinates of the vertexes of each polygon? If so you may be able to calculate the area of each polygon yourself.

    Here a general method for finding the area of a polygon in Euclidean space is described: https://www.mathopenref.com/coordpolygonarea.html

    But of course the earth is curved. Here are some notes on converting from lat/long to miles, but you could also do KM: https://gis.stackexchange.com/questi...ength-in-miles

    Comment


    • #3
      Hi Daniel

      Thanks a lot for your suggestion. I think the vertexes are in the coordinates file that is created by shp2dta, though I should check that. It would probably stretch my programming skills, but I might try this if anything else fails!

      Comment


      • #4
        Here is a couple of examples calculating the area of polygon using the Shoelace formula:

        Code:
        clear
        set obs 1000
        gen x = (_n-1)/1000
        gen y = sqrt(1-x^2)
        gen t = _n
        tsset t
        gen sump1 = sum(x*cond(l.y != . , l.y, y[_N]))
        gen sump2 = sum(y*cond(l.x != . , l.x, x[_N]))
        dis "area = " .5*(abs(sump1[_N] - sump2[_N]))
        
        //"More complex example" from 
        // https://en.wikipedia.org/wiki/Shoelace_formula
        
        clear
        input x y
        3 4
        5 11
        12 8
        9 5
        5 6
        3 4
        end
        
        //Plot ploygon
        gen c = "("+string(x) + "," + string(y)+")"
        line y x , cmissing(n) || scatter y x, mlabel(c) mlabpos(12) ||, legend(off)
        
        gen t = _n
        tsset t
        gen sump1 = sum(x*cond(l.y != . , l.y, y[_N]))
        gen sump2 = sum(y*cond(l.x != . , l.x, x[_N]))
        dis "area = " .5*(abs(sump1[_N] - sump2[_N]))

        Comment

        Working...
        X