Create a Voxel¶
GeoLime Voxel are regular grid and can be in 2D, 3D or 4D. They are created using an origin, the number of cell in each direction and the directional vector of the cell size in each axis. The origin correspond to the location of the node of the block. In other cases Voxel coordinates represent the block centroids.
In [1]:
Copied!
import geolime as geo
from pyproj import CRS
import geolime as geo
from pyproj import CRS
2D Voxel¶
The following command creates a 2D grids of 75 cells in X direction and 150 cells in Y direction. Cells are squared with an X and Y cellsize of 50 meters.
In [3]:
Copied!
grid = geo.Voxel(
name="2DGrid",
shape=[75, 150],
origin=[545400, 7472700, 430],
axis=[[50, 0, 0], [0, 50, 0]]
)
grid = geo.Voxel(
name="2DGrid",
shape=[75, 150],
origin=[545400, 7472700, 430],
axis=[[50, 0, 0], [0, 50, 0]]
)
In [4]:
Copied!
grid.element_count()
grid.element_count()
Out[4]:
11250
In [5]:
Copied!
grid.set_property_expr(name="XY", expr="sin(X / 2) * sin (Y / 2)")
grid.set_property_expr(name="XY", expr="sin(X / 2) * sin (Y / 2)")
In [6]:
Copied!
geo.plot(grid, property="XY", agg_method="mean", width=400, height=650)
geo.plot(grid, property="XY", agg_method="mean", width=400, height=650)
3D Voxel¶
The following command creates a 3D grids of 75 cells in X direction, 150 cells in Y direction and 5 cells in Z directions. Cells are parallelepipedic with an X and Y cellsize of 50 meters and a Z cellsize of 20 meters.
Creation of a meaningless property for plotting purpose.
In [8]:
Copied!
grid.set_property_expr(name="XY", expr="sin(X / 2) * sin (Y / 2)")
grid.set_property_expr(name="XY", expr="sin(X / 2) * sin (Y / 2)")
In [9]:
Copied!
geo.plot(grid, property="XY", agg_method="mean", width=400, height=650)
geo.plot(grid, property="XY", agg_method="mean", width=400, height=650)
In [10]:
Copied!
geo.plot_2d(
grid,
property="XY",
agg_method="mean",
crs=CRS('EPSG:20350'),
width=650,
height=650,
mapbox_zoom=12
)
geo.plot_2d(
grid,
property="XY",
agg_method="mean",
crs=CRS('EPSG:20350'),
width=650,
height=650,
mapbox_zoom=12
)