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

Multipolygons cause "UnboundLocalError: local variable 'x' referenced before assignment" in rs cover #217

Open
iboates opened this issue Mar 27, 2021 · 1 comment

Comments

@iboates
Copy link

iboates commented Mar 27, 2021

I am just leaving this here as a note to anyone getting this error when using rs cover. If there are features in the cover GeoJSON that are of MultiPolygon type, they will throw the error in the title due to a limitation in supermercado, a dependency of robosat. Specfically, this function in "burntiles.py":

def _feature_extrema(geometry):
    if geometry["type"] == "Polygon":
        x, y = zip(*[c for part in geometry["coordinates"] for c in part])
    elif geometry["type"] == "LineString":
        x, y = zip(*[c for c in geometry["coordinates"]])
    elif geometry["type"] == "Point":
        x, y = geometry["coordinates"]
        return x, y, x, y

    return min(x), min(y), max(x), max(y)

You can get around it by making sure that your training polygons are forced to be Polygon and not MultiPolygon type before writing them to your cover CSV.

@daniel-j-h
Copy link
Collaborator

daniel-j-h commented Mar 27, 2021 via email

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