Take the 2-minute tour ×
Geographic Information Systems Stack Exchange is a question and answer site for cartographers, geographers and GIS professionals. It's 100% free, no registration required.

I have a map based web application using geodjango. I needed to display the crime hotspots within a selected polygon area. I found that v.kernel is very good for generating heatmaps/hotspots. So in my application I ran this command through python subprocess and created the raster map showing point density. I displayed this raster map over the polygon area in grass. But when I try to run the command through python using d.out.file command, error is raised.

command5 = "d.mon start=x1" 
command6 = "d.mon select=x1"
command7 = "d.mon unlock=x1"
command8 = "r.colors byr"
command9 = "d.rast crimes_"+str(pname)
command10 = "d.vect "+str(pname)+" type=line,boundary"
command11 = "d.out.file output="+str(pname)+" format=png size=800,600"
command12 = "d.mon stop=x1"

saveCommands = [command4,command5,command6,command7]

for sc in saveCommands:
    s = subprocess.Popen(sc,shell=True,env=environ) 
    s.wait()

Error is :

ERROR: Graph_Set: can't open Display
ERROR: Unable to get GIS_LOCK enviroment variable value
Problem selecting x1. Will try once more
ERROR: Unable to get GIS_LOCK enviroment variable value
d.mon select=x1
Exception AttributeError: AttributeError("'_DummyThread' object has no attribute '_Thread__block'",) in <module 'threading' from '/usr/lib/python2.7/threading.pyc'> ignored
ERROR: Unable to get GIS_LOCK enviroment variable value

All I need is to export the grass vector and raster layer to an image.

share|improve this question
    
command4 is included in saveCommands but not shown in the example. –  steko Mar 8 '13 at 11:05
    
Hi I have added environ['GIS_LOCK'] = '.gislock' before running subprocess but same error persists... –  user12757 Mar 13 '13 at 10:56
add comment

2 Answers 2

The error is likely occurring in your command6.

To solve the specific error, you could set the GIS_LOCK environment variable and add it to the environ before it is passed to subprocess.Popen.

environ['GIS_LOCK'] = 'default' # any value should do
share|improve this answer
    
Hi I have added environ['GIS_LOCK'] = '.gislock' before running subprocess but same error persists... –  user12757 Mar 13 '13 at 10:59
add comment

Are you sure that you can open a X11 display in a Python process like this. In your case, better use the PNG driver:

d.mon start=PNG
...

See also this manual page: http://grass.osgeo.org/grass64/manuals/pngdriver.html

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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