[GRASS-dev] WARNING: No data base element files found
Paulo van Breugel
p.vanbreugel at gmail.com
Tue Mar 22 07:02:28 PDT 2016
On 22-03-16 14:19, Anna Petrášová wrote:
> On Tue, Mar 22, 2016 at 7:22 AM, Paulo van Breugel
> <p.vanbreugel at gmail.com> wrote:
>> On 22-03-16 10:59, Markus Neteler wrote:
>>> On Mon, Mar 21, 2016 at 11:41 AM, Moritz Lennert
>>> <mlennert at club.worldonline.be> wrote:
>>>> On 21/03/16 11:38, Paulo van Breugel wrote:
>>>>> "WARNING: No data base element files found"
>>>> In my experience it comes from a g.remove call that tries to remove a
>>>> that doesn't exist. So generally, testing for its existence before
>>>> avoids the warning.
>>> Also i.colors.enhance suffers from that.
>>> Do we have any "best practice" example for that in an existing core
>> Would be good to have a 'best practice' example. I have used before
>> something like:
>> rast = 'my_raster'
>> cf = grass.find_file(name=rast, element = 'cell',
>> if not cf['fullname'] == '':
>> grass.run_command("g.remove", type="raster", name=rast, quiet=True)
>> But I guess there are better ways to do this?
> Best practice is just to not remove layers which don't exist. So don't
> remove the temporary maps inside the script, but rather inside the
> registered cleanup procedure which is called every time. The temporary
> maps should be added to a global list as they are used, so when you
> interrupt the script in the middle only the already created temporary
> maps will be deleted.
That is what I am doing now, using atexit.register(). But if a script
generates a very large number of layers, it might be worthwhile removing
them in between to save disk space (I recently had to such a case at
hand, where keeping the intermediate layers would have taken up too much
space). But generally yes, following the cleanup procedure makes
absolutely more sense. In the script I referred to in the initial email,
I used both because at the time of writing the script, I misunderstood
the working of atexit.register().
>> P.s. in the find_file example above, is it sufficient to use as 'element'
>> 'cell', i.e., does that also find fcell and cellhd layers?
> All of 'raster', 'rast', 'cell' will find raster maps (of all
> types),not sure what do you mean with cellhd layer.
I was looking at the possible element types for the find_file function
at https://grass.osgeo.org/programming7/find__file_8c.html, and cellhd
was mentioned as one possible element type (I couldn't find a list
though of all possible database elements)
>> grass-dev mailing list
>> grass-dev at lists.osgeo.org
More information about the grass-dev