[R-sig-Geo] problems for reading ASCII file

Barry Rowlingson b.rowlingson at lancaster.ac.uk
Wed Oct 7 11:43:17 CEST 2015


On Wed, Oct 7, 2015 at 10:04 AM, Paulo Flores Ribeiro
<paulo.flores.mail at gmail.com> wrote:
> Try change cell size in your ascii text file (eg. instead of «cellsize
> 0,0012386489974299», try  «cellsize 10,10»)

How is that going to do anything but break the geolocation of the raster?

I'm worried about the comma decimal separators. Are they really commas
in the grid file? They should be full stops "." - otherwise I suspect
readAsciiGrid is throwing a fit. The cellsize parameter is a single
value, Esri Ascii Grid cells are always square.

Its possible there are decimal points okay in the file, and what
you've shown us is a localised printout where your locale is set to
use commas for decimal markers. But if there really are commas in the
file, then it will fail until they are replaced with points.

I can replicate your error with:

ncols 5
nrows 3
xllcorner 1000
yllcorner 1000
cellsize 0,001
NODATA_value -9999
2 3 4 3 2
3 4 5 6 7
1 2 4 3 2

and if I replace the comma with a point it reads in okay.

Barry


> Paulo Flores Ribeiro
>
> Às 08:48 de 07-10-2015, ana carolina cuellar escreveu:
>>
>> Hi All, I am trying to read an ASCII file into R and is the first time i
>> am
>> trying to work with ASCII files. I saw a previous discussion that this
>> command can be used:
>>
>> library(rgdal)
>> library(maptools)
>> grid <- readAsciiGrid("<your file and its path>")
>> table <- data.frame(grid)
>>
>> in my case:  grid <-
>> readAsciiGrid("I:/modisv5sm0112_2/prueb/amaascii.txt")
>>
>>
>> but when i used the readAsciiGrid function i get this error:
>>
>> Error in validObject(.Object) :
>>
>>    invalid class “GridTopology” object: cells.dim has incorrect dimension
>>
>>
>> Can anybody tell me why? i dont get why it doesnt work :(
>>
>> my ASCII file looks like this:
>>
>> ncols         260
>> nrows         193
>> xllcorner     12,397449031167
>> yllcorner     55,534017291881
>> cellsize      0,0012386489974299
>> NODATA_value  -9999
>> -9999 -9999 -9999 -9999 -9999 -9999 -9999 -9999 -9999 -9999 -9999 25
>> 25....etc
>>
>>
>> i am trying to process a raster image (the one i transformed to ASCII)
>> but it is too big to work with it as a raster in R (i am having memory
>> problems)...thats why i am trying to see if its simplier to process it
>> in ASCII and then bring it back to raster.
>>
>> Thanks a lot!!
>>
>> Ana
>>
>>         [[alternative HTML version deleted]]
>>
>> _______________________________________________
>> R-sig-Geo mailing list
>> R-sig-Geo at r-project.org
>> https://stat.ethz.ch/mailman/listinfo/r-sig-geo
>
>
> _______________________________________________
> R-sig-Geo mailing list
> R-sig-Geo at r-project.org
> https://stat.ethz.ch/mailman/listinfo/r-sig-geo



More information about the R-sig-Geo mailing list