yeesian / ArchGDAL.jl

A high level API for GDAL - Geospatial Data Abstraction Library
https://yeesian.github.io/ArchGDAL.jl/stable/
Other
142 stars 26 forks source link

How to access the points in a polygon? #301

Closed maxfreu closed 2 years ago

maxfreu commented 2 years ago

I just don't get it (and can't find the relevant passage in the docs), please help:

simplepolygon = ArchGDAL.createpolygon([(0.,0.), (0.,1.), (1.,1.)])
AG.getpoint(simplepolygon,1)  # CE Failure Code 6, incompatible geometry for operation
simplepolygon[1]  # no getindex
first(simplepolygon)  # no iterate

In the end I want to convert the polygons to their julia counterpart from Meshes.jl.

visr commented 2 years ago

It looks like you can use getgeom for this: https://github.com/yeesian/ArchGDAL.jl/blob/e401e0079d97dac9d4755a4bc9dce345a9c5bf81/src/geointerface.jl#L69-L72

In the end I want to convert the polygons to their julia counterpart from Meshes.jl.

A completely renewed https://github.com/JuliaGeo/GeoInterface.jl/ was just released, with a pending PR in #290. If Meshes would also be open to add this interface (it has 0 dependencies), conversion could be a simple convert.

maxfreu commented 2 years ago

Omg, just now I read that getgeom indexing starts at 0... And I wondered why I always get a NULL Geometry. Shouldn't it simply raise an out of bounds error? Anyway, thanks for the hint & I'm looking forward to the new implementation!

visr commented 2 years ago

That would probably be a good improvement, yes. I assume it would be a cheap check.

maxfreu commented 2 years ago

The initial issue has been solved, so I think this can be closed :)