Open Yangnaan opened 3 days ago
Do you have indicate min and Max coordinares?
yes, the error only occured on some maps. when i print the coordinates in branch Multipolygon, it has only two points.
def get_geoms( osm_geom ): """ Converts the geometry or multigeometry to a list of simple geometries (LineString, Polygon) """ geoms = [] geom_type = osm_geom['type'] if geom_type == 'LineString': geoms.append( LineString( osm_geom['coordinates'])) elif geom_type == 'Polygon': geoms.append( Polygon( osm_geom['coordinates'])) elif geom_type == 'MultiLineString': for g in osm_geom['coordinates']: geoms.append( LineString( g)) elif geom_type == 'MultiPolygon': print("g", osm_geom['coordinates'][0][0]) print("\n") geoms.append( Polygon( osm_geom['coordinates'][0][0])) # we take just the 1st, the rest are holes #TODO: manage holes
# elif geom_type == 'GeometryCollection': # TODO
# return []
else: print("ERROR: unknow geometry type:", geom_type)
return geoms
Traceback (most recent call last): File "./scripts/extract_features.py", line 40, in
polygons = process_features( polygons['features'], conf['polygons']) # extracted_polygons
File "D:\share\OSM_Extract\scripts\funcs.py", line 93, in process_features
geoms = get_geoms( feature['geometry'])
File "D:\share\OSM_Extract\scripts\funcs.py", line 47, in get_geoms
geoms.append( Polygon( osm_geom['coordinates'][0][0])) # we take just the 1st, the rest are holes #TODO: manage holes
File "C:\Actions\ZEPHYR_SDK\1.02\Python38\lib\site-packages\shapely\geometry\polygon.py", line 230, in new
shell = LinearRing(shell)
File "C:\Actions\ZEPHYR_SDK\1.02\Python38\lib\site-packages\shapely\geometry\polygon.py", line 104, in new
geom = shapely.linearrings(coordinates)
File "C:\Actions\ZEPHYR_SDK\1.02\Python38\lib\site-packages\shapely\decorators.py", line 77, in wrapped
return func(*args, kwargs)
File "C:\Actions\ZEPHYR_SDK\1.02\Python38\lib\site-packages\shapely\creation.py", line 171, in linearrings
return lib.linearrings(coords, out=out, kwargs)
ValueError: A linearring requires at least 4 coordinates.