Spaces:
Sleeping
Sleeping
| import json | |
| def reduce_coordinate_precision(geojson_data, precision=5): | |
| """Reduces the decimal precision of coordinates in GeoJSON data.""" | |
| features = geojson_data.get('features', []) | |
| for feature in features: | |
| if feature['geometry']['type'] == 'Polygon': | |
| coords = feature['geometry']['coordinates'] | |
| rounded_coords = [[[round(coord, precision) for coord in point] for point in ring] for ring in coords] | |
| feature['geometry']['coordinates'] = rounded_coords | |
| return geojson_data |