Vector and raster information are the 2 foremost sorts of spatial information buildings. Vector information is nice for storing actual places and shapes, reminiscent of factors, traces, and polygons. In distinction, raster information fashions spatial options utilizing a grid of pixels, every storing explicit values. Completely different information sources and purposes yield completely different information buildings; nevertheless, when conducting superior spatial analytics, we frequently have to make these two differing types meet. On this article, I’ll give an instance of that — the right way to flip vector information, on this case, elevation traces, right into a raster of grid cells. Moreover, I present how this may be visualized by matching every raster grid cell to a small Lego brick.
All pictures created by the writer.
As a knowledge supply, I used the open information offered by the Budapest Open Information Atlas containing the elevation layers of town. After downloading the spatial information file, let’s take a look at it utilizing GeoPandas:
import geopandas as gpdgdf = gpd.read_file('bpelev.json')
print(len(gdf))
gdf.head(5)
The output of this cell: