Skip to content

Able to write LineString and Polygon geometry, #89

@ErickChacon

Description

@ErickChacon

I started a PR in GeoTables (JuliaEarth/GeoTables.jl#15) to be able to write Meshes.jl geometries to .shp using Shapefile.jl. However, we have problems when trying to write non-multi geometries like (LineString and Polygon).

ERROR: KeyError: key GeoInterface.LineStringTrait not found
Stacktrace:
 [1] getindex
   @ ./dict.jl:498 [inlined]
 [2] write(path::String, o::Shapefile.Writer; force::Bool)
   @ Shapefile ~/.julia/packages/Shapefile/TRwfU/src/writer.jl:140
 [3] #write#36
   @ ~/.julia/packages/Shapefile/TRwfU/src/writer.jl:266 [inlined]
 [4] save(fname::String, geotable::GeoTables.GeoTable{GeoJSON.FeatureCollection{2, Float64}}; kwargs::Base.Pairs{Symbol, Bool, Tuple{Symbol}, NamedTuple{(:force,), Tuple{Bool}}})
   @ GeoTables ~/documents/repositories/GeoTables.jl/src/GeoTables.jl:64
 [5] top-level scope
   @ REPL[1965]:1



ERROR: KeyError: key GeoInterface.PolygonTrait not found
Stacktrace:
 [1] getindex
   @ ./dict.jl:498 [inlined]
 [2] write(path::String, o::Shapefile.Writer; force::Bool)
   @ Shapefile ~/.julia/packages/Shapefile/TRwfU/src/writer.jl:140
 [3] #write#36
   @ ~/.julia/packages/Shapefile/TRwfU/src/writer.jl:266 [inlined]
 [4] save(fname::String, geotable::GeoTables.GeoTable{GeoJSON.FeatureCollection{2, Float64}}; kwargs::Base.Pairs{Symbol, Bool, Tuple{Symbol}, NamedTuple{(:force,), Tuple{Bool}}})
   @ GeoTables ~/documents/repositories/GeoTables.jl/src/GeoTables.jl:64
 [5] top-level scope
   @ REPL[1960]:1

We can solve this by transforming the StringLine and Polygon to MultiStringLine and MultiPolygon; however this will required to do by every package that wants to use Shapefile.jl to write to disk. Can that issue be solved here, so other packages using GeoInterface.jl integration can also benefit from it?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions