create location from CLI

classic Classic list List threaded Threaded
12 messages Options
Reply | Threaded
Open this post in threaded view
|

create location from CLI

Dave Roberts
Dear All,

    I'm trying to understand the simplest way in GRASS7 to create a
location from the command line without using a georeferenced file.  So
far, it appears to be

% grass70 -c newLocation

at the OS prompt, followed by

GRASS GIS 7.0.4 > g.proc -c wkt=some WKT text file

inside of the new GRASS location (which temporarily has a generic XY
non-projection).   Two things:

1) I can't seem to coerce grass70 or g.proj to do this in a single step
from the OS command line (probably missing environment variables when
trying to go straight to g.proj from OS CLI).

2) I would prefer to use g.proj -c proj4=some PROJ4 string or file but I
can't seem to get g.proj to parse any proj4 strings either from stdin or
a file, even substituting the output from a g.proj -j command from a
working location.

GRASS 7.0.4

grass70 --config
x86_64-pc-linux-gnu
./configure  --prefix=/opt/grass
--with-freetype-includes=/usr/include/freetype2 --with-wxwidgets
--with-readline --with-pthread --with-netcdf --with-nls --with-geos
--with-postgres

uname -a
Linux luthertucker 4.6.4-1-ARCH #1 SMP PREEMPT Mon Jul 11 19:12:32 CEST
2016 x86_64 GNU/Linux

Thanks, Dave
--
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
David W. Roberts                                     office 406-994-4548
Professor and Head                                      FAX 406-994-3190
Department of Ecology                         email [hidden email]
Montana State University
Bozeman, MT 59717-3460
_______________________________________________
grass-user mailing list
[hidden email]
http://lists.osgeo.org/mailman/listinfo/grass-user
Reply | Threaded
Open this post in threaded view
|

Re: create location from CLI

Ken Mankoff

On 2016-09-06 at 13:21, Dave Roberts <[hidden email]> wrote:
> I'm trying to understand the simplest way in GRASS7 to create a
> location from the command line without using a georeferenced file. So
> far, it appears to be
>
> % grass70 -c newLocation
>
> at the OS prompt, followed by
>
> GRASS GIS 7.0.4 > g.proc -c wkt=some WKT text file

You say "without using a georeferenced file" but then use the WKTfile. Why not use that at the CLI?

grass70 -e -c WKTfile newLocation
grass70 ./newLocation/PERMANENT

I do it in two lines and use -e on the first so that if I run this again, and the location exists, it will still launch GRASS. If you just do the first line w/o -e, GRASS won't start if the location exists.

> I can't seem to get g.proj to parse any proj4 strings either from
> stdin or a file, even substituting the output from a g.proj -j command
> from a working location.

A MWE would help debugging.

  -k.
_______________________________________________
grass-user mailing list
[hidden email]
http://lists.osgeo.org/mailman/listinfo/grass-user
Reply | Threaded
Open this post in threaded view
|

Re: create location from CLI

Sajid Pareeth-2
In reply to this post by Dave Roberts
Hi

   I'm trying to understand the simplest way in GRASS7 to create a location from the command line without using a georeferenced file.  So far, it appears to be

% grass70 -c newLocation

Did you try parsing the EPSG code of the location you want to create?

For example:

grass71 -c epsg:3035 /home/user/grassdata/mynewlocation

The above command will create a new location in epsg 3035 projection.
You can find some details here:
https://grasswiki.osgeo.org/wiki/GRASS_Location_Wizard#GRASS_GIS_7:_Creating_locations_from_command_line


Best

Sajid

_______________________________________________
grass-user mailing list
[hidden email]
http://lists.osgeo.org/mailman/listinfo/grass-user
Reply | Threaded
Open this post in threaded view
|

Re: create location from CLI

Markus Neteler
On Tue, Sep 6, 2016 at 4:13 PM, Sajid Pareeth <[hidden email]> wrote:

>
> Hi
>>
>>
>>    I'm trying to understand the simplest way in GRASS7 to create a location from the command line without using a georeferenced file.  So far, it appears to be
>>
>> % grass70 -c newLocation
>
>
> Did you try parsing the EPSG code of the location you want to create?
>
> For example:
>
> grass71 -c epsg:3035 /home/user/grassdata/mynewlocation
>
> The above command will create a new location in epsg 3035 projection.

In GRASS GIS 7.2 you can even create and import in a single line,
using the new --exec magic:

mneteler@wernstrom ~ $ grass72 -c epsg:3035 ~/grassdata/newloc3035
--exec g.region -p
Cleaning up temporary files...
Creating new GRASS GIS location/mapset...
Executing <g.region -p> ...
projection: 99 (ETRS89 / LAEA Europe)
zone:       0
datum:      etrs89
ellipsoid:  grs80
north:      1
south:      0
west:       0
east:       1
nsres:      1
ewres:      1
rows:       1
cols:       1
cells:      1
Execution of <g.region -p> finished.
Cleaning up temporary files...
mneteler@wernstrom ~ $

Pretty powerful (instead of direct GRASS commands you can also specify
a script etc.).

See
https://grass.osgeo.org/grass72/manuals/grass7.html#examples

Markus

PS: Yes, we will release 7.2 soon but yet fixing some last minutes issues...
_______________________________________________
grass-user mailing list
[hidden email]
http://lists.osgeo.org/mailman/listinfo/grass-user
Reply | Threaded
Open this post in threaded view
|

Re: create location from CLI

Dave Roberts
In reply to this post by Ken Mankoff
Hi Ken, Hi Sajid,

    Thanks for the pointers.  I think my problem is that grass70 and
g.proj parse the files differently.  I.e.,

Here is file teste.prj

PROJCS["Lambert_Conformal_Conic",
     GEOGCS["GCS_WGS_1984",
         DATUM["D_WGS_1984",
             SPHEROID["WGS_1984",6378137,298.257223563]],
         PRIMEM["Greenwich",0],
         UNIT["Degree",0.017453292519943295]],
     PROJECTION["Lambert_Conformal_Conic"],
     PARAMETER["standard_parallel_1",40],
     PARAMETER["standard_parallel_2",45],
     PARAMETER["latitude_of_origin",0],
     PARAMETER["central_meridian",-109],
     PARAMETER["false_easting",0],
     PARAMETER["false_northing",0],
     UNIT["Meter",1]]

The following does not work

grass70 -e -c teste.prj teste
Creating new GRASS GIS location/mapset...
ERROR: ERROR 4: `teste.prj' not recognised as a supported
file format.

ERROR: Could not read georeferenced file teste.prj using either OGR nor
        GDAL

However, this does work

grass70 -c teste
g.proj -c wkt=teste.prj

    I'm having even worse luck with PROJ4 syntax of files.

Sajid, I have no problem getting EPSG specs to work, but that's a lttle
too indirect for the audience I'm trying to reach.

Thanks, Dave




On 09/06/16 08:12, Ken Mankoff wrote:

>
> On 2016-09-06 at 13:21, Dave Roberts <[hidden email]> wrote:
>> I'm trying to understand the simplest way in GRASS7 to create a
>> location from the command line without using a georeferenced file. So
>> far, it appears to be
>>
>> % grass70 -c newLocation
>>
>> at the OS prompt, followed by
>>
>> GRASS GIS 7.0.4 > g.proc -c wkt=some WKT text file
>
> You say "without using a georeferenced file" but then use the WKTfile. Why not use that at the CLI?
>
> grass70 -e -c WKTfile newLocation
> grass70 ./newLocation/PERMANENT
>
> I do it in two lines and use -e on the first so that if I run this again, and the location exists, it will still launch GRASS. If you just do the first line w/o -e, GRASS won't start if the location exists.
>
>> I can't seem to get g.proj to parse any proj4 strings either from
>> stdin or a file, even substituting the output from a g.proj -j command
>> from a working location.
>
> A MWE would help debugging.
>
>   -k.
>

--
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
David W. Roberts                                     office 406-994-4548
Professor and Head                                      FAX 406-994-3190
Department of Ecology                         email [hidden email]
Montana State University
Bozeman, MT 59717-3460
_______________________________________________
grass-user mailing list
[hidden email]
http://lists.osgeo.org/mailman/listinfo/grass-user
Reply | Threaded
Open this post in threaded view
|

Re: create location from CLI

Helmut Kudrnovsky
>ERROR: Could not read georeferenced file teste.prj using either OGR >nor
 >       GDAL

AFAIK the prj file holds the projection information, but the georeferenced file would be e.g. the related *.shp file.
best regards
Helmut
Reply | Threaded
Open this post in threaded view
|

Re: create location from CLI

Markus Neteler
In reply to this post by Dave Roberts

Hi,

On Sep 6, 2016 9:25 PM, "Dave Roberts" <[hidden email]> wrote:
>
> Hi Ken, Hi Sajid,
>
>    Thanks for the pointers.  I think my problem is that grass70 and g.proj parse the files differently.  I.e.,
>
> Here is file teste.prj
>
> PROJCS["Lambert_Conformal_Conic",
>     GEOGCS["GCS_WGS_1984",
>         DATUM["D_WGS_1984",
>             SPHEROID["WGS_1984",6378137,298.257223563]],
>         PRIMEM["Greenwich",0],
>         UNIT["Degree",0.017453292519943295]],
>     PROJECTION["Lambert_Conformal_Conic"],
>     PARAMETER["standard_parallel_1",40],
>     PARAMETER["standard_parallel_2",45],
>     PARAMETER["latitude_of_origin",0],
>     PARAMETER["central_meridian",-109],
>     PARAMETER["false_easting",0],
>     PARAMETER["false_northing",0],
>     UNIT["Meter",1]]
>
> The following does not work
>
> grass70 -e -c teste.prj teste
>
> Creating new GRASS GIS location/mapset...
> ERROR: ERROR 4: `teste.prj' not recognised as a supported
> file format.
>
> ERROR: Could not read georeferenced file teste.prj using either OGR nor
>        GDAL

Yes because it is not a raster or vector file.

> However, this does work
>
> grass70 -c teste
> g.proj -c wkt=teste.prj

This one is right.

>    I'm having even worse luck with PROJ4 syntax of files.

AFAIK that's only supported in g.proj.

Markus


_______________________________________________
grass-user mailing list
[hidden email]
http://lists.osgeo.org/mailman/listinfo/grass-user
Reply | Threaded
Open this post in threaded view
|

Re: create location from CLI

Dave Roberts
Thanks for clarification Markus, and thanks Helmut for similar input.
So, the last problem is that

g.proj -c proj4=-

followed by input to stdin works, but I cannot seem to construct a file
with proj4 parameters that g.proj will accept, even though identical
information entered at stdin works.  So, I'm still struggling for the
syntax of aproj4 file I guess.

Thanks all, Dave

On 09/06/16 14:37, Markus Neteler wrote:

> Hi,
>
> On Sep 6, 2016 9:25 PM, "Dave Roberts" <[hidden email]
> <mailto:[hidden email]>> wrote:
>>
>> Hi Ken, Hi Sajid,
>>
>>    Thanks for the pointers.  I think my problem is that grass70 and
> g.proj parse the files differently.  I.e.,
>>
>> Here is file teste.prj
>>
>> PROJCS["Lambert_Conformal_Conic",
>>     GEOGCS["GCS_WGS_1984",
>>         DATUM["D_WGS_1984",
>>             SPHEROID["WGS_1984",6378137,298.257223563]],
>>         PRIMEM["Greenwich",0],
>>         UNIT["Degree",0.017453292519943295]],
>>     PROJECTION["Lambert_Conformal_Conic"],
>>     PARAMETER["standard_parallel_1",40],
>>     PARAMETER["standard_parallel_2",45],
>>     PARAMETER["latitude_of_origin",0],
>>     PARAMETER["central_meridian",-109],
>>     PARAMETER["false_easting",0],
>>     PARAMETER["false_northing",0],
>>     UNIT["Meter",1]]
>>
>> The following does not work
>>
>> grass70 -e -c teste.prj teste
>>
>> Creating new GRASS GIS location/mapset...
>> ERROR: ERROR 4: `teste.prj' not recognised as a supported
>> file format.
>>
>> ERROR: Could not read georeferenced file teste.prj using either OGR nor
>>        GDAL
>
> Yes because it is not a raster or vector file.
>
>> However, this does work
>>
>> grass70 -c teste
>> g.proj -c wkt=teste.prj
>
> This one is right.
>
>>    I'm having even worse luck with PROJ4 syntax of files.
>
> AFAIK that's only supported in g.proj.
>
> Markus
>

--
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
David W. Roberts                                     office 406-994-4548
Professor and Head                                      FAX 406-994-3190
Department of Ecology                         email [hidden email]
Montana State University
Bozeman, MT 59717-3460
_______________________________________________
grass-user mailing list
[hidden email]
http://lists.osgeo.org/mailman/listinfo/grass-user
Reply | Threaded
Open this post in threaded view
|

Re: create location from CLI

Paul Kelly
On 09/06/2016 09:44 PM, Dave Roberts wrote:
> Thanks for clarification Markus, and thanks Helmut for similar input.
> So, the last problem is that
>
> g.proj -c proj4=-
>
> followed by input to stdin works, but I cannot seem to construct a file
> with proj4 parameters that g.proj will accept, even though identical
> information entered at stdin works.  So, I'm still struggling for the
> syntax of aproj4 file I guess.

The proj4 parameter in g.proj takes a PROJ string description, not a
file containing one.
So,
g.proj -c proj4="+proj=longlat +datum=WGS84"

should work, as far as I can think.

Paul
_______________________________________________
grass-user mailing list
[hidden email]
http://lists.osgeo.org/mailman/listinfo/grass-user
Reply | Threaded
Open this post in threaded view
|

Re: create location from CLI

Dave Roberts
Paul,

On 09/06/16 16:28, Paul Kelly wrote:

> The proj4 parameter in g.proj takes a PROJ string description, not a
> file containing one.
> So,
> g.proj -c proj4="+proj=longlat +datum=WGS84"
>
> should work, as far as I can think.
>

   Indeed it does, and that seems to be the end of the line.  So it's
possible to create an arbitrary locations with nothing but projection
information (no data yet), but it takes two lines of code.  That works
for me.  When I migrate to 7.2 apparently I can do it in one.

Thanks all, Dave



_______________________________________________
grass-user mailing list
[hidden email]
http://lists.osgeo.org/mailman/listinfo/grass-user
Reply | Threaded
Open this post in threaded view
|

Re: create location from CLI

Markus Neteler
In reply to this post by Paul Kelly
On Wed, Sep 7, 2016 at 12:28 AM, Paul Kelly
<[hidden email]> wrote:
...
> The proj4 parameter in g.proj takes a PROJ string description, not a file
> containing one.
> So,
> g.proj -c proj4="+proj=longlat +datum=WGS84"
>
> should work, as far as I can think.

BTW:
Are there reasons to not support proj4= also in the startup script "grass72"?

Markus
_______________________________________________
grass-user mailing list
[hidden email]
http://lists.osgeo.org/mailman/listinfo/grass-user
Reply | Threaded
Open this post in threaded view
|

Re: create location from CLI

wenzeslaus

On Wed, Sep 7, 2016 at 4:01 AM, Markus Neteler <[hidden email]> wrote:
BTW:
Are there reasons to not support proj4= also in the startup script "grass72"?


I don't think so. If somebody wants to look at it, this is the file to change (long, but you can ignore most of it for this project):

https://trac.osgeo.org/grass/browser/grass/trunk/lib/init/grass.py

Vaclav

_______________________________________________
grass-user mailing list
[hidden email]
http://lists.osgeo.org/mailman/listinfo/grass-user