[R-sig-Geo] Coverting CRS in R to OSGB 1936
Hello I have shapefile data (of the river Tweed catchment in N England and Scotland) which I have been able to plot precipitation and temperature data onto without too many problems. These data have the OSGB 1936/British National Grid CRS projection. But I now have a raster of land cover (from the Centre for Ecology and Hydrology) covering the catchment area which I want to incorporate into my processing. I have downloaded the raster into R and its properties are class : RasterLayer band : 1 (of 5 bands) dimensions : 4914, 8861, 43542954 (nrow, ncol, ncell) resolution : 25, 25 (x, y) extent : 261400, 482925, 576750, 699600 (xmin, xmax, ymin, ymax) crs: +proj=tmerc +lat_0=49 +lon_0=-2 +k=0.9996012717 +x_0=40 +y_0=-10 +ellps=airy +units=m +no_defs source : LCM.tif names : LCM values : 0, 255 (min, max) So it has a different CRS - my question is - how (in R) can I reset the raster CRS to be the same as my earlier data sets ie OSGB 1936 British National Grid? I haven't been able to find anything obvious on the net. Thanks Nick Wray [[alternative HTML version deleted]] ___ R-sig-Geo mailing list R-sig-Geo@r-project.org https://stat.ethz.ch/mailman/listinfo/r-sig-geo
[R-sig-Geo] getting data from an nc file
Hello I am trying to get rainfall data from the UK chess-met site https://catalogue.ceh.ac.uk/datastore/eidchub/2ab15bf0-ad08-415c-ba64-831168be7293/precip/ and here there are a large number of nc files eg "chess-met_precip_gb_1km_daily_20150101-20150131.nc" I’ve found various sources on the net for opening nc files, and getting the data but when I try instructions like nc_data<-nc_open("chess-met_precip_gb_1km_daily_20150101-20150131.nc") lon <- ncvar_get(nc_data, "lon") lon the code works but all I get is a series of element numbers and no data: [,1] [,2] [,3] [,4] [,5] [,6] [,7] [,8] [,9] [,10][,11][,12] [,13][,14][,15][,16][,17][,18][,19] [,20][,21][,22][,23][,24] And similarly for latitude But if I open the nc file as a raster I get a raster precipitation plot of Great Britain, which rather suggests that the lat and long values are in there somewhere Can anyone help with getting the actual data sets out of an nc file? Thanks Nick Wray [[alternative HTML version deleted]] ___ R-sig-Geo mailing list R-sig-Geo@r-project.org https://stat.ethz.ch/mailman/listinfo/r-sig-geo
[R-sig-Geo] Converting longitude and latitude to UK OS references
I am trying to convert longitude and latitude values for UK weather stations to UK Ordnance Survey National Grid References. There are sites where one can do them one at a time but I have a large number. I have found some code which does the conversion and include the first three points which I want to convert as an example library(sp) xy<-as.data.frame(cbind(c(55.8533,55.8551,55.8473),c(-2.38588,-2.39620,-2.11304))) colnames(xy)<-c("lon","lat") xy coordinates(xy)<-~lon+lat ## see site in jounral convert llon lat proj4string(xy)<-CRS("+init=epsg:4326") ptsOS<-spTransform(xy,CRS("+init=epsg:27700")) ptsOS but it doesn't give the right answers - the output doesn't correspond to either what I get whn I put an individual point into a conversion site nor with other points in the same region which I have got from other sources and are mutually compatible Can anyone explain where I'm going wrong and how I can fix this? Thanks Nick Wray [[alternative HTML version deleted]] ___ R-sig-Geo mailing list R-sig-Geo@r-project.org https://stat.ethz.ch/mailman/listinfo/r-sig-geo
[R-sig-Geo] LINESTRING to vector in R
Hello I have downloaded a large shapefile dataset of UK rivers and I want to isolate (as an ordinary R string) the LINESTRING values for particular lines, corresponding to rivers Looking at the first line I can isolate the geometry by Hello I have downloaded a large shapefile dataset of UK rivers and I want to isolate (as an ordinary R string) the LINESTRING values for particular lines, corresponding to rivers Looking at the first line I can isolate the geometry by st_geometry(rivers[1,8]) Geometry set for 1 feature Geometry type: LINESTRING Dimension: XYZ Bounding box: xmin: 462010.6 ymin: 1213039 xmax: 462306.5 ymax: 1213199 z_range: zmin: 0 zmax: 0 Projected CRS: OSGB 1936 / British National Grid LINESTRING Z (462306.5 1213048 0, 462275.4 1213... What I need is all the values in the LINESTRING as a common or garden R vector, but I cannot find a way to do this. Does anyone know how? Thanks, Nick Wray [[alternative HTML version deleted]] ___ R-sig-Geo mailing list R-sig-Geo@r-project.org https://stat.ethz.ch/mailman/listinfo/r-sig-geo