evetion/GeoDataFrames.jl

read layer

visr opened this issue · 4 comments

visr commented

Right now GeoDataFrames.read by default returns the first layer. Since many datasets have only one layer, that is very convenient. But perhaps we should not automatically do this if there are more than 1 layers? Otherwise it is very easy for users to miss the fact that they are only seeing part of the data.

function read(fn::AbstractString, layer::Union{Integer,AbstractString}=0)
ds = AG.read(fn)
layer = AG.getlayer(ds, layer)

What could be useful is an ogrinfo like statement to inspect such a thing?

visr commented

Something like that could be useful, but for read I was thinking to perhaps:

  • find the number of layers
  • if >1, and no layer is given, throw an error which tells you to select on of the following layer, and printing the layers in the error message.

That seems quite harsh, why would the default option suddenly throw errors? I'd propose

  • A warning describing all layers in such a case
  • Improve the current gdalerror on an invalid layer option (either wrong index or name) describing possible options
visr commented

Because default means that the user didn't make a choice, which is only really fine if there is no choice, if the dataset has a single layer.

If there is a choice to be made (multiple layers), it seems quite arbitrary to pick the first one for them. We could give a warning, but that will be annoying to the user that actually does want the first layer and does read("file.shp", 0). Hence I'd say give them a helpful error that forces them to choose.