Monday 29 July 2019

Why is this GRASS script (from GRASS WiKi) causing an error?


I'm trying to run a script from the GRASS WiKi to create a simple map using ps.map. I'm confused because it's generating an error that the output was not set, when it appears to me that it is set at the beginning of the script. The script and error follow. The first code box contains the contents of the file spearfish.map, which is referenced as the input value in the second code box.



# Simple ps.map example using the Spearfish dataset
g.region rast=elevation.10m

ps.map output=spearfish.ps << EOF
paper us-letter
end
scale 1:120000
raster elevation.10m
colortable
where 2 6.75

end
text 50% -7% Spearfish County, ND (Mount Rushmore)
fontsize 16
end
mapinfo
where 4.5 7.25
end
vlines roads
where label ~ 'highway' OR label = 'interstate'
color grey

end
vpoints archsites
symbol basic/triangle
end
end
EOF

The command for running the script and the error it generates are below:


> ps.map input=spearfish.map                                                     
ERROR: Required parameter not set:

(PostScript output file)

UPDATE: Based on ShaunLangley's comment, I tried ps.map output=out.map. This seems to have started ps.map in interactive mode and I was able to enter the rest of the script one line at a time. That did create a map as a postscript file, so I'm headed in the right direction. I'll close this thread as solved and open a new one more targeted on the question of how to run the commands as a script.



Answer



the ps.map function requires you specify output. The example you have:


> ps.map input=spearfish.map

doesn't specify the output variable. I'm not sure what the distinction between the code boxes is. The former should work because the input raster is defined with "raster" and output defined at the top. It looks like you're trying to replicate an example; is this correct?


Perhaps you could try:


ps.map input=elevation.10m output=spearfish.map


You can specify the additional options as well just as the code example did.


No comments:

Post a Comment

arcpy - Changing output name when exporting data driven pages to JPG?

Is there a way to save the output JPG, changing the output file name to the page name, instead of page number? I mean changing the script fo...