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

Add bbox to feature data #100

Closed
sgillies opened this issue Mar 22, 2014 · 1 comment
Closed

Add bbox to feature data #100

sgillies opened this issue Mar 22, 2014 · 1 comment
Assignees

Comments

@sgillies
Copy link
Member

Either use OGR or just do this:

def explode(coords):
    """Explode a GeoJSON geometry's coordinates object and yield coordinate tuples.
    As long as the input is conforming, the type of the geometry doesn't matter."""
    for e in coords:
        if isinstance(e, (float, int, long)):
            yield coords
            break
        else:
            for f in explode(e):
                yield f

def bbox(f):
    x, y = zip(*list(explode(f['geometry']['coordinates'])))
    return min(x), min(y), max(x), max(y)
@sgillies sgillies self-assigned this Mar 22, 2014
@sgillies
Copy link
Member Author

On second thought, no. Instead, I'll add a fast bounds() function to fiona.

sgillies added a commit that referenced this issue Mar 23, 2014
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant