English 中文(简体)
保留地格档案的问题——“ASCII Grid文档中是否有数据价值”?
原标题:Issues with saving terra asc files - "Couldn t find data values in ASCII Grid file"?
  • 时间:2024-03-19 18:54:27
  •  标签:
  • r
  • terra

Reproducible example from my dataset;

library(terra)
ext1_boreal <- ext(-154.529, -104.855, 47.663, 70.4789)
x <- rast(ext1_boreal, res=.1, crs="epsg:4326")
values(x) <- 1:ncell(x)

ext_EcoZone1 <- ext(-140.999, -122.812, 56.408, 64.700)
EcoZone2 <- vect(ext_EcoZone1, crs="epsg:4326")
x <- mask(x, EcoZone2)
f <- "D:/GitHub/MyProject/Outputs/Rasters/Explanatory/Testx.asc"
writeRaster(x, filename=f, overwrite=TRUE)

The problem:

Warning: D:/GitHub/MyProject/Outputs/Rasters/Explanatory/Testx.asc: Couldn t find data values in ASCII Grid file. (GDAL error 1)Error: [rast] cannot open this file as a SpatRaster: D:/GitHub/MyProject/Outputs/Rasters/Explanatory/Testx.asc

为什么发出这一警告? 使用:成套地形版本1.7-71,R版本4.3.3。

我无法为我的数据出口一个信箱(ESRI ASCII)。 我可以无问题出口扼杀。 我需要使用,该软件使用方式与一套软件格式脱节。 我能够把Saptraster扼杀档案带入QGIS,并单独将其作为后可输入R的立体文档。

问题回答

这对我来说是可行的(使用另一个档案名称,因为我没有这样做)。

f <- paste0(tempfile(), ".asc")
writeRaster(x, filename=f, overwrite=TRUE)

这样做(不需要另外打电话<代码>write Raster)

x <- mask(x, EcoZone2, filename=f, overwrite=TRUE)

也许你的磁盘是完整的吗?





相关问题
How to plot fitted model over observed time series

This is a really really simple question to which I seem to be entirely unable to get a solution. I would like to do a scatter plot of an observed time series in R, and over this I want to plot the ...

REvolution for R

since the latest Ubuntu release (karmic koala), I noticed that the internal R package advertises on start-up the REvolution package. It seems to be a library collection for high-performance matrix ...

R - capturing elements of R output into text files

I am trying to run an analysis by invoking R through the command line as follows: R --no-save < SampleProgram.R > SampleProgram.opt For example, consider the simple R program below: mydata =...

R statistical package: wrapping GOFrame objects

I m trying to generate GOFrame objects to generate a gene ontology mapping in R for unsupported organisms (see http://www.bioconductor.org/packages/release/bioc/vignettes/GOstats/inst/doc/...

Changing the order of dodged bars in ggplot2 barplot

I have a dataframe df.all and I m plotting it in a bar plot with ggplot2 using the code below. I d like to make it so that the order of the dodged bars is flipped. That is, so that the bars labeled "...

Strange error when using sparse matrices and glmnet

I m getting a weird error when training a glmnet regression. invalid class "dgCMatrix" object: length(Dimnames[[2]]) must match Dim[2] It only happens occasionally, and perhaps only under larger ...

Generating non-duplicate combination pairs in R

Sorry for the non-descriptive title but I don t know whether there s a word for what I m trying to achieve. Let s assume that I have a list of names of different classes like c( 1 , 2 , 3 , 4 ) ...

Per panel smoothing in ggplot2

I m plotting a group of curves, using facet in ggplot2. I d like to have a smoother applied to plots where there are enough points to smooth, but not on plots with very few points. In particular I d ...

热门标签