Skip to content

Shapefiles read with v0.4.0 can no longer use common GeoInterface methods #116

@niclasmattsson

Description

@niclasmattsson

I'm not sure if the diagnosis in my title is correct, feel free to edit it when you figure out what the problem is. Anyway, my code utterly broke when I upgraded to v0.4.0. The code reads and manipulates geodata in various formats, both geopackages and shapefiles. The parts that operate exclusively on geopackages work as before in v0.3.13, but everything that interacts with shapefiles now produce method errors as shown below. Basic methods like getgeom work fine, but optional methods like area, contains or intersects don't work anymore.

Here's an example using a shapefile of Austria from GADM level 0.

v0.4.0

julia> df = GDF.read("C:/Users/niclas/Downloads/gadm41_AUT_shp/gadm41_AUT_0.shp")
1×3 DataFrame
 Row │ geometry                GID_0    COUNTRY
     │ Polygon?                String?  String?
─────┼──────────────────────────────────────────
   1Polygon(249273 Points)  AUT      Austria

julia> GI.area(df.geometry[1])
ERROR: MethodError: no method matching area(::GeoInterface.MultiPolygonTrait, ::Shapefile.Polygon)
The function `area` exists, but no method is defined for this combination of argument types.

Closest candidates are:
  area(::Any)
   @ GeoInterface C:\Users\niclas\.julia\packages\GeoInterface\4tyIo\src\interface.jl:244
  area(::Union{GeoInterface.CircularStringTrait, GeoInterface.CompoundCurveTrait, GeoInterface.CurvePolygonTrait, GeoInterface.GeometryCollectionTrait, GeoInterface.LineStringTrait, GeoInterface.LinearRingTrait, GeoInterface.MultiLineStringTrait, GeoInterface.MultiPointTrait, GeoInterface.MultiPolygonTrait, GeoInterface.MultiSurfaceTrait, GeoInterface.PointTrait, GeoInterface.PolygonTrait, GeoInterface.PolyhedralSurfaceTrait, GeoInterface.TINTrait, GeoInterface.TriangleTrait}, ::ArchGDAL.AbstractGeometry)
   @ ArchGDAL C:\Users\niclas\.julia\packages\ArchGDAL\ujstt\src\geointerface.jl:310

Stacktrace:
 [1] area(geom::Shapefile.Polygon)
   @ GeoInterface C:\Users\niclas\.julia\packages\GeoInterface\4tyIo\src\interface.jl:244
 [2] top-level scope
   @ REPL[178]:1

v0.3.13

julia> df = GDF.read("C:/Users/niclas/Downloads/gadm41_AUT_shp/gadm41_AUT_0.shp")
1×3 DataFrame
 Row │ geometry                   GID_0   COUNTRY
     │ IGeometr                  String  String
─────┼────────────────────────────────────────────
   1 │ Geometry: wkbMultiPolygon  AUT     Austria

julia> GI.area(df.geometry[1])
10.038532695098086

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions