ITADN

Forward force keyword in rasterize

#1047Openfelixcremer 创建于 2025-11-23
F
felixcremercommented
I think we should forward the force keyword in rasterize when using it with filename. Otherwise we get the error from inside create about using force to overwrite the data but a user can't add this keyword into their code. ```julia julia> rastacean = rasterize(count, df[1:4,:], res=0.1, filename="Datasets/vessel_data_2012_NE_Atl_sub.tif", force=true) ERROR: ArgumentError: filename already exists at Datasets/vessel_data_2012_NE_Atl_sub.tif. use the keyword `force=true` to write anyway Stacktrace: [1] check_can_write @ ~/Documents/Privat/AIRCentre_Dashboard/CretaceanView/dev/Rasters/src/write.jl:215 [inlined] [2] #write#2 @ ~/Documents/Privat/AIRCentre_Dashboard/CretaceanView/dev/Rasters/ext/RastersArchGDALExt/gdal_source.jl:72 [inlined] [3] write @ ~/Documents/Privat/AIRCentre_Dashboard/CretaceanView/dev/Rasters/ext/RastersArchGDALExt/gdal_source.jl:60 [inlined] [4] write @ ~/Documents/Privat/AIRCentre_Dashboard/CretaceanView/dev/Rasters/src/write.jl:206 [inlined] [5] write @ ~/Documents/Privat/AIRCentre_Dashboard/CretaceanView/dev/Rasters/src/write.jl:206 [inlined] [6] create(filename::String, source::Rasters.GDALsource, ::Type{…}, dims::Tuple{…}; name::Symbol, missingval::Int64, fill::Int64, metadata::DimensionalData.Dimensions.Lookups.Metadata{…}, chunks::Rasters.NoKW, scale::Rasters.NoKW, offset::Rasters.NoKW, dropband::Bool, lazy::Bool, verbose::Bool, force::Bool, coerce::Rasters.NoKW, f::Rasters.var"#625#626"{…}, kw::@Kwargs{}) @ Rasters ~/Documents/Privat/AIRCentre_Dashboard/CretaceanView/dev/Rasters/src/create.jl:301 [7] create @ ~/Documents/Privat/AIRCentre_Dashboard/CretaceanView/dev/Rasters/src/create.jl:272 [inlined] [8] create(filename::String, T::Type{…}, dims::Tuple{…}; lazy::Bool, parent::Rasters.NoKW, suffix::String, source::Rasters.GDALsource, missingval::Int64, kw::@Kwargs{…}) @ Rasters ~/Documents/Privat/AIRCentre_Dashboard/CretaceanView/dev/Rasters/src/create.jl:182 [9] create(::Function, ::String, ::Vararg{…}; kw::@Kwargs{…}) @ Rasters ~/Documents/Privat/AIRCentre_Dashboard/CretaceanView/dev/Rasters/src/create.jl:129 [10] #alloc_rasterize#623 @ ~/Documents/Privat/AIRCentre_Dashboard/CretaceanView/dev/Rasters/src/methods/rasterize.jl:507 [inlined] [11] alloc_rasterize @ ~/Documents/Privat/AIRCentre_Dashboard/CretaceanView/dev/Rasters/src/methods/rasterize.jl:497 [inlined] [12] create_rasterize_dest @ ~/Documents/Privat/AIRCentre_Dashboard/CretaceanView/dev/Rasters/src/methods/rasterize.jl:491 [inlined] [13] create_rasterize_dest(f::Function, r::Rasters.RasterCreator{…}) @ Rasters ~/Documents/Privat/AIRCentre_Dashboard/CretaceanView/dev/Rasters/src/methods/rasterize.jl:471 [14] rasterize(data::DataFrame; to::Nothing, fill::Function, threaded::Bool, geometrycolumn::Nothing, kw::@Kwargs{…}) @ Rasters ~/Documents/Privat/AIRCentre_Dashboard/CretaceanView/dev/Rasters/src/methods/rasterize.jl:459 [15] rasterize @ ~/Documents/Privat/AIRCentre_Dashboard/CretaceanView/dev/Rasters/src/methods/rasterize.jl:450 [inlined] [16] #rasterize#614 @ ~/Documents/Privat/AIRCentre_Dashboard/CretaceanView/dev/Rasters/src/methods/rasterize.jl:441 [inlined] [17] top-level scope @ REPL[13]:1 Some type information was truncated. Use `show(err)` to see complete types. ```
1 条评论