logan-berner / LandsatTS

LandsatTS is an R package to facilitate retrieval, cleaning, cross-calibration, and phenological modeling of Landsat time-series data.
Other
26 stars 3 forks source link

Running into error while stepping through the examaple in the ReadMe #36

Closed milesalanmoore closed 2 years ago

milesalanmoore commented 2 years ago

Hello Dr. Logan Berner and Dr. Jakob Assman!

Thanks for this fantastic package. I am encountering an error I am having trouble debugging when I step through your lsat_export_ts() example in the readMe here on github.

I am running lsatTS 1.0.1.

# Generate test points
test_points_sf <- st_sfc(sf::st_point(c(-149.6026, 68.62574)),
                         sf::st_point(c(-149.6003, 68.62524)),
                         sf::st_point(c(-75.78057, 78.87038)),
                         sf::st_point(c(-75.77098, 78.87256)),
                         sf::st_point(c(-20.56182, 74.47670)),
                         sf::st_point(c(-20.55376, 74.47749)), crs = 4326) %>%
  st_sf() %>%
  mutate(site = c("toolik_1",
                  "toolik_2",
                  "ellesmere_1",
                  "ellesmere_1",
                  "zackenberg_1",
                  "zackenberg_2"),
         region = c("toolik", "toolik",
                    "ellesmere", "ellesmere",
                    "zackenberg", "zackenberg"))
# Export time-series using lsat_export_ts()
task_list <- lsat_export_ts(test_points_sf)

running the task_list line here at the bottom returns:

> task_list <- lsat_export_ts(test_points_sf)
Spherical geometry (s2) switched off
Exporting time-series for 6 pixels in 1 chunks.
Submitting task to EE for chunk_id: chunk_1.
Error in `[.data.frame`(x, i, j, drop = drop) : 
  undefined columns selected

I will post an update if I am able to solve this issue or reproduce it with other point geometries. Stepping away for now but I figured I would put this up here.

An update: Using my own geometries failed to reproduce this error. Only the readme example seems to be returning the above error.

Thank you both,

Miles Alan Moore INSTAAR

jakobjassmann commented 2 years ago

Dear Miles, Thank you very much for raising this issue! I am at a conference today and tomorrow, but will try look into it as soon as possible. Jakob

jakobjassmann commented 2 years ago

Hi Miles,

I was able to replicate the error using the code example you took from the readme on GitHub.

The example from the GitHub readme was first written for an earlier version of the lsat_export_ts() function and we must have missed it when changing the default value for the option specifying the identifier column (now "sample_id" instead of previously "site").

Your code example should run if you change the column name from "site" to "smaple_id" when constructing the sf object of example locations.

[...]
st_sf() %>%
  mutate(site = c("toolik_1",
                  "toolik_2",
[...]

should be:

[...]
st_sf() %>%
  mutate(sample_id = c("toolik_1",
                  "toolik_2",
[...]

I fixed the bug in the code example provided in the readme. It should now work as intended. See e91a2bf0bbcf76cf75448848adc8a5ba8d454c32.

Jakob