J'ai maintenant une fonction : densifygeometry(geom: BaseGeometry, espacement: float) ->…
- User
J'ai maintenant une fonction : densify_geometry(geom: BaseGeometry, espacement: float) -> BaseGeometry
Et ce code qui l'appelle : gdf_densifie = gdf.copy() gdf_densifie = gdf_densifie.geometry.apply( lambda geom: densify_geometry(geom, espacement) # type: ignore[return-value, arg-type] # noqa: E501 )
mypy trouve une erreur : error: Incompatible types in assignment (expression has type "Series[Any]", variable has type "GeoDataFrame") [assignment]
Assistant
The error occurs because you're trying to assign the result of
apply()(a pandas Series containing modified geometries) directly to thegdf_densifievariable (a GeoDataFrame). This causes a type mismatch:Series[Any]vs.GeoDataFrame.Fix:
You need to modify the geometry column in-place instead of overwriting the entire GeoDataFrame. Change this line:
Other models, same or similar prompt
Responses were produced in different, uncontrolled contexts (system prompts, settings, prior turns). This is not a benchmark.