EuroCrops icon indicating copy to clipboard operation
EuroCrops copied to clipboard

Drop Z dimension

Open thomasstorm opened this issue 2 years ago • 1 comments

The LT and the SI dataset have a 'Z'-dimension, which seem to be 0 for all values, and causes an error when ingesting these datasets into the geoDB. Suggestion: drop the dimension. Implementation could look like this (with gdf being an instance of geopandas.GeoDataFrame):

import shapely
def remove_z(gdf):
  new_geom_values = []
  for value in gdf['geometry'].geometry.values:
    new_geom_values.append(shapely.ops.transform(lambda *args: args[:2], value))
  new_geom = geopandas.array.GeometryArray(numpy.asarray(new_geom_values, dtype=shapely.geometry.polygon.Polygon))
  new_gs = geopandas.geoseries.GeoSeries(new_geom)
  gdf['geometry'] = new_gs

thomasstorm avatar Jul 07 '22 22:07 thomasstorm

Thank you @thomasstorm for pointing that out and providing the solution as well :+1:

maja601 avatar Jul 12 '22 09:07 maja601

The extra z dimension in the geometry has been removed for LT and SI for the latest HCAT3. Let me know if it's still causing issues :). Thanks.

xchan011 avatar Apr 21 '23 14:04 xchan011