```r
query1<-sprintf("select mhabitat,st_buffer(st_union(geom),0.1) geom 
from (%s) s group by mhabitat ",hh_habitat)
query2<-sprintf("select st_buffer(st_union(geom),50) geom 
from (%s) s",hh_paths)

query3<-sprintf("select mhabitat,st_difference(h.geom,p.geom) 
    geom from (%s) h, (%s) p",query1,query2)

dif<-st_read(conn,query=query3)
qtm(dif,"mhabitat") +tm_style("classic")
```

<img src="OS_GIS_files/figure-html/unnamed-chunk-89-1.png" width="672" />