如何找到具有两部分的 geojson 多边形的面积,例如在海岸外有一个岛屿的县?
How can I find the area of a geojson polygon that has two parts, such as a county with an island off the coast?
我正在尝试查找人口普查区和县的面积,但有少数不连续。我正在使用 python area
库。这是我的代码,适用于所有连续的形状。
obj = {'type':'Polygon','coordinates': feature['geometry']['coordinates']}
current_area = area(obj) / square_meter_to_square_mile
坐标示例如下:
{'type': 'Polygon', 'coordinates': [[[-79.891153, 40.497034, 0], [-79.890443, 40.494777, 0], [-79.889832, 40.491527, 0], [-79.884604, 40.490922, 0], [-79.884484, 40.488949, 0], [-79.884592, 40.487329, 0], [-79.888175, 40.48644, 0], [-79.8882, 40.483948, 0], [-79.883772, 40.483406, 0], [-79.879559, 40.483247, 0], [-79.876632, 40.483316, 0], [-79.874238, 40.48355, 0], [-79.865498, 40.485069, 0], [-79.865786, 40.491525, 0], [-79.865968, 40.495515, 0], [-79.862811, 40.49765, 0], [-79.859216, 40.497693, 0], [-79.859175, 40.496435, 0], [-79.856864, 40.498169, 0], [-79.851113, 40.493601, 0], [-79.850339, 40.49594, 0], [-79.84968, 40.497589, 0], [-79.848853, 40.503658, 0], [-79.849326, 40.506821, 0], [-79.849451, 40.507425, 0], [-79.850546, 40.514188, 0], [-79.850665, 40.51721, 0], [-79.850494, 40.520508, 0], [-79.851755, 40.520607, 0], [-79.85488, 40.520812, 0], [-79.85527,
40.528789, 0], [-79.867579, 40.528512, 0], [-79.867259, 40.522247, 0], [-79.871734, 40.526388, 0], [-79.872237, 40.527164, 0], [-79.871867, 40.517058, 0], [-79.871676, 40.509746, 0], [-79.87278, 40.50971, 0], [-79.872672, 40.503888, 0], [-79.878623, 40.503694, 0], [-79.879079, 40.499454, 0], [-79.883633, 40.499245, 0], [-79.887353, 40.498669, 0], [-79.891153, 40.497034, 0]]]}
这是它的样子:
错误不是我想的那样。那组坐标都是一个形状,不是问题。对于那些有两个形状的形状,我必须遍历子形状列表并分别处理每个区域。
我正在尝试查找人口普查区和县的面积,但有少数不连续。我正在使用 python area
库。这是我的代码,适用于所有连续的形状。
obj = {'type':'Polygon','coordinates': feature['geometry']['coordinates']}
current_area = area(obj) / square_meter_to_square_mile
坐标示例如下:
{'type': 'Polygon', 'coordinates': [[[-79.891153, 40.497034, 0], [-79.890443, 40.494777, 0], [-79.889832, 40.491527, 0], [-79.884604, 40.490922, 0], [-79.884484, 40.488949, 0], [-79.884592, 40.487329, 0], [-79.888175, 40.48644, 0], [-79.8882, 40.483948, 0], [-79.883772, 40.483406, 0], [-79.879559, 40.483247, 0], [-79.876632, 40.483316, 0], [-79.874238, 40.48355, 0], [-79.865498, 40.485069, 0], [-79.865786, 40.491525, 0], [-79.865968, 40.495515, 0], [-79.862811, 40.49765, 0], [-79.859216, 40.497693, 0], [-79.859175, 40.496435, 0], [-79.856864, 40.498169, 0], [-79.851113, 40.493601, 0], [-79.850339, 40.49594, 0], [-79.84968, 40.497589, 0], [-79.848853, 40.503658, 0], [-79.849326, 40.506821, 0], [-79.849451, 40.507425, 0], [-79.850546, 40.514188, 0], [-79.850665, 40.51721, 0], [-79.850494, 40.520508, 0], [-79.851755, 40.520607, 0], [-79.85488, 40.520812, 0], [-79.85527,
40.528789, 0], [-79.867579, 40.528512, 0], [-79.867259, 40.522247, 0], [-79.871734, 40.526388, 0], [-79.872237, 40.527164, 0], [-79.871867, 40.517058, 0], [-79.871676, 40.509746, 0], [-79.87278, 40.50971, 0], [-79.872672, 40.503888, 0], [-79.878623, 40.503694, 0], [-79.879079, 40.499454, 0], [-79.883633, 40.499245, 0], [-79.887353, 40.498669, 0], [-79.891153, 40.497034, 0]]]}
这是它的样子:
错误不是我想的那样。那组坐标都是一个形状,不是问题。对于那些有两个形状的形状,我必须遍历子形状列表并分别处理每个区域。