Closed BeetrootShoulders closed 4 years ago
You need to tell it the CRS of the OS Terrain 50 files. Try adding this to your mosaic_files() call.
file_crs = 'EPSG:27700'
I'm away from my personal machine so let me know if that fails & I'll test it properly.
That threw an error so I did a bit of Googling and found that it in fact needs:
file_crs = '+proj=tmerc +lat_0=49 +lon_0=-2 +k=0.9996012717 +x_0=400000 +y_0=-100000 +ellps=airy +datum=OSGB36 +units=m +no_defs '
However, on running I now get a fresh error:
Unzipping files...
Merging files...
Error in .local(.Object, ...) :
Error in .rasterObjectFromFile(x, band = band, objecttype = "RasterLayer", :
Cannot create a RasterLayer object from this file.
This should be fixed now, thanks for logging the issue.
Use this snippet to run the merge (also changed in the readme), which changes file_match so that it doesn't pick up an extra xml file from the OS Terrain 50 zip files. I've also fixed a bug in the merge function.
mosaic_files(
"path/to/zip/files",
extract_zip = TRUE,
zip_file_match = ".*GRID.*.zip",
file_match = ".*.asc$",
raster_output_file = "mosaic_out.raster",
file_crs = '+proj=tmerc +lat_0=49 +lon_0=-2 +k=0.9996012717 +x_0=400000 +y_0=-100000 +ellps=airy +datum=OSGB36 +units=m +no_defs'
)
Until it's on CRAN, install with
remotes::install_github("neilcharles/geoviz")
Having trouble using this with OS Terrain 50. I get the following error:
Error in mosaic_files("terr50_gagg_gb/data/nn", extract_zip = TRUE, zip_file_match = ".*GRID.*.zip", : Input files have no CRS, use the file_crs option to set it