carderne / ccg-spider

https://ccgspider.site
MIT License
0 stars 1 forks source link

Distance function returning zeroes across the board #20

Open alycialeonard opened 2 weeks ago

alycialeonard commented 2 weeks ago

While using prep to generate a hexagon file with distances, I noticed that all distance fields are returning zero. This doesn't make sense e.g., given the placement of the ocean, shown in the image attached. I suspect there may be a bug with the distance operation. I just pulled before running so my codebase is up to date.

Config file:

aoi: data/Ukraine.gpkg
features:
- decimals: 3
  file: data/Ukraine_oceans.gpkg
  fix:
    factor: 0.001
  name: ocean_dist
  operation: distance
  type: vector
- decimals: 3
  file: data/Ukraine_waterbodies.gpkg
  fix:
    factor: 0.001
  name: waterbody_dist
  operation: distance
  type: vector
- decimals: 3
  file: data/Ukraine_waterways.gpkg
  fix:
    factor: 0.001
  name: waterway_dist
  operation: distance
  type: vector
- decimals: 3
  file: data/Ukraine_roads.gpkg
  fix:
    factor: 0.001
  name: road_dist
  operation: distance
  type: vector
hex_res: 4
raster_like: data/blank_proj.tif

Terminal output (success with future warnings):

(spider) C:\Users\hert5576\PycharmProjects\ccg-spider\prep>spi --config=configs/Ukraine_config.yml processed/Ukraine_hex.geojson
Creating a new hex geometry from scratch
Adding features...
Doing ocean_dist
C:\Users\hert5576\PycharmProjects\ccg-spider\prep\spider\features.py:41: FutureWarning: Downcasting object dtype arrays on .fillna, .ffill, .bfill is deprecated and will change in a future version. Call result.infer_objects(copy=False) instead. To opt-in to the future behavior, set `pd.set_option('future.no_silent_downcasting', True)`
  geom[col_name] = geom[col_name].fillna(0).round(f["decimals"])
Doing waterbody_dist
C:\Users\hert5576\PycharmProjects\ccg-spider\prep\spider\features.py:41: FutureWarning: Downcasting object dtype arrays on .fillna, .ffill, .bfill is deprecated and will change in a future version. Call result.infer_objects(copy=False) instead. To opt-in to the future behavior, set `pd.set_option('future.no_silent_downcasting', True)`
  geom[col_name] = geom[col_name].fillna(0).round(f["decimals"])
Doing waterway_dist
C:\Users\hert5576\PycharmProjects\ccg-spider\prep\spider\features.py:41: FutureWarning: Downcasting object dtype arrays on .fillna, .ffill, .bfill is deprecated and will change in a future version. Call result.infer_objects(copy=False) instead. To opt-in to the future behavior, set `pd.set_option('future.no_silent_downcasting', True)`
  geom[col_name] = geom[col_name].fillna(0).round(f["decimals"])
Doing road_dist
C:\Users\hert5576\PycharmProjects\ccg-spider\prep\spider\features.py:41: FutureWarning: Downcasting object dtype arrays on .fillna, .ffill, .bfill is deprecated and will change in a future version. Call result.infer_objects(copy=False) instead. To opt-in to the future behavior, set `pd.set_option('future.no_silent_downcasting', True)`
  geom[col_name] = geom[col_name].fillna(0).round(f["decimals"])
Saving to processed\Ukraine_hex.geojson

Oceans do not overlap with hex file in all locations: hex_oceans Yet, all entries of ocean_dist are zeroes.

alycialeonard commented 2 days ago

Note that this has been resolved - the issue is that tiff files do not overwrite when using the gdal commands. e.g., once there is a blank_proj.tif already in place in the folder, if you try to re-run the process explained in the ReadMe with different input data, blank_proj.tif does not get overwritten. This can be solved on the user end by having them delete the tif files after each run of the prep code. Alternatively, you could add that to the code that executes when you use the spi CLI.