Skip to content

bm_extract: Incorrect Day of Year (DOY) calculation for VNP46A3 URLs (Leap Year Logic Inverted?) #26

@aidanhorn

Description

@aidanhorn

I am encountering 404 errors when downloading VNP46A3 (monthly) data because bm_extract generates incorrect URLs for the .csv files. It appears the "Day of Year" (DOY) calculation is off by one day: it seems to treat leap years as non-leap years, and non-leap years as leap years.

Package Version

0.2.5

Examples

  1. Leap Year (2024)

    • Date: 2024-09-01
    • Actual DOY: 245
    • Generated URL: .../2024/244.csv (DOY 244)
    • Result: 404 Error (File not found).
    • Observation: It behaves as if February had 28 days.
  2. Non-Leap Year (2025)

    • Date: 2025-04-01
    • Actual DOY: 91
    • Generated URL: .../2025/092.csv (DOY 92)
    • Result: 404 Error.
    • Observation: It behaves as if February had 29 days.

Minimal Reproducible Example

library(blackmarbler)
library(sf)

# Dummy ROI
roi <- st_as_sf(data.frame(id=1, lat=0, lon=0), coords = c("lon", "lat"), crs=4326)

# Case 1: Leap Year (2024) - calculated DOY is one too low (244 vs 245)
try(bm_extract(roi_sf=roi, product_id="VNP46A3", date="2024-09-01", bearer="MY_TOKEN"))

# Case 2: Non-Leap Year (2025) - calculated DOY is one too high (092 vs 091)
 try(bm_extract(roi_sf=roi, product_id="VNP46A3", date="2025-04-01", bearer="MY_TOKEN"))

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions