Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

manual: correct v.surf.rst example #3743

Merged
merged 3 commits into from
Jun 6, 2024

Conversation

neteler
Copy link
Member

@neteler neteler commented May 27, 2024

Update broken example (r.random usage and more meaningful threshold).

Update broken example.
@neteler neteler added the manual Documentation related issues label May 27, 2024
@neteler neteler added this to the 8.4.0 milestone May 27, 2024
@neteler neteler self-assigned this May 27, 2024
@github-actions github-actions bot added vector Related to vector data processing HTML Related code is in HTML module docs labels May 27, 2024
ninsbl
ninsbl previously approved these changes May 30, 2024
Copy link
Member

@ninsbl ninsbl left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Have not tested but looks good to me...

@echoix
Copy link
Member

echoix commented May 30, 2024

Didn't quite work for me (windows OSGeo4W grass-dev 8.4-314-xxxxxxxx-1) past the first v.surf.rst call (that problems started):

There's even a traceback :(

The first call failing is because I forgot to select the mapset after downloading the north carolina location

image
image
image
image
image
image

Full console output:

Details

(Thu May 30 08:08:11 2024)                                                      
v.db.select elevrand                                                            
ERROR: Vector map <elevrand> not found
(Thu May 30 08:08:12 2024) Command ended with non-zero return code 1 (0 sec)    
(Thu May 30 08:08:49 2024)                                                      
g.region raster=elevation -p                                                    
projection: 99 (Lambert Conformal Conic)
zone:       0
datum:      nad83
ellipsoid:  a=6378137 es=0.006694380022900787
north:      228500
south:      215000
west:       630000
east:       645000
nsres:      10
ewres:      10
rows:       1350
cols:       1500
cells:      2025000
(Thu May 30 08:08:51 2024) Command finished (0 sec)                             
(Thu May 30 08:09:02 2024)                                                      
r.random -s elevation vector=elevrand n=500                                     
Collecting Stats...
Writing vector map <elevrand> ...
Building topology for vector map <elevrand@PERMANENT>...
Registering primitives...
(Thu May 30 08:09:04 2024) Command finished (1 sec)                             
(Thu May 30 08:09:14 2024)                                                      
v.info -c elevrand                                                              
Displaying column types/names for database connection of layer <1>:
INTEGER|cat
DOUBLE PRECISION|value
(Thu May 30 08:09:16 2024) Command finished (1 sec)                             
(Thu May 30 08:09:26 2024)                                                      
v.db.select elevrand                                                            
cat|value
1|139.334793
2|108.347321
3|79.552414
[...]
498|104.818825
499|121.172256
500|120.353851
(Thu May 30 08:09:28 2024) Command finished (1 sec)                             
(Thu May 30 08:09:37 2024)                                                      
v.surf.rst elevrand zcol=value elevation=elev_full                              
Reading features from vector map ...
WARNING: There are less than 600 points for interpolation. No segmentation is necessary, to run the program faster set segmax=600 (see manual)
Processing all selected output files will require
7.73 MB of disk space for temp files.
Processing segments in parallel...
Starting parallel work
WARNING: Overshoot - increase in tension suggested. Overshoot occurs at (1302,341) cell. Z-value 52336.522532, zmin 56.839634, zmax 153.417145.
(Thu May 30 08:09:50 2024) Command ended with non-zero return code 3221226356 (11 sec)
(Thu May 30 08:10:17 2024)                                                      
r.colors elev_full raster=elevation                                             
ERROR: Raster map <elev_full> not found
(Thu May 30 08:10:18 2024) Command ended with non-zero return code 1 (0 sec)    
Failed to run command 'd.rast map=elev_full'. Details:                          
                                                                                
GRASS_INFO_ERROR(5168,1): Raster map <elev_full> not found                      
GRASS_INFO_END(5168,1)                                                          
(Thu May 30 08:11:11 2024)                                                      
v.db.univar -e elevrand column=value                                            
Reading column values...
Number of values: 500
Minimum: 56.839634
Maximum: 153.417145
Range: 96.577511
Mean: 111.182936934
Arithmetic mean of absolute values: 111.182936934
Variance: 451.398877288021
Standard deviation: 21.2461497050176
Coefficient of variation: 0.191091819400577
Sum: 55591.468467
-nThe system cannot find the file specified.
Traceback (most recent call last):
  File "C:\OSGeo4W\apps\grass\grass84/scripts/db.univar.py",
line 384, in <module>
    main()
  File "C:\OSGeo4W\apps\grass\grass84/scripts/db.univar.py",
line 291, in main
    sortfile(tmp, tmp + ".sort")
  File "C:\OSGeo4W\apps\grass\grass84/scripts/db.univar.py",
line 84, in sortfile
    gscript.run_command("sort", flags="n", stdin=inf,
stdout=outf)
  File "C:\OSGeo4W\apps\grass\grass84\etc\python\grass\scrip
t\core.py", line 487, in run_command
    return handle_errors(returncode, result=None, args=args,
kwargs=kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
^^^^^^^^^^^^^^^
  File "C:\OSGeo4W\apps\grass\grass84\etc\python\grass\scrip
t\core.py", line 366, in handle_errors
    raise CalledModuleError(module=module, code=code,
returncode=returncode)
grass.exceptions.CalledModuleError: Module run `sort -n`
ended with an error.
The subprocess ended with a non-zero return code: 1. See
errors above the traceback or in the error output.
(Thu May 30 08:11:14 2024) Command ended with non-zero return code 1 (2 sec)    
(Thu May 30 08:11:25 2024)                                                      
v.surf.rst elevrand zcol=value elevation=elev_partial where=value > 123.7       
Reading features from vector map ...
WARNING: Strip exists with insufficient data
WARNING: 158 points given for interpolation (after thinning) is less than given NPMIN=300
WARNING: There are less than 600 points for interpolation. No segmentation is necessary, to run the program faster set segmax=600 (see manual)
Processing all selected output files will require
7.72 MB of disk space for temp files.
Processing segments in parallel...
Starting parallel work
WARNING: Taking too long to find points for interpolation - please change the region to area where your points are. Continuing calculations...
WARNING: Taking too long to find points for interpolation - please change the region to area where your points are. Continuing calculations...
WARNING: Taking too long to find points for interpolation - please change the region to area where your points are. Continuing calculations...
(Thu May 30 08:11:35 2024) Command ended with non-zero return code 3221226356 (9 sec)
(Thu May 30 08:11:39 2024)                                                      
r.colors elev_partial raster=elevation                                          
ERROR: Raster map <elev_partial> not found
(Thu May 30 08:11:41 2024) Command ended with non-zero return code 1 (0 sec)    
Failed to run command 'd.rast map=elev_partial'. Details:                       
                                                                                
GRASS_INFO_ERROR(2988,1): Raster map <elev_partial> not found                   
GRASS_INFO_END(2988,1)                                                          

Copy link
Contributor

@petrasovaa petrasovaa left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I tested on linux and the example is fine, everything runs, even with valgrind.

@neteler
Copy link
Member Author

neteler commented May 31, 2024

The first call failing is because I forgot to select the mapset after downloading the north carolina location

However, are this/these error/s really related to the new example (as it works for others) or warrant a new issue/PR?

@echoix
Copy link
Member

echoix commented May 31, 2024

I think these two warnings shouldn't be emitted when using the example call:


v.surf.rst elevrand zcol=value elevation=elev_full                              
Reading features from vector map ...
WARNING: There are less than 600 points for interpolation. No segmentation is necessary, to run the program faster set segmax=600 (see manual)
Processing all selected output files will require
7.73 MB of disk space for temp files.
Processing segments in parallel...
Starting parallel work
WARNING: Overshoot - increase in tension suggested. Overshoot occurs at (1302,341) cell. Z-value 52336.522532, zmin 56.839634, zmax 153.417145.
(Thu May 30 08:09:50 2024) Command ended with non-zero return code 3221226356 (11 sec)

Not enough points, and what does overshoot mean here?

@veroandreo
Copy link
Contributor

I think these two warnings shouldn't be emitted when using the example call:


v.surf.rst elevrand zcol=value elevation=elev_full                              
Reading features from vector map ...
WARNING: There are less than 600 points for interpolation. No segmentation is necessary, to run the program faster set segmax=600 (see manual)
Processing all selected output files will require
7.73 MB of disk space for temp files.
Processing segments in parallel...
Starting parallel work
WARNING: Overshoot - increase in tension suggested. Overshoot occurs at (1302,341) cell. Z-value 52336.522532, zmin 56.839634, zmax 153.417145.
(Thu May 30 08:09:50 2024) Command ended with non-zero return code 3221226356 (11 sec)

Not enough points, and what does overshoot mean here?

AFAIU, it predicts a really high value compared to the min-max range

Copy link
Contributor

@petrasovaa petrasovaa left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Using 1st quartile and npmin=100 will fix the problems.

vector/v.surf.rst/v.surf.rst.html Outdated Show resolved Hide resolved
vector/v.surf.rst/v.surf.rst.html Outdated Show resolved Hide resolved
Co-authored-by: Anna Petrasova <[email protected]>
@neteler neteler requested a review from petrasovaa June 2, 2024 10:42
@echoix
Copy link
Member

echoix commented Jun 2, 2024

GRASS GIS Console output:

Details

(Sun Jun  2 08:18:05 2024)                                                      
g.region raster=elevation -p                                                    
projection: 99 (Lambert Conformal Conic)
zone:       0
datum:      nad83
ellipsoid:  a=6378137 es=0.006694380022900787
north:      228500
south:      215000
west:       630000
east:       645000
nsres:      10
ewres:      10
rows:       1350
cols:       1500
cells:      2025000
(Sun Jun  2 08:18:06 2024) Command finished (0 sec)                             
(Sun Jun  2 08:18:15 2024)                                                      
r.random -s elevation vector=elevrand n=500                                     
Collecting Stats...
Writing vector map <elevrand> ...
Building topology for vector map <elevrand@PERMANENT>...
Registering primitives...
(Sun Jun  2 08:18:17 2024) Command finished (1 sec)                             
(Sun Jun  2 08:18:24 2024)                                                      
v.info -c elevrand                                                              
INTEGER|cat
DOUBLE PRECISION|value
Displaying column types/names for database connection of layer <1>:
(Sun Jun  2 08:18:26 2024) Command finished (0 sec)                             
(Sun Jun  2 08:18:50 2024)                                                      
v.db.select elevrand                                                            
cat|value
1|132.603104
2|136.727524
3|121.434631
4|141.957703
5|77.78125
6|146.0112
7|139.792068
8|147.112198
9|141.073868
10|144.650116
11|129.659531
12|63.483627
13|119.557114
14|62.680443
15|57.236671
16|91.529587
17|125.334625
18|130.351196
19|116.749054
20|82.054657
21|139.65416
22|119.276947
23|137.49649
24|110.643692
25|131.997955
26|80.070724
27|141.659027
28|113.749886
29|120.824944
30|101.19117
31|128.672287
32|146.395905
33|88.485298
34|94.823586
35|72.360153
36|140.557724
37|117.704552
38|122.018372
39|122.050415
40|62.804924
41|134.56398
42|122.712852
43|87.175537
44|112.483231
45|77.574677
46|87.955009
47|143.211365
48|152.175446
49|81.232368
50|85.721115
51|81.569847
52|88.065804
53|134.774399
54|112.089241
55|140.760269
56|125.236694
57|137.276215
58|96.618706
59|147.857269
60|135.471664
61|112.656052
62|142.338455
63|95.163712
64|151.852707
65|110.127609
66|134.203186
67|138.87619
68|89.821663
69|135.376923
70|115.485924
71|149.706177
72|153.473557
73|99.394157
74|130.852478
75|109.568756
76|75.995987
77|133.887039
78|95.200081
79|139.146439
80|95.514755
81|151.604492
82|149.084946
83|126.791985
84|147.820557
85|127.753716
86|130.14032
87|127.36367
88|148.999619
89|146.473068
90|143.607498
91|77.746155
92|94.445419
93|123.874016
94|93.502518
95|141.814804
96|85.473236
97|95.269257
98|98.974609
99|99.766724
100|145.620956
101|96.495026
102|113.911568
103|147.121872
104|119.1101
105|101.312347
106|137.105698
107|144.945633
108|138.191849
109|132.314484
110|105.267662
111|127.242172
112|144.111801
113|125.589897
114|136.341492
115|129.755356
116|111.891747
117|88.494949
118|95.514923
119|93.657913
120|115.780876
121|125.468788
122|113.218124
123|124.287651
124|125.69136
125|102.719795
126|104.149132
127|101.683914
128|140.867126
129|122.865486
130|92.447624
131|130.032379
132|127.540222
133|94.91716
134|98.629692
135|141.458084
136|122.459038
137|121.176506
138|117.964745
139|135.084183
140|135.90242
141|100.496513
142|85.661667
143|143.512589
144|128.049271
145|100.212219
146|119.324364
147|100.413986
148|103.230499
149|94.847076
150|122.25354
151|115.30513
152|120.316345
153|141.212128
154|101.947708
155|110.992172
156|122.30513
157|135.675751
158|133.800385
159|91.397255
160|131.267334
161|128.787201
162|92.021172
163|87.891708
164|136.075165
165|91.345123
166|144.727356
167|103.36557
168|111.016174
169|83.445076
170|139.960251
171|144.351685
172|85.763451
173|104.476891
174|132.785065
175|145.825653
176|104.364738
177|116.46064
178|71.002174
179|121.657402
180|111.83593
181|142.572006
182|127.841698
183|151.254333
184|92.953308
185|73.1502
186|107.936867
187|85.841362
188|129.951721
189|136.562607
190|145.567337
191|93.547653
192|114.070686
193|67.656418
194|133.790787
195|107.731041
196|117.465111
197|118.79615
198|132.820648
199|73.866287
200|68.889046
201|65.132896
202|146.831467
203|85.604568
204|75.829544
205|82.041168
206|110.162865
207|121.365593
208|108.323494
209|105.752937
210|69.811623
211|141.046295
212|127.041351
213|82.806511
214|128.950272
215|122.82016
216|86.313042
217|139.211578
218|111.464249
219|139.761993
220|79.663773
221|117.922241
222|114.661285
223|136.519562
224|140.477158
225|73.051933
226|88.086304
227|98.7808
228|125.152252
229|86.573936
230|128.525482
231|130.32106
232|100.57373
233|104.623169
234|101.696388
235|133.365646
236|122.645767
237|109.104797
238|89.165344
239|86.545609
240|116.996292
241|116.21328
242|117.317543
243|89.158058
244|132.383789
245|127.589333
246|104.382141
247|126.198471
248|136.021988
249|92.459358
250|133.341721
251|125.198639
252|128.959442
253|80.028519
254|134.980118
255|83.957588
256|128.426727
257|84.632889
258|130.566711
259|109.005005
260|84.698265
261|119.180183
262|117.880943
263|116.202728
264|135.062775
265|137.475189
266|85.28878
267|93.772316
268|135.712296
269|100.442764
270|105.153931
271|118.009514
272|128.814651
273|131.894043
274|126.479897
275|125.923752
276|112.374252
277|122.465073
278|128.930222
279|108.810501
280|123.084145
281|128.963943
282|127.808189
283|101.600182
284|135.481339
285|116.456924
286|121.766037
287|111.0466
46
288|107.193062
289|103.802834
290|124.04985
291|83.313248
292|115.717796
293|117.343224
294|111.75798
295|130.293243
296|114.468803
297|100.075409
298|116.039421
299|125.601425
300|104.159561
301|99.068283
302|105.239326
303|103.742485
304|125.692322
305|107.772423
306|111.576241
307|104.354324
308|117.449249
309|116.621498
310|118.938484
311|118.658005
312|124.457306
313|93.047905
314|99.668938
315|124.810699
316|95.948036
317|103.906364
318|116.813652
319|108.704323
320|122.818375
321|110.235359
322|107.675591
323|119.408478
324|104.925056
325|123.801987
326|110.470352
327|104.510445
328|132.096298
329|108.721283
330|93.897217
331|96.938835
332|99.410706
333|112.242332
334|108.560326
335|92.83223
336|92.630013
337|118.7742
338|110.95887
339|96.296669
340|102.210419
341|101.039116
342|112.426598
343|137.754379
344|97.858612
345|113.444099
346|97.945488
347|128.349136
348|100.388351
349|94.415092
350|100.888695
351|99.268448
352|106.279198
353|109.540199
354|104.122093
355|95.909866
356|133.715103
357|91.076103
358|94.368401
359|128.448364
360|110.5896
361|89.613121
362|117.881584
363|116.243263
364|128.749176
365|102.981186
366|99.775436
367|90.741867
368|91.610428
369|92.770401
370|124.159416
371|122.355865
372|97.706177
373|91.426483
374|96.22171
375|106.232574
376|91.350044
377|100.590065
378|105.504013
379|117.84623
380|122.295341
381|108.843468
382|105.861588
383|99.843086
384|100.159737
385|131.352173
386|96.142731
387|100.352333
388|104.446922
389|100.949112
390|93.509277
391|93.428635
392|121.942436
393|96.95031
394|93.795586
395|86.831139
396|118.112312
397|137.12442
398|98.615532
399|99.975769
400|99.334961
401|116.107368
402|110.122894
403|93.966087
404|108.09774
405|85.643883
406|113.039185
407|115.709908
408|94.907455
409|102.87278
410|88.308464
411|88.331116
412|111.541283
413|110.936241
414|94.712776
415|136.647583
416|95.580833
417|121.35556
418|97.675758
419|104.870331
420|95.961395
421|104.664452
422|87.597801
423|124.098427
424|106.617523
425|102.604965
426|135.591217
427|115.81987
428|133.111481
429|99.751114
430|95.029663
431|137.989349
432|102.858894
433|111.663567
434|87.009766
435|97.620041
436|99.320625
437|87.268631
438|105.904434
439|128.648102
440|112.078209
441|99.813789
442|108.990654
443|96.296616
444|88.142189
445|123.399269
446|114.881119
447|104.214088
448|93.012238
449|109.696236
450|108.085876
451|112.329346
452|114.653023
453|129.795502
454|93.160896
455|103.975647
456|94.463669
457|112.631668
458|84.387032
459|121.13784
460|109.736046
461|90.789482
462|93.120514
463|98.032921
464|90.876984
465|104.472229
466|105.695038
467|96.661392
468|105.502029
469|98.374207
470|98.958641
471|107.156303
472|102.200813
473|108.292175
474|89.196106
475|109.270218
476|91.591888
477|93.0317
478|98.124405
479|97.201729
480|120.746002
481|83.294281
482|86.355827
483|116.77652
484|86.220894
485|91.340813
486|115.013275
487|140.98674
488|89.755051
489|97.26651
490|102.819901
491|84.753746
492|91.34787
493|135.995316
494|73.906052
495|100.559448
496|135.466583
497|135.576477
498|76.441788
499|129.969223
500|77.75724
(Sun Jun  2 08:18:52 2024) Command finished (1 sec)                             
(Sun Jun  2 08:19:03 2024)                                                      
v.surf.rst elevrand zcol=value elevation=elev_full                              
Reading features from vector map ...
WARNING: There are less than 600 points for interpolation. No segmentation is necessary, to run the program faster set segmax=600 (see manual)
Processing all selected output files will require
7.73 MB of disk space for temp files.
Processing segments in parallel...
Starting parallel work
WARNING: Overshoot - increase in tension suggested. Overshoot occurs at (888,340) cell. Z-value 2439.497871, zmin 57.236671, zmax 153.473557.
(Sun Jun  2 08:19:14 2024) Command ended with non-zero return code 3221226356 (10 sec)
(Sun Jun  2 08:19:31 2024)                                                      
r.colors elev_full raster=elevation                                             
ERROR: Raster map <elev_full> not found
(Sun Jun  2 08:19:32 2024) Command ended with non-zero return code 1 (0 sec)    
(Sun Jun  2 08:20:47 2024)                                                      
r.colors input=elev_full raster=elevation                                       
Creates/modifies the color table associated with a raster
map.
Usage:
 r.colors [-rwldngae] [map=name[,name,...]] [file=name]
[color=style]
   [raster=name] [raster_3d=name] [rules=name]
[offset=value]
   [scale=value] [--help] [--verbose] [--quiet] [--ui]
Flags:
  -r   Remove existing color table
  -w   Only write new color table if it does not already
exist
  -l   List available rules then exit
  -d   List available rules with description then exit
  -n   Invert colors
  -g   Logarithmic scaling
  -a   Logarithmic-absolute scaling
  -e   Histogram equalization
Parameters:
        map   Name of raster map(s)
       file   Input file with one map name per line
      color   Name of color table
              options:
aspect,aspectcolr,bcyr,bgyr,blues,byg,byr,celsius,
corine,curvature,differences,elevation,etopo2,evi,
fahrenheit,forest_cover,gdd,grass,greens,grey,grey.eq,
grey.log,grey1.0,grey255,gyr,haxby,inferno,kelvin,
magma,ndvi,ndwi,nlcd,oranges,plasma,population,
population_dens,precipitation,precipitation_daily,
precipitation_monthly,rainbow,ramp,random,reds,
roygbiv,rstcurv,ryb,ryg,sepia,slope,soilmoisture,srtm,
                       srtm_plus,terrain,viridis,water,wave
     raster   Raster map from which to copy color table
  raster_3d   3D raster map from which to copy color table
      rules   Path to rules file
     offset   Offset for color rule values
              default: 0
      scale   Scale for color rule values
              default: 1
ERROR: r.colors: Sorry, <input> is not a valid parameter
ERROR: At least one of the following options is required:
<map>, <file>, <-l> and <-d>
(Sun Jun  2 08:20:48 2024) Command ended with non-zero return code 1 (0 sec)    
(Sun Jun  2 08:21:37 2024)                                                      
r.colors elev_full raster=elevation                                             
ERROR: Raster map <elev_full> not found
(Sun Jun  2 08:21:38 2024) Command ended with non-zero return code 1 (0 sec)    
(Sun Jun  2 08:22:01 2024)                                                      
v.db.univar -e elevrand column=value                                            
Reading column values...
Number of values: 500
Minimum: 57.236671
Maximum: 153.473557
Range: 96.236886
Mean: 111.473390824
Arithmetic mean of absolute values: 111.473390824
Variance: 388.104774537452
Standard deviation: 19.7003749846913
Coefficient of variation: 0.176727152902304
Sum: 55736.695412
-nThe system cannot find the file specified.
Traceback (most recent call last):
  File "C:\OSGeo4W\apps\grass\grass84/scripts/db.univar.py",
line 384, in <module>
    main()
  File "C:\OSGeo4W\apps\grass\grass84/scripts/db.univar.py",
line 291, in main
    sortfile(tmp, tmp + ".sort")
  File "C:\OSGeo4W\apps\grass\grass84/scripts/db.univar.py",
line 84, in sortfile
    gscript.run_command("sort", flags="n", stdin=inf,
stdout=outf)
  File "C:\OSGeo4W\apps\grass\grass84\etc\python\grass\scrip
t\core.py", line 487, in run_command
    return handle_errors(returncode, result=None, args=args,
kwargs=kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
^^^^^^^^^^^^^^^
  File "C:\OSGeo4W\apps\grass\grass84\etc\python\grass\scrip
t\core.py", line 366, in handle_errors
    raise CalledModuleError(module=module, code=code,
returncode=returncode)
grass.exceptions.CalledModuleError: Module run `sort -n`
ended with an error.
The subprocess ended with a non-zero return code: 1. See
errors above the traceback or in the error output.
(Sun Jun  2 08:22:04 2024) Command ended with non-zero return code 1 (2 sec)    
(Sun Jun  2 08:22:31 2024)                                                      
v.db.univar -e elevrand column=value                                            
Reading column values...
Number of values: 500
Minimum: 57.236671
Maximum: 153.473557
Range: 96.236886
Mean: 111.473390824
Arithmetic mean of absolute values: 111.473390824
Variance: 388.104774537452
Standard deviation: 19.7003749846913
Coefficient of variation: 0.176727152902304
Sum: 55736.695412
-nThe system cannot find the file specified.
Traceback (most recent call last):
  File "C:\OSGeo4W\apps\grass\grass84/scripts/db.univar.py",
line 384, in <module>
    main()
  File "C:\OSGeo4W\apps\grass\grass84/scripts/db.univar.py",
line 291, in main
    sortfile(tmp, tmp + ".sort")
  File "C:\OSGeo4W\apps\grass\grass84/scripts/db.univar.py",
line 84, in sortfile
    gscript.run_command("sort", flags="n", stdin=inf,
stdout=outf)
  File "C:\OSGeo4W\apps\grass\grass84\etc\python\grass\scrip
t\core.py", line 487, in run_command
    return handle_errors(returncode, result=None, args=args,
kwargs=kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
^^^^^^^^^^^^^^^
  File "C:\OSGeo4W\apps\grass\grass84\etc\python\grass\scrip
t\core.py", line 366, in handle_errors
    raise CalledModuleError(module=module, code=code,
returncode=returncode)
grass.exceptions.CalledModuleError: Module run `sort -n`
ended with an error.
The subprocess ended with a non-zero return code: 1. See
errors above the traceback or in the error output.
(Sun Jun  2 08:22:34 2024) Command ended with non-zero return code 1 (2 sec)    
(Sun Jun  2 08:28:15 2024)                                                      
v.surf.rst input=elevrand zcolumn=value elevation=elev_partial npmin=100 where=value > 94.9
Reading features from vector map ...
WARNING: Strip exists with insufficient data
Processing all selected output files will require
7.73 MB of disk space for temp files.
Processing segments in parallel...
Starting parallel work
ident. points in segm.
x[0]=0.171109, x[90]=0.171109, y[0]=-0.795483,
y[90]=-0.795483
WARNING: Overshoot - increase in tension suggested. Overshoot occurs at (265,339) cell. Z-value 5648.343051, zmin 94.907455, zmax 153.473557.
(Sun Jun  2 08:28:21 2024) Command ended with non-zero return code 3221226356 (5 sec)
(Sun Jun  2 08:28:28 2024)                                                      
r.colors elev_partial raster=elevation                                          
ERROR: Raster map <elev_partial> not found
(Sun Jun  2 08:28:30 2024) Command ended with non-zero return code 1 (0 sec)    
Failed to run command 'd.rast map=elev_partial'. Details:                       
                                                                                
GRASS_INFO_ERROR(5272,1): Raster map <elev_partial> not found                   
GRASS_INFO_END(5272,1)                                                          

Line 326 still doesn't have enough points and overshoots.
Line 328 fails (r.colors), and doesn't continue well.

v.db.univar fails because db.univar fails. It calls sort -n, checking if the program exists before calling it. But there exists a Windows sort.exe in cmd, but doesn't accept -n (a Linux-like argument).
image
image
image

def sortfile(infile, outfile):
inf = open(infile, "r")
outf = open(outfile, "w")
if gscript.find_program("sort", "--help"):
gscript.run_command("sort", flags="n", stdin=inf, stdout=outf)
else:
# FIXME: we need a large-file sorting function
gscript.warning(_("'sort' not found: sorting in memory"))
lines = inf.readlines()
for i in range(len(lines)):
lines[i] = float(lines[i].rstrip("\r\n"))
lines.sort()
for line in lines:
outf.write(str(line) + "\n")
inf.close()
outf.close()

image

This is grass-dev 8.4-316-242731e-1 242731e

@neteler
Copy link
Member Author

neteler commented Jun 2, 2024

What I don't understand: why to you have input=... here? The example does not contain that.

> r.colors input=elev_full raster=elevation                                       
...
> Usage:
>  r.colors [-rwldngae] [map=name[,name,...]] [file=name] [color=style]

Sometimes a kind of "parameter name shift" happens when the compilation is messed up due to partial compilations. In this case only make distclean helps.

@echoix
Copy link
Member

echoix commented Jun 2, 2024

The input was me that retried once, since it says that it didn't work the call before (I saw the difference in another call, I just tried before)

@echoix
Copy link
Member

echoix commented Jun 2, 2024

Sometimes a kind of "parameter name shift" happens when the compilation is messed up due to partial compilations. In this case only make distclean helps.

In #3739 (comment) I gave the hypothesis that maybe a make libsclean might be missing.

@neteler
Copy link
Member Author

neteler commented Jun 2, 2024

v.db.univar fails because db.univar fails.

db.univar issue now reported in #3760

@echoix
Copy link
Member

echoix commented Jun 2, 2024

v.db.univar fails because db.univar fails.

db.univar issue now reported in #3760

It is indeed a problem in db.univar, but the cause I had is very different and specific to windows, where the logic was wrong. The logic checks if there is an executable called sort available, and if so, it calls it with the -n flag. But on windows, there is a sort executable, that doesn't work like the Unix one. So, on Windows, it doesn't fall back into the Python implementation.

@neteler
Copy link
Member Author

neteler commented Jun 2, 2024

ut on windows, there is a sort executable, that doesn't work like the Unix one.

So we need a different implementation for

if gscript.find_program("sort", "--help"):

--> reported in #3778

Copy link
Contributor

@petrasovaa petrasovaa left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For me, this is fine, it's not the best example ever, but I don't think we should be spending more time on it.

@neteler neteler merged commit f13b379 into OSGeo:main Jun 6, 2024
23 checks passed
@neteler neteler deleted the manual_v_surf_rst_example branch June 6, 2024 12:09
a0x8o pushed a commit to a0x8o/grass that referenced this pull request Jun 17, 2024
Update broken user example with more meaningful thresholds.

Co-authored-by: Anna Petrasova <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
docs HTML Related code is in HTML manual Documentation related issues module vector Related to vector data processing
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants