GeoDataFrames.jl icon indicating copy to clipboard operation
GeoDataFrames.jl copied to clipboard

Add more informative error when trying to write vector of geometry

Open alex-s-gardner opened this issue 1 year ago • 1 comments
trafficstars

load data

using GeoDataFrames
using Shapefile

path2shp = splitpath(pathof(Shapefile))
path2shp = joinpath(vcat(path2shp[1:end-2], ["test", "shapelib_testcases", "test.shp"]))

gdf = GeoDataFrames.read(path2shp)

write geopackage with attributes [works as expected]

GeoDataFrames.write("test.gpkg", gdf)

write geopackage with geometry only [I would have thought this would work but it doesn't]

GeoDataFrames.write("test.gpkg", gdf[:,:geometry])
ERROR: type IGeometry has no field geometry
Stacktrace:
 [1] getproperty
   @ ./Base.jl:37 [inlined]
 [2] getcolumn
   @ ~/.julia/packages/Tables/8p03y/src/Tables.jl:102 [inlined]
 [3] getcolumn
   @ ~/.julia/packages/Tables/8p03y/src/tofromdatavalues.jl:73 [inlined]
 [4] getproperty
   @ ~/.julia/packages/Tables/8p03y/src/Tables.jl:186 [inlined]
 [5] write(fn::String, table::Vector{…}; layer_name::String, crs::Nothing, driver::Nothing, options::Dict{…}, geom_columns::Tuple{…}, chunksize::Int64, kwargs::@Kwargs{})
   @ GeoDataFrames ~/.julia/packages/GeoDataFrames/eP9Sg/src/io.jl:136
 [6] write(fn::String, table::Vector{ArchGDAL.IGeometry{ArchGDAL.wkbPolygon}})
   @ GeoDataFrames ~/.julia/packages/GeoDataFrames/eP9Sg/src/io.jl:112
 [7] top-level scope
   @ ~/Documents/GitHub/Altim.jl/src/junk9.jl:12
Some type information was truncated. Use `show(err)` to see complete types.

alex-s-gardner avatar Oct 05 '24 19:10 alex-s-gardner