Skip to content

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

@jtdimasaka

Description

@jtdimasaka

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions