Tiling Objects

Splitting a raster into 4 quadrants

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
# Splits a raster into 4 equally sized tiles
version(1.0);

# Change the directory below to correspond to your file location.
baseDir = "c:/Program Files/LandSerf/data/landscriptExamples/";

# Open a raster map to split.
raster = open(baseDir&"topoMap.srf");

# Create four new empty rasters.
midEasting  = info(raster,"w")+(info(raster,"e")-info(raster,"w"))/2;
midNorthing = info(raster,"s")+(info(raster,"n")-info(raster,"s"))/2;

nw = newraster(info(raster,"w"),midNorthing,
               info(raster,"xRes"),info(raster,"yRes"),
               info(raster,"numRows")/2,info(raster,"numCols")/2);
ne = newraster(midEasting,midNorthing,
               info(raster,"xRes"),info(raster,"yRes"),
               info(raster,"numRows")/2,info(raster,"numCols")/2);
sw = newraster(info(raster,"w"),info(raster,"s"),
               info(raster,"xRes"),info(raster,"yRes"),
               info(raster,"numRows")/2,info(raster,"numCols")/2);
se = newraster(midEasting,info(raster,"s"),
               info(raster,"xRes"),info(raster,"yRes"),
               info(raster,"numRows")/2,info(raster,"numCols")/2);

# Cookie-cut the original raster with the new quadrant rasters.
nw = combine(raster_,nw_,"intersection");
edit(nw,"title","NW quadrant of "&info(raster,"title"));
ne = combine(raster_,ne_,"intersection");
edit(ne,"title","NE quadrant of "&info(raster,"title"));
sw = combine(raster_,sw_,"intersection");
edit(sw,"title","SW quadrant of "&info(raster,"title"));
se = combine(raster_,se_,"intersection");
edit(se,"title","SE quadrant of "&info(raster,"title"));

# Save the new quadrants
save(nw,baseDir&"topoMapNW.srf");
save(ne,baseDir&"topoMapNE.srf");
save(sw,baseDir&"topoMapSW.srf");
save(se,baseDir&"topoMapSE.srf");

Combining 4 quadrants into a new raster

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
# Combines 4 tiled rasters into a single raster map.
version(1.0);

# Change the directory below to correspond to your file location.
baseDir = "c:/Program Files/LandSerf/data/landscriptExamples/";

# Start with one of the tiled rasters.
bigRaster = open(baseDir&"topoMapNW.srf");

# Combine each of the tiled rasters with the main raster.
tile = open(baseDir&"topoMapNE.srf");
bigRaster = combine(bigRaster_,tile_);

tile = open(baseDir&"topoMapSE.srf");
bigRaster = combine(bigRaster_,tile_);

tile = open(baseDir&"topoMapSW.srf");
bigRaster = combine(bigRaster_,tile_);

# Save the newly combined raster
save(bigRaster,baseDir&"topoMapCombined.srf");