Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How to access the points in a polygon? #301

Closed
maxfreu opened this issue May 19, 2022 · 4 comments
Closed

How to access the points in a polygon? #301

maxfreu opened this issue May 19, 2022 · 4 comments

Comments

@maxfreu
Copy link
Contributor

maxfreu commented May 19, 2022

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
Copy link
Collaborator

visr commented May 19, 2022

It looks like you can use getgeom for this:

elseif gtype in multilinetypes || gtype in polygontypes
Vector{Vector{Float64}}[
GeoInterface.coordinates(getgeom(g, i - 1)) for i in 1:ngeom(g)
]

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
Copy link
Contributor Author

maxfreu commented May 19, 2022

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
Copy link
Collaborator

visr commented May 19, 2022

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

@maxfreu
Copy link
Contributor Author

maxfreu commented May 26, 2022

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

@maxfreu maxfreu closed this as completed May 26, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants