You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
## PLEASE DELETE AND WRITE YOUR OWN
library(MODIStsp)
library(osmdata)
# I expect the below code to give me tiles covering China but gives me a default tile which# I don't know which geographical region it ischina_bb<-osmdata::getbb("China")
MODIStsp(gui=FALSE,
selcat="Ecosystem Variables - Vegetation Indices",
selprod="Vegetation_Indexes_16Days_1Km (M*D13A2)",
bbox=china_bb,
sensor="Terra",
bandsel="EVI",
download_server="http",
user="XXXX" ,
password="XXXX",
start_date="2001.02.18",
end_date="2001.12.31",
out_projsel="User Defined",
output_proj="4326",
out_res_sel="Native",
out_res=926.6254,
resampling="near",
reprocess=FALSE,
delete_hdf=TRUE,
nodata_change=FALSE,
scale_val=TRUE,
out_format="GTiff",
compress="LZW",
out_folder="D:/modis",
out_folder_mod="D:/modis_hdf"
)
Expected and actual behavior
# If I read a single file, as follows, I get a tile which is not China.
library(raster)
temp <- raster('D:/modis/VI_16Days_1Km_v6/EVI/MOD13A2_EVI_2000_049.tif')
plot(temp)
# This issue is also being asked on SO here
#https://stackoverflow.com/questions/66326127/using-a-shapefile-with-modistsp-r-package
#https://stackoverflow.com/questions/66201309/visualising-modis-vegetation-layers-for-a-
specific-country-using-r-package-modi
Sorry for waiting.
The reason of this behaviour is that the default value of argument spatmeth is "tiles", so values specified with arguments start_x, end_x, start_y and end_y (and, if not explicitly specified, their defaults) are used.
From the function documentation:
bbox numeric(4) Output bounding box (xmin, ymin, xmax, ymax) in out_proj coordinate system. Ignored if spatmeth == "tiles", Default: NULL
spatmeth character ["tiles" | "bbox" | "file"], indicates how the processing extent is retrieves. if "tiles", use the specified tiles (start_x....). If "file", retrieve extent from spatial file specifies in spafile. If "bbox", use the specified bounding box, Default: "tiles"
To use the china_bb extent you have to:
add spatmeth = "tiles";
correct bbox = china_bb to bbox = as.vector(china_bb)
Moreover, there was a bug (fixed with c22cc96) affecting your case.
You should also reinstall the package from GitHub:
Issue description
Reproducible example
Expected and actual behavior
System information
Additional context
Scientific publication
The text was updated successfully, but these errors were encountered: