[GRASS-dev] Python: core.create_location() available but core.create_mapset() yet missing

Hi,

would it be possible to also add a convenient core.create_mapset() function?
The code already exists:

gui/wxpython/gis_set.py line 858:

def CreateNewMapset(self, mapset):
....

This would help folks who want to batch-process data and appears to be
the missing piece to completely generate a new location in the Python
way.

thanks
Markus

PS: since it is wxGUI code I hesitate to modify it myself

On Tue, May 6, 2014 at 12:02 AM, Markus Neteler <neteler@osgeo.org> wrote:

Hi,

would it be possible to also add a convenient core.create_mapset() function?
The code already exists:

gui/wxpython/gis_set.py line 858:

def CreateNewMapset(self, mapset):
....

This would help folks who want to batch-process data and appears to be
the missing piece to completely generate a new location in the Python
way.

Is it possible, that create_location() only works *within* a GRASS session?

How would I generate a location in Python when not having the location
yet created but only a SHAPE/.prj file available or a GeoTIFF?
Seems I am overlooking something. Pointers welcome!

Markus

HI,

attached a new attempt to generate a new location within a Python
script (goal: batch processing).

All fine except for the fact that GRASS 7 started with -c ... creates
a location but then actually *starts* the session rather than
returning.

How to overcome this issue?

thanks
Markus

(attachments)

start_grass7_create_new_location.py (960 Bytes)

Markus Neteler wrote:

> This would help folks who want to batch-process data and appears to be
> the missing piece to completely generate a new location in the Python
> way.

Is it possible, that create_location() only works *within* a GRASS session?

If you're not within a GRASS session, I wouldn't assume that Python
can even find the grass.script.core package. Or the libraries, or
modules, or anything else.

How would I generate a location in Python when not having the location
yet created but only a SHAPE/.prj file available or a GeoTIFF?
Seems I am overlooking something. Pointers welcome!

IMHO, the logical approach is to start a GRASS session with a dummy
database, location and mapset, create the new database, location
and/or mapset, then switch to it with g.mapset.

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

On Tue, May 6, 2014 at 10:21 PM, Glynn Clements
<glynn@gclements.plus.com> wrote:
...

IMHO, the logical approach is to start a GRASS session with a dummy
database, location and mapset, create the new database, location
and/or mapset, then switch to it with g.mapset.

Agreed.
This should ideally be offered as a Python (wrapper) function.
Meanwhile I found that also the startup script contains a create_new()
location function.

Markus