[GRASS-user] r.in.xyz: Could open text file ~ 2.5GB

Glynn Clements glynn at gclements.plus.com
Thu Oct 19 14:01:17 EDT 2006


Patton, Eric wrote:

> I'm trying to open a text file to scan for extents:
> 
> r.in.xyz -s input=2006MB_GarryTrough_1N.txt output=2006MB_GarryTrough_1N
> method=mean type=FCELL fs=space  x=1 y=2 z=3 percent=100
> 
> Could not open input file
> </home/epatton/Projects/Whalen/PERMANENT/WORK/2006MB_GarryTrough_1N.txt>.
> 
> I get the same error regardless of what percent parameter is set to (60, 40,
> 10). Is this an LFS problem with r.in.xyz?

Yes. r.in.xyz won't accept input files >2GiB on a 32-bit system (one
where the C "long" type is 32 bits), regardless of whether or not
GRASS was built with --enable-largefile.

The attached patch might be sufficient, although the progress
percentage will be wrong (it will reach 100% at 2GiB rather than at
the end of the file).

-- 
Glynn Clements <glynn at gclements.plus.com>

-------------- next part --------------
Index: raster/r.in.xyz/main.c
===================================================================
RCS file: /grassrepository/grass6/raster/r.in.xyz/main.c,v
retrieving revision 1.21
diff -u -r1.21 main.c
--- raster/r.in.xyz/main.c	12 Oct 2006 07:22:35 -0000	1.21
+++ raster/r.in.xyz/main.c	19 Oct 2006 17:56:45 -0000
@@ -12,6 +12,7 @@
  *   This program is intended as a replacement for the GRASS 5 s.cellstats module.
  */
 
+#include <grass/config.h>
 #include <stdio.h>
 #include <stdlib.h>
 #include <string.h>
@@ -33,7 +34,7 @@
     int    bin_n, bin_min, bin_max, bin_sum, bin_sumsq;
     double zrange_min, zrange_max, d_tmp;
     char   *fs; /* field delim */
-    unsigned long filesize;
+    long   filesize;
     int    linesize, estimated_lines;
 
     RASTER_MAP_TYPE rtype;
@@ -328,6 +329,8 @@
     }
     fseek(in_fd, 0L, SEEK_END);
     filesize = ftell(in_fd);
+    if (filesize < 0)
+	filesize = 0x7FFFFFFF;
     rewind(in_fd);
     if(linesize < 6)  /* min possible: "0,0,0\n" */
 	linesize = 6;


More information about the grass-user mailing list