I am new to geographic information systems and i need to calculate the area of a a polygon ( a circle to be precise) that falls inside the boundaries of a region, say a state or a country. For example, in the figure below, the black outline the state in consideration and the circle is the concerned polygon. The yellow area is the area that is required. I have the concerned shapefile for the state.
I am using python. Can someone guide me about how to approach this problem?
Answer
The quickest way that I am aware of, is to use the Shapely library (requires the GEOS Engine, you can find a one-click installer for shapely here if you're on windows)
The manual provides a dead-on example of what your question:
>>> from shapely.geometry import Point
>>> a = Point(1, 1).buffer(1.5)
>>> b = Point(2, 1).buffer(1.5)
>>> c = a.intersection(b)
>>> c.area
4.11619859013966
No comments:
Post a Comment