Skip to content

support update_bbox() also for of coordinates with elevation data #10

@udos

Description

@udos

it would be nice if update_bbox() would also work for features with coordinates that contain elevation data (as optional 3rd element).

currently an error is thrown.

the geojson specs do forsee an optional 3rd elevation element in the coordinate array (https://tools.ietf.org/html/rfc7946#section-3.1.1):

A position is an array of numbers. There MUST be two or more elements. The first two elements are longitude and latitude, or easting and northing, precisely in that order and using decimal numbers. Altitude or elevation MAY be included as an optional third element.

the error can be reproduced as following:

newfile = pygeoj.new()
newfile.add_feature(
    properties={"country": "Norway"},
    geometry={"type": "Polygon", "coordinates": [[(21, 3, 120), (33, 11, 400), (44, 22, 234)]]}
)
newfile.update_bbox()

and the error:

  File "/Users/udos/.virtualenvs/ts/lib/python3.6/site-packages/pygeoj.py", line 662, in update_bbox
    xmins, ymins, xmaxs, ymaxs = zip(*(feat.geometry.bbox for feat in self if feat.geometry.type != "Null"))
  File "/Users/udos/.virtualenvs/ts/lib/python3.6/site-packages/pygeoj.py", line 662, in <genexpr>
    xmins, ymins, xmaxs, ymaxs = zip(*(feat.geometry.bbox for feat in self if feat.geometry.type != "Null"))
  File "/Users/udos/.virtualenvs/ts/lib/python3.6/site-packages/pygeoj.py", line 232, in bbox
    for _x,_y in coordsgen:
ValueError: too many values to unpack (expected 2)

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