bevingtona / planetR

(early development) R tools to search, activate and download satellite imagery from the Planet API.
Apache License 2.0
45 stars 14 forks source link

Result of planet_search a vector not a table, replace nrow with length and [i,] with [i] #24

Closed tylerbhampton closed 7 months ago

tylerbhampton commented 1 year ago

In the example in the readme, the output of the planet_search() function is named response. The example assumes that response has rows, when I am getting a vector as the output.

for(i in 1:nrow(response)) {
  planet_activate(i, item_name = item_name)
  print(paste("Activating", i, "of", nrow(response)))}

# PLANET_DOWNLOAD: Batch Download 

for(i in 1:nrow(response)) {
  planet_download(i)
  print(paste("Downloading", i, "of", nrow(response)))}

The example should be changed to the following:

for(i in 1:length(response)) {
  planet_activate(i, item_name = item_name)
  print(paste("Activating", i, "of", length(response)))}

# PLANET_DOWNLOAD: Batch Download 

for(i in 1:length(response)) {
  planet_download(i)
  print(paste("Downloading", i, "of", length(response)))}

In addition, within the functions planet_activate() and planet_download(), the index of response should be changed from 2-dimensional to 1-dimensional:

response[i]
Leoanish commented 9 months ago

Hey I was facing a issue with nrow(response) and then I changed it to 1:length(response) and I am geeting an error message with this, Error in response[i, ] : incorrect number of dimensions

here is my code for(i in 1:length(response)) { planet_activate(i, item_name = item_name) print(paste("Activating", i, "of", nrow(response))) }

Leoanish commented 9 months ago

Screenshot 2024-02-16 at 2 56 36 PM And here is the response data that I am getting after planet search...

Leoanish commented 9 months ago

I got what you meant by changing the dimention of [i,] to [i] and I changed it too in the function planet_activate but now it is throwing me an error with product not found