RGISTools icon indicating copy to clipboard operation
RGISTools copied to clipboard

modPreview fails due to lack of CRS, even though it seems to be there

Open sdwfrost opened this issue 5 years ago • 1 comments

When I run this code:

library(RGISTools)
library(rgdal)

bbox_string <- '
{
"type": "FeatureCollection",
"name": "KingCounty",
"crs": { "type": "name", "properties": { "name": "urn:ogc:def:crs:OGC:1.3:CRS84" } },
"features": [
{ "type": "Feature", "properties": { "MINX": -122.54204074767026, "MINY": 47.084628061013817, "MAXX": -121.06594568541907, "MAXY": 47.780581394066793, "CNTX": -121.80399321654465, "CNTY": 47.432604727540308, "AREA": 1.0272932784767566, "PERIM": 4.344096790608333, "HEIGHT": 0.69595333305297657, "WIDTH": 1.4760950622511899 }, "geometry": { "type": "Polygon", "coordinates": [ [ [ -122.542040747670256, 47.084628061013817 ], [ -121.065945685419067, 47.084628061013817 ], [ -121.065945685419067, 47.780581394066793 ], [ -122.542040747670256, 47.780581394066793 ], [ -122.542040747670256, 47.084628061013817 ] ] ] } }
]
}
'

bbox <- readOGR(bbox_string)
sres <- modSearch(product = "MOD09GA",
                  dates = seq(as.Date("2016-01-01"),as.Date("2016-01-31"),by=1),
                  region = bbox)

modPreview(searchres = sres, dates = as.Date("2016-01-01"))

I get an error:

Warning message in CPL_crs_from_input(x):
“GDAL Error 1: PROJ: proj_create_from_database: crs not found”
Error in CPL_transform(x, crs, aoi, pipeline, reverse): crs not found: is it missing?
Traceback:

1. modPreview(searchres = sres, dates = as.Date("2016-01-01"))
2. .modPreviewRecursive(searchres = searchres, n = 1, lpos = lpos, 
 .     add.Layer = add.Layer, verbose = verbose, ...)
3. extent(st_transform(mod.tiles[mod.tiles$Name == paste0("h:", 
 .     ho, " v:", ve), ], crs = st_crs(54008)))
4. st_transform(mod.tiles[mod.tiles$Name == paste0("h:", ho, " v:", 
 .     ve), ], crs = st_crs(54008))
5. st_transform.sf(mod.tiles[mod.tiles$Name == paste0("h:", ho, 
 .     " v:", ve), ], crs = st_crs(54008))
6. st_transform(st_geometry(x), crs, ...)
7. st_transform.sfc(st_geometry(x), crs, ...)
8. structure(CPL_transform(x, crs, aoi, pipeline, reverse), single_type = NULL, 
 .     crs = crs)
9. CPL_transform(x, crs, aoi, pipeline, reverse)

Here is the ROI as a SpatialPolygonsDataFrame, with a fairly standard CRS proj4 string.

class       : SpatialPolygonsDataFrame 
features    : 1 
extent      : -122.542, -121.0659, 47.08463, 47.78058  (xmin, xmax, ymin, ymax)
crs         : +proj=longlat +datum=WGS84 +no_defs +ellps=WGS84 +towgs84=0,0,0 
variables   : 10
names       :             MINX,             MINY,              MAXX,             MAXY,              CNTX,             CNTY,             AREA,            PERIM,            HEIGHT,            WIDTH 
value       : -122.54204074767, 47.0846280610138, -121.065945685419, 47.7805813940668, -121.803993216545, 47.4326047275403, 1.02729327847676, 4.34409679060833, 0.695953333052977, 1.47609506225119

sdwfrost avatar May 22 '20 15:05 sdwfrost

Same problem when trying to run the examples :(

cavargar avatar May 21 '21 15:05 cavargar