Spaces:
Runtime error
Runtime error
padding fix
Browse files186 unmodified lines1871881891901911921931941951961971981992002012022031901911921931941951961971981992002012022032042062052082062072082094 unmodified lines214215216217218219220221222223186 unmodified lines raster_crs = _src.crs raster_bounds = _src.bounds
if cleaned.crs is None: cleaned = cleaned.set_crs(raster_crs, allow_override=True) elif cleaned.crs != raster_crs: cleaned = cleaned.to_crs(raster_crs)
if not cleaned.empty: cleaned = cleaned.clip(box(*raster_bounds))
if not cleaned.empty: if pyproj.CRS.from_user_input(raster_crs).is_geographic: tol = 2e-5 else: tol = 0.4 cleaned.set_geometry(cleaned.geometry.simplify(tol, preserve_topology=True), inplace=True) crowns_crs = cleaned.crs if crowns_crs is None: bx = cleaned.total_bounds looks_geographic = ( -180 - 1e-6 <= bx[0] <= 180 + 1e-6 and -180 - 1e-6 <= bx[2] <= 180 + 1e-6 and -90 - 1e-6 <= bx[1] <= 90 + 1e-6 and -90 - 1e-6 <= bx[3] <= 90 + 1e-6 ) crowns_crs = "EPSG:4326" if looks_geographic else raster_crs cleaned = cleaned.set_crs(crowns_crs, allow_override=True)
if cleaned.crs != raster_crs: cleaned = cleaned.to_crs(raster_crs)
clip_geom = box(*orig_bounds) if not cleaned.empty: cleaned = cleaned.clip(clip_geom) cleaned = cleaned.clip(box(*orig_bounds))
# save vector gpkg_path = os.path.join(workdir, "crowns_out.gpkg")4 unmodified lines with rasterio.open(infile) as src: fig, ax = plt.subplots(figsize=(10, 10)) show(src, ax=ax) ax.set_aspect('equal') rb = src.bounds ax.set_xlim(rb.left, rb.right) ax.set_ylim(rb.bottom, rb.top) if not cleaned.empty: cleaned.plot(ax=ax, facecolor="none", edgecolor="cyan", linewidth=1.2) ax.set_xticks([]); ax.set_yticks([]); ax.set_frame_on(False)app.py+18-16