Multipolygons cause "UnboundLocalError: local variable 'x' referenced before assignment" in rs cover
Nobody has claimed this yet.
Assessment
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Newbie friendliness
- 35/100
- Issue type
- Bug
- Clarity
- Needs clarification
- Activity status
- Stale
- Tech stack
- python
- Domain
- machine-learning
Research direction
Start with burntiles.py and the _feature_extrema function used by rs cover, then determine whether the limitation belongs in robosat or its supermercado dependency. Reproduce the UnboundLocalError with a MultiPolygon cover GeoJSON and verify that rs cover handles it without the error while preserving the existing Polygon behavior.
Written by the indexing model from the issue text.
Description
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.
- Dominant language
- Python
- Stars
- 2.1k
- Forks
- 385
- PR merge metrics
- No merged PRs in 30d
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from mapbox/robosat
-
Difficulty 1/5 Under an hour Newbie friendliness 35/100
-
Difficulty 5/5 Over a week Newbie friendliness 20/100
-
Difficulty 4/5 3-5 days Newbie friendliness 32/100
-
Difficulty 3/5 1-2 days Newbie friendliness 30/100
-
Bringin own data Open
Difficulty 5/5 Over a week Newbie friendliness 20/100
Similar issues
-
Difficulty 2/5 1-3 hours Newbie friendliness 88/100
-
Difficulty 2/5 1-3 hours Newbie friendliness 82/100
-
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
-
enhancement
Difficulty 2/5 1-3 hours Newbie friendliness 72/100
-
Difficulty 2/5 1-3 hours Newbie friendliness 74/100