Hi there,
I'm searching to create a road distance raster thanks to ocelet. It's possible to do that in QGIS but i'm searching to train myself with little problem like those.
In a first time, I'm only searching to create a 0-1 Raster indicating where roads are. I've succed to do that but I'm searching to mask my created raster thanks to a "working area" polygon in order to sort and use only cells that interact my working area. I also want to do this sorting before connecting my raster and my roads in order to optimize connection time.
It seem's that the problem come from Cell type and properties in ocelet. As i've seen cell Entities cannot be stored in List, it's seems dificult to me to sort them. Also there is maybe a way to remove cells from the "relation.allCellentities" List that I don't know...
Also I can says that the mask is working because of the "bool" variable/raster i created.
Thanks for your help
Here is the code,
scenario Neaw {
println("Model Neaw ready to run")
// resolution of the output raster
let resolution = 200.0
// my Datafacers
let rstExport = new RasterExport
let df_Mask = new DfMask
let df_Line = new DfLine
let myArea = df_Mask.readAll
let myRoad = df_Line.readAll
let myExtent = new MultiPolygon
for(i:myArea) myExtent = i.geom
println("Creating grid...")
//my future masked raster...
let lGrid = new List<ERast>
// creating a raster ...
let Pregrid = new Sigrid
Pregrid.createSquares(myExtent.getEnvelope,resolution,resolution)
println("Grid created!")
for(iregrid.allERast) i.bool = 0
rstExport.export(Pregrid.allERast,"output/Base.tif","EPSG:32620","line")
// Sorting the raster
let MaskGridRel = new MaskGrid
MaskGridRel.connect(Pregrid.allERast,myArea,resolution)
MaskGridRel.collectCell(lGrid)
rstExport.export(Pregrid.allERast,"output/bool.tif","EPSG:32620","bool")
// road raster relation
let RoadGridRel = new RoadGrid
RoadGridRel.connect(lGrid,myRoad)
RoadGridRel.setLine
// My final raster
rstExport.export(Pregrid.allERast,"output/RoadRast01.tif","EPSG:32620","line")
}
relation Sigrid <ERast r1, ERast r2> {}
relation MaskGrid<ERast rast, Mask mask>{
interaction collectCell(List<ERast> lRast){
rast.line = 0
rast.bool = 1
lRast.add(rast)
}
}
relation RoadGrid<ERast rast, Line line>{
interaction setLine(){
rast.line = 1
}
}
entity Mask{
property MultiPolygon geom
}
datafacer DfMask{
data Shapefile("data/Mask971ContOK.shp", "EPSG:32620")
match Mask{
geom : "geom"
}
}
entity Line{
property MultiLine geom
}
datafacer DfLine{
data Shapefile("data/971Road.shp", "EPSG:32620")
match Line{
geom : "geom"
}
}
entity ERast {
property Cell geom
// property Double dist
property Integer line
property Integer bool
}