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

Three minor issues in geo.py (re: multipolygon error, deprecated multiplication, and iteritems) #8

Open
jtdimasaka opened this issue Apr 23, 2024 · 0 comments

Comments

@jtdimasaka
Copy link

I do not think I can freely pull request, so I'm just sending the issues here with my proposed fixes that made the codes working for me. Hope this helps!

1. An admin region that is in a form of "Multipolygon" is not recognized. Instead of Line 85-86 (geo.py):

            out_image, out_transform = rasterio.mask.mask(src, geom, crop=True)
            no_data = src.nodata

Use this:

            if type(geom) == shapely.geometry.multipolygon.MultiPolygon:
                out_image, out_transform = rasterio.mask.mask(src, geom.geoms, crop=True)
                no_data = src.nodata
            else:
                out_image, out_transform = rasterio.mask.mask(src, geom, crop=True)
                no_data = src.nodata

2. "Deprecated multiplication" error. Just flip the position. Instead of Line 98 (geo.py):
rc2xy = lambda r, c: (c, r) * T1
Use this:
rc2xy = lambda r, c: T1 * (c, r)

3. "iteritems" does not work. I replaced it with "items" but still gives me a minor warning error due to predefined geometry (but it still performs), which can be fixed with pre-identifying "geometry" in the future. Instead of Line 113 (geo.py):
for col, val in adm.iteritems():
Use this:
for col, val in adm.items():

Thank you,
Joshua

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

1 participant