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

oregon 2022 source & update unary_multi #41

Merged
merged 6 commits into from
Sep 30, 2023
Merged

Conversation

dhodcz2
Copy link
Collaborator

@dhodcz2 dhodcz2 commented Sep 24, 2023

addressing issue #40

# def unary_multi(gdf):
# 	"""
# 	handles the errors with multipolygon
# 	"""
# 	if gdf.unary_union.type == 'MultiPolygon':
# 		gdf_uni = gpd.GeoDataFrame(geometry=gpd.GeoSeries([geom for geom in gdf.unary_union.geoms]))
# 	else:
# 		gdf_uni = gpd.GeoDataFrame(geometry=gpd.GeoSeries(gdf.unary_union))
# 	return gdf_uni


def unary_multi(gdf: gpd.GeoDataFrame) -> gpd.GeoDataFrame:
    # handles the errors with multipolygon
    loc = ~gdf.is_valid.values
    logger.warning(f'Number of invalid geometries: {loc.sum()} out of {len(gdf)}')
    gdf.geometry.loc[loc] = shapely.make_valid(gdf.geometry.loc[loc])
    result = (
        gdf
        # dissolve overlapping geometries
        .dissolve()
        # explode multipart geometries
        .explode()
    )
    return result

I ran it on the proximity which included 5k tiles, with no issues, however testing it on with all 75k tiles as in the issue would likely take several hours of runtime on my end

@Mary-h86 Mary-h86 merged commit fedd709 into main Sep 30, 2023
dhodcz2 pushed a commit that referenced this pull request Dec 21, 2023
oregon 2022 source & update unary_multi & buffer_union_erode
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

Successfully merging this pull request may close these issues.

2 participants