On CentOs 7.. I installed GRASS by

yum install grass

So, using this great tutorial: https://xycarto.com/2020/05/03/basic-grass-gis-with-bash/ I try to get started with GRASS.

I made a folder GRASSDATA and then I made a bash script to initiate it: create a location and a mapset. But command grass -text -c esri:102027 -e $GRASSDB/$GRASSLOC results in The LOCATION "GRASSDATA" does not exist. Please create it first. In bash file I specified $GRASSDB and $GRASSLOC which are in other folder than I start grass from (but even if I change it to that folder it doesn't help at all). Seems I don't understand some basic approach to GRASS. It starts a GRASS session, but doesn't create any location.

I understand that I can create location from GUI (on Windows, as I dont have any GUIs on Linux), but I would like to build the whole processing environment to dockerize it then.

I also analyzed this case enter link description here but I don't think I should specify paths to GRASS scripts as GRASS is launched successfully.

So, what steps should I take then to init GRASS from an empty folder GRASSDATA?

UPD: I added some path variables as proposes the example:

 export GISBASE=/usr/lib64/grass
 export PATH=$PATH:$GISBASE/bin:$GISBASE/scripts
 export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:$GISBASE/lib #(although I don't have such dir in grass dir..


 grass --text -c -e $EXTENT $GRASSDB/$GRASSLOC #(for this time I took a georeferenced file, not ESRI prj code, however it must be understood by grass.

And I got some errors again:

 Starting GRASS ...
 /usr/lib64/grass-6.4.4/etc/Init.sh: line 537: [: !=: unary operator expected
 basename: invalid option -- 'e'
 Try 'basename --help' for more information.
 dirname: invalid option -- 'e'
 Try 'dirname --help' for more information.
 GISDBASE, LOCATION_NAME and MAPSET variables not set properly.
 Interactive startup needed.

Here the extent file I use to create a location

UPD2: by editing -e to --e I return to the first error mentioned - grass starts a session, but doesn't create any location, and it sees working folder as possible but not existing location.

I looked at the Init.sh code: there is no flag like -e.

I have grass 6.4.4 ver. And please hold in mind that I don't have grass installed with conda, only installed with yum install grass!

UPD3: before Starting GRASS it wrote me:

WARNING: Searched for a web browser, but none found.

WELCOME TO GRASS              Version 6.4.4         2014

1) Have at your side all available GRASS GIS tutorials

2) When working on your location, the following materials
  are extremely useful:
  - A topographic map of your area
  - Current catalog of available computer maps

3) Check the GRASS GIS web pages for supporting mailing lists and more:

  Hit RETURN to continue

Not like on Micha's computer - Start GRASS and then immediately it created LOCATION

My last code was:

grass -text -c $EXTENT .$GISDBASE

where EXTENT is a path to extent.shp and GISDBASE is a name of DB folder

1 Answer 1


Creating a LOCATION is more than just the directory. That directory must contain certain files, created by GRASS that determine the coordinate reference system, computational region, etc. You can prepare this LOCATION directory from the CLI in two ways:

  1. using a EPSG code
  2. Use an existing, georeferenced spatial file

The ESRI code that you used is not recognized. On my system, I get:

Starting GRASS GIS...
Creating new GRASS GIS location <WGS84_Lambert>...
ERROR: b'ERROR 4: ESRI:102027: No such file or directory'
ERROR: Unable to read georeferenced file <ESRI:102027> using GDAL library

Do you have any georeferenced data set in that coord system? BTW, you do not create the directories in advance. The -c flag creates the LOCATION and PERMANENT subdirectories.

And also take note that the --text flag must be preceded by double dash '--'


Here's what I ran, using the shapefile that you linked. Seems to work fine

micha@RMS:Nikolai$ grass -c extent.shp ./Nikolai
Starting GRASS GIS...
Creating new GRASS GIS location <Nikolai>...
Cleaning up temporary files...

          __________  ___   __________    _______________
         / ____/ __ \/   | / ___/ ___/   / ____/  _/ ___/
        / / __/ /_/ / /| | \__ \\_  \   / / __ / / \__ \
       / /_/ / _, _/ ___ |___/ /__/ /  / /_/ // / ___/ /
       \____/_/ |_/_/  |_/____/____/   \____/___//____/

Welcome to GRASS GIS 8.2.1dev (1a04bca863)
GRASS GIS homepage:                      https://grass.osgeo.org
This version running through:            Bash Shell (/bin/bash)
Help is available with the command:      g.manual -i
See the licence terms with:              g.version -c
See citation options with:               g.version -x
Start the GUI with:                      g.gui wxpython
When ready to quit enter:                exit

micha@RMS:Nikolai$ g.proj -p
name       : Asia_North_Lambert_Conformal_Conic
datum      : wgs84
ellps      : wgs84
proj       : lcc
lat_0      : 30
lon_0      : 95
lat_1      : 15
lat_2      : 65
x_0        : 0
y_0        : 0
no_defs    : defined
SRID       : ESRI:102027
unit       : meter
units      : meters
meters     : 1
micha@RMS:Nikolai$ g.mapset -p

You can put any directory you want (I just used "Nikolai" in the current dir). Inside that directory GRASS creates the LOCATION and PERMANENT mapset.

  • It's strange. I must be understandable as EPSG too. It is: +proj=lcc +lat_0=30 +lon_0=95 +lat_1=15 +lat_2=65 +x_0=0 +y_0=0 +datum=WGS84 +units=m +no_defs So, I should or I shouldn't create folders before the location creation line? Jan 23, 2023 at 9:53
  • No, you don't create the folders by hand, the grass -c command takes care of that. And you can't use the proj4 string for defining a new LOCATION. Only an EPSG code, or a georeferenced spatial layer. (All software that uses GDAL, which is pretty much everything geospatial, is moving away from proj4 strings)
    – Micha
    Jan 23, 2023 at 11:12
  • But you see, I used a georeferenced shp file, but I still get the first error. It seems that grass gis doesn't even understand that I want it to create a new location within grassdata folder... Jan 23, 2023 at 12:41
  • See edit to the answer. (Sorry for misspelling your name :-)
    – Micha
    Jan 24, 2023 at 20:14
  • Thank you. It's very strange, but I used your command directly from that db folder exactly as you proposed. But it gives Starting GRASS ... The LOCATION "lena" does not exist. Please create it first Jan 26, 2023 at 12:49

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.