I'm trying to plot GOES-16 data with world boundaries. Data comes from GOES-16 files such as this.
Data comes with "GOES-R ABI fixed grid projection" reference system, which to my better knowledge is describe as this PROJ4 string: '+proj=geos +h=35786023.0 +a=6378137.0 +b=6356752.31414 +f=0.00335281068119356027 +lat_0=0.0 +lon_0=-89.5 +sweep=x +no_defs'
My first step is to create a raster layer:
library(raster)
rrqpe <- raster("OR_ABI-L2-RRQPEF-M6_G16_s20202340210217_e20202340219525_c20202340220028.nc", varname='RRQPE')
I get some warnings about not being able to create a valid CRS, perhaps due software version.
Warning messages: 1: In .getCRSfromGridMap4(atts) : cannot process these parts of the CRS: long_name=GOES-R ABI fixed grid projection perspective_point_height=35786023 semi_minor_axis=6356752.31414 sweep_angle_axis=x 2: In .getCRSfromGridMap4(atts) : cannot create a valid CRS grid_mapping_name; false_easting; false_northing; scale_factor_at_projection_origin; scale_factor_at_central_meridian; standard_parallel; standard_parallel1; standard_parallel2; longitude_of_central_meridian; longitude_of_projection_origin; latitude_of_projection_origin; > straight_vertical_longitude_from_pole; longitude_of_prime_meridian; semi_major_axis; inverse_flattening; earth_radius; +proj; +x_0; +y_0; +k_0; +k_0; +lat_1; +lat_1; +lat_2; +lon_0; +lon_0; +lat_0; +lon_0; +lon_0; +a; +rf; +a
> rrqpe
class : RasterLayer
dimensions : 5424, 5424, 29419776 (nrow, ncol, ncell)
resolution : 1, 1 (x, y)
extent : -0.5, 5423.5, -0.5, 5423.5 (xmin, xmax, ymin, ymax)
coord. ref. : NA
data source : OR_ABI-L2-RRQPEF-M6_G16_s20202340210217_e20202340219525_c20202340220028.nc
names : ABI.L2..Rainfall.Rate...Quantitative.Precipitation.Estimate
zvar : RRQPE
Then I set the CRS:
> rrqpe@crs <- sp::CRS('+proj=geos +h=35786023.0 +a=6378137.0 +b=6356752.31414 +f=0.00335281068119356027 +lat_0=0.0 +lon_0=-89.5 +sweep=x +no_defs')
> rrqpe
class : RasterLayer
dimensions : 5424, 5424, 29419776 (nrow, ncol, ncell)
resolution : 1, 1 (x, y)
extent : -0.5, 5423.5, -0.5, 5423.5 (xmin, xmax, ymin, ymax)
coord. ref. : +proj=geos +h=35786023.0 +a=6378137.0 +f=0.00335281068119356027 +lat_0=0.0 +lon_0=-89.5 +sweep=x +no_defs
data source : OR_ABI-L2-RRQPEF-M6_G16_s20202340210217_e20202340219525_c20202340220028.nc
names : ABI.L2..Rainfall.Rate...Quantitative.Precipitation.Estimate
zvar : RRQPE
Then I try to warp (reproject) the image to EPSG:4326
> rrqpe_wgs84 <- projectRaster(rrqpe, crs="+proj=longlat +datum=WGS84 +no_defs +ellps=WGS84")
But something is wrong. The extent is tiny. I was expecting something like half world of data.
> rrqpe_wgs84
class : RasterLayer
dimensions : 5436, 5436, 29550096 (nrow, ncol, ncell)
resolution : 8.98e-06, 9.04e-06 (x, y)
extent : -89.50005, -89.45123, -4.774882e-05, 0.04909369 (xmin, xmax, ymin, ymax)
coord. ref. : +proj=longlat +datum=WGS84 +no_defs +ellps=WGS84 +towgs84=0,0,0
data source : /tmp/RtmpfHzSHu/raster/r_tmp_2020-08-21_231812_20555_52886.grd
names : ABI.L2..Rainfall.Rate...Quantitative.Precipitation.Estimate
values : -49.68673, 49.87008 (min, max)
I want to plot the data (rrqpe_wgs84) on a world map like world["continent"]["geom"] from library spData. Can someone help me on this reprojection using R libraries? Although I'm not using here, I have rgdal installed. I'm trying to avoid using many file operations with gdalUtils on R 3.4.4.