Main edit:'ValueError: No Shapely geometry can be created from null value' van be called if 'all_shapes' contains invalid geometry. Feeding the input including such invalid geometry(ies) to casdaded_union results in this ValueError. To fix, # Geometry validity check and correction is added.
Other minor modifications:
(1) The exclusion of the above-threshold cells is done by boolean mask instead of 'if value == 1.0:' argument in the original.
(2) 'all_shapes' list is now converted to a GeoSeries 'gs' so that it can be directly checked its geometric validity and fed to unary_union function instead of cascaded_union, which is now recommended by Sharply support.
(3) Coding notes are added for those who will work on this code in the future.
Main edit: 'ValueError: No Shapely geometry can be created from null value' van be called if 'all_shapes' contains invalid geometry. Feeding the input including such invalid geometry(ies) to casdaded_union results in this ValueError. To fix, # Geometry validity check and correction is added.
Other minor modifications: (1) The exclusion of the above-threshold cells is done by boolean mask instead of 'if value == 1.0:' argument in the original.
(2) 'all_shapes' list is now converted to a GeoSeries 'gs' so that it can be directly checked its geometric validity and fed to unary_union function instead of cascaded_union, which is now recommended by Sharply support.
(3) Coding notes are added for those who will work on this code in the future.