-
Notifications
You must be signed in to change notification settings - Fork 20
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
CRS Warning for k_ring_smoothing when using k param #12
Comments
Hi @johnziebro thanks for the question and report! Coordinates are assumed to be in I am not yet sure how the warning you posted could happen and did not manage to reproduce it. Could you please share what version of It would help a lot if you could also provide a small reproducible example for me to test. |
Interesting... running k_ring_smoothing with weights with only 1 coefficient, or multiple coefficients of the same value produces the same error, but using multiple coefficients of differing values does not. I saw in the module that it defers to the less computationally expensive method of smoothing if possible, so this might help narrow it down to the clause that is less expensive. |
The following works without a warning, the only difference is that geometry is specified as not returned.
Since the test gdf contains geometry, this points to a conflict when new geometry overwrites the existing geometry and lines up with the module code cited in the warning: lambda x: gpd.GeoDataFrame(x, crs="epsg:4326") The issue occurs inside this module call:
Specifically from the last line of h3_to_geo_boundary() when the the gdf being smoothed already has geometry. A workaround for now would be to execute smoothing using k param without returning geometry, and copy the already existing geometry column in the source gdf into the smoothed gdf, OR just extract the smoothed columns and copy them to the original gdf. |
Thank you!
Thank you for the detailed analysis. The warning happens because the grouped GeoDataFrame stays a GeoDataFrame even after import geopandas as gpd
df = gpd.GeoDataFrame(
{'group': [1, 1, 2], 'val': [5, 10, 15]},
geometry=gpd.points_from_xy([15, 16, 17], [50, 51, 52], crs='epsg:4326')
)
# Groupby still retains CRS information
result = df.groupby('group').sum()
type(result) # geopandas.geodataframe.GeoDataFrame
result.crs # <Geographic 2D CRS: EPSG:4326>
# Divide afterwards does not
divided = result.divide(1)
type(divided) # geopandas.geodataframe.GeoDataFrame
divided.crs # None I will consider opening an issue in GeoPandas, as I am not completely sure this behaviour makes sense. A simple and backwards-compatible workaround for |
What CRS should the GeoDataFrame being worked on have? I couldn't locate this in the docs or provided example notebooks.
When working with a GeoDataFrame with CRS 4326, a warning involving CRS is produced if k_ring_smoothing is applied using k instead of weight coefficients. The warning does not appear if weight coefficients are used.
test_smooth = test.h3.k_ring_smoothing(k=2)
test.crs
type(test)
The text was updated successfully, but these errors were encountered: