Conversation
Contributor
|
I think by concatenating the DFs retrieved for each ISO in |
Owner
Author
|
that's what I though, then I won't avoid the reordering..... |
Contributor
|
How about this: isos = level_gdf.GID_0.dropna().unique()
# workaround for the wrong naming convention in the geojson files
# https://gis.stackexchange.com/questions/467848/how-to-get-back-spaces-in-administrative-names-in-gadm-4-1
# it should disappear in the next version of GADM
# we are forced to retrieve all the names from the df (sourced from.gpkg) to replace the one from
# the geojson that are all in camelCase
df_list = [Names(admin=iso, content_level=content_level, complete=True) for iso in isos]
complete_df = pd.concat(df_list)
# GID columns to merge on; they (should) match exactly
shared_cols = [f"GID_{i}" for i in range(int(content_level) + 1)]
# Camel-case columns to drop
drop_cols = [f"NAME_{i}" for i in range(int(content_level) + 1)]
gdf = pd.merge(level_gdf.drop(drop_cols, axis=1), complete_df,
how='inner', on=shared_cols)
return gdfIn my hands, this works. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fix #73
Instead of loading only the identified ISO_3 I naively discover them from the geojson. I'm concerned with the ordering and need to verify that it's not introducing an artificial offset. It does not slow down the computation that much.