Error when using the code with polygon survey
Eslam-mohakim opened this issue · comments
when trying to use the same code df["geometry"] = df["area"].apply(create_geometry)
but for area for Polygon type, it fires this error:
"ValueError: setting an array element with a sequence. The requested array has an inhomogeneous shape after 1 dimensions. The detected shape was (25,) + inhomogeneous part."
this is the function:
def create_geometry(x): if x == x and isinstance(x, dict) and "rings" in x and isinstance(x["rings"], list) and len(x["rings"]) > 0: return Polygon(coordinates) else: return np.nan
Furthermore, you should then apply the create_geometry function instead of:
df["geometry"] = df["location"].apply(
lambda x: Polygon(x["rings"][0])
)
in
df["geometry"] = df["area"].apply(create_geometry)
)