1

I am trying to calculate the fraction of one area inside another. I confess to not understanding geopandas vs shapely shapes too well. But an example should show my confusion. My python calculation says that the area of intersection (bounded by red) divided by the blue circle area is only about 12%, when it should be close to 30%. radius around centroid in blue, area of overlap with Mexico in red

Code:

 for k in (mexico,canada): # rows of a geopandas GeoDataFrame
  if int(k.intersects(circles["full"]))==1: #circle["full"] is the blue circle below
   print("INTER") 
    try:
      z = [MultiPolygon(k) for k in list(k.geometry)][0] this is how I could get the rows into shapely comparisons?
      print(z.intersection(circles["full"]).area/(50000*50000*np.pi**2)) # calculating what I hope is red bounded area/ blue bounded area. Denominator is a bit overstated due to projection, but shouldn't be too bad and calculations show not too bad
      print(circles["full"].area) # confirms denominator not too bad
      x,y = circles["full"].exterior.xy # what I think I needed to do to make math for area work
      pyplot.plot(x,y)
      x,y = Polygon(z.intersection(circles["full"])).exterior.xy # needed to convert to polygon to do the plot of the red area. Is this changing something? Couldn't do calc above with numerator and denominator with z turned to Polygon
Tom
  • 21
  • 2

1 Answers1

1

Answered. Solved. I squared pi and the radius instead of just the radius!

Tom
  • 21
  • 2