Skip to content

Add tree canopy reprojection helper#14

Open
erin-glen wants to merge 2 commits intopreprocessing/disturbancesfrom
codex/find-input-path-and-file-pattern-for-tree-canopy
Open

Add tree canopy reprojection helper#14
erin-glen wants to merge 2 commits intopreprocessing/disturbancesfrom
codex/find-input-path-and-file-pattern-for-tree-canopy

Conversation

@erin-glen
Copy link
Owner

Motivation

  • Provide a small utility to reproject NLCD Tree Canopy Cover rasters to the NLCD reference grid for downstream processing.
  • Discover unprojected canopy rasters placed in the primary and fallback input directories and produce consistent outputs next to them.
  • Ensure outputs align to the NLCD reference raster grid and spatial reference to avoid misalignment with other NLCD products.

Description

  • Add reproject_tree_canopy.py, which scans cfg.NLCD_TCC_INPUT_DIR and cfg.NLCD_TCC_INPUT_DIR_FALLBACK for *.tif files that do not end with _projected.tif.
  • Set arcpy environment (snapRaster, cellSize, extent, outputCoordinateSystem) from the reference raster at cfg.NLCD_RASTER and use arcpy.management.ProjectRaster to reproject.
  • Write outputs named by appending _projected before the .tif extension and skip files where the output already exists.
  • Use NEAREST resampling and arcpy.env.overwriteOutput = True while checking out the Spatial extension.

Testing

  • No automated tests were run for this change (script-only addition).

Codex Task

Copy link

@chatgpt-codex-connector chatgpt-codex-connector bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment on lines 79 to 81
arcpy.env.outputCoordinateSystem,
resampling_type="NEAREST",
cell_size=arcpy.env.cellSize,

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Pass numeric cell size to ProjectRaster

Here cell_size is fed from arcpy.env.cellSize, but _set_env assigns that environment value to the reference raster path string. ProjectRaster expects a numeric cell size, so when the env value is a path this call can fail with an “invalid cell size” error and stop all reprojections. Consider passing a numeric size (e.g., Describe(ref).meanCellWidth) or omitting cell_size and letting the environment setting take effect.

Useful? React with 👍 / 👎.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant