How to change a Lambert Conic Conformal raster projection to latlon degree R

白昼怎懂夜的黑 提交于 2019-12-20 02:38:38

问题


I have a raster, obtained from a netcdf which is in (Lambert Conic Conformal projection):

    library(meteoForecast)
    wrf_temporary <- getRaster("temp", day = Sys.Date(), frames = 'complete', resolution = 36, service = "meteogalicia")
    wrf_temporary

extent      : -18, 4230, -18, 3726  (xmin, xmax, ymin, ymax)
coord. ref. : +proj=lcc +lat_1=43 +lat_2=43 +lat_0=34.82300186157227 +lon_0=-14.10000038146973 +x_0=536402.34 +y_0=-18558.61 +ellps=WGS84 +towgs84=0,0,0,0,0,0,0 +units=km +no_defs 

Now I want to transform that wrf_temporary raster to "+proj=longlat +datum=WGS84" (lat long degree). What to do? I want something like this:

    mfExtent('meteogalicia', resolution = 36)

class       : Extent 
xmin        : -49.18259 
xmax        : 18.789 
ymin        : 24.03791 
ymax        : 56.06608 

Already tried a lot of options but none of them give the right results...


回答1:


This should work:

> ll = projectRaster(wrf_temporary,crs="+init=epsg:4326")
> plot(ll[[1]])

and produces this:

which looks right at first glance but the Greenwich meridian (longitude=0) doesn't go through London.

The problem doesn't occur for resolution set to the other values, 4 or 12. When called with resolution=36, you get a raster with a larger extent than the others, but with an identical projection string. This can't be right. For example, the (0,0) coordinate on the following plots should be the same point on the earth because they claim to be the same projection, but they arent.

I think the resolution=12 ones are correct. Here's that raster transformed to lat-long with an EU vector coverage overlaid:

which lines up perfectly.

So I would say its a bug - either getRaster is guessing the projection and getting it wrong, or not applying a change in projection after cropping, or whatever service it uses is lying about the projection.

getRaster is guessing. The projection info is in the downloaded NetCDF file. In another format. For the resolution=36 file the projection info section is this:

int Lambert_Conformal ;
    Lambert_Conformal:standard_parallel = 43., 43. ;
    Lambert_Conformal:latitude_of_projection_origin = 24.2280006408691 ;
    Lambert_Conformal:false_easting = 2182.62935 ;
    Lambert_Conformal:false_northing = -269.65597 ;
    Lambert_Conformal:grid_mapping_name = "lambert_conformal_conic" ;
    Lambert_Conformal:longitude_of_central_meridian = -14.1000003814697 ;
    Lambert_Conformal:_CoordinateTransformType = "Projection" ;
    Lambert_Conformal:_CoordinateAxisTypes = "GeoX GeoY" ;

which is a bit different to the resolution=12 projection used by the R package. So make a compliant one:

p = "+proj=lcc +lat_1=43 +lat_2=43 +lat_0=24.2280006408691 +lon_0=-14.1000003814697 +x_0=2182629.35 +y_0=-269655.97 +ellps=WGS84 +towgs84=0,0,0,0,0,0,0 +units=km +no_defs"
 wrf <- getRaster('temp', day = testDay, resolution=36)
 projection(wrf) = p

Then my test with EU overlay....

Note this time I've reprojected the EU. Doing projectRaster to latlong works too:

> wrfLL = projectRaster(wrf, crs="+init=epsg:4326")
> plot(wrfLL[[1]])
> abline(v=0)

with the Greenwich meridian in its rightful place.



来源:https://stackoverflow.com/questions/36868506/how-to-change-a-lambert-conic-conformal-raster-projection-to-latlon-degree-r

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!