uDALES / u-dales

uDALES: large-eddy-simulation software for urban flow, dispersion and microclimate modelling
https://udales.github.io/u-dales
GNU General Public License v3.0
47 stars 16 forks source link

How can I generate 2D array of building heights for uDALES (blocks.inp) from a 2-D grid ASCII file? #142

Closed wimvanderbauwhede closed 3 years ago

wimvanderbauwhede commented 3 years ago

Hi, this is more a question for my own needs than a criticism of your work. My GIS data are in an ASCII file consisting of one float per line which represents the heigh of a square in a fixed regular 2-D grid. Do you provide a way to convert this to the blocks.inp format? I could of course generate a fake LIDAR image from my data but that seems rather roundabout.

tomgrylls commented 3 years ago

Hi, could you post an example line of the ASCII file?

We currently support a couple of ASCII file formats in the preprocessing (https://github.com/uDALES/u-dales/blob/joss-paper/docs/udales-pre-processing.md). Generally, one needs to generate a 2D array of building heights when unsupported file formats are the starting point (this can be either an image or an ASCII file ltxtblocks). Therefore some (pre-)pre-processing work may be needed in this case. There is certainly scope for supporting more file types where multiple users have the same requirements. The modularity of the pre-processing routines should make this easy to build in where helpful.

wimvanderbauwhede commented 3 years ago

It's just one float per line, for example:

39.9020538 27.9513283 ...

I have file e.g. representing a 2kmx2km part of a Tokyo with 20 m resolution, it simply consists of 10,000 lines like the above.

tomgrylls commented 3 years ago

Apologies for the slow response, I am no longer working on this. Two options to do this as I mentioned above:

1) a) reshape the 1D file into a 2D array, b) clip the file to the area that you want to model, c) set the lowest height (ground) to zero, d) divide by the resolution in the z-direction (assuming constant grid size), e) round to the nearest integer. You will then have a 2D array of the heights of the buildings in number of cells in the z-direction. f) Save that as a .txt file, g) use ltxtblocks in preprocessing to read the file into uDALES. Note this assumes the grid also has a 20 m x- and y-resolution - if not some interpolation or extrapolation is required.

2) a) reshape the 1D file into a 2D array, b) set the lowest height (ground) to zero, c) divide by the maximum building height, d) convert this to a grey-scale RGB file, e.g. PNG, where the colour scales from 0 [255,255,255] to max height [0,0,0]. You can then use llidar in the preprocessing. Ensure to set maxh, dxinp, dyinp, dzinp etc. You also use inputs centeri, centerj to define what part of your file you are interested in modelling. Note this preprocessing routine does some additional processing to ensure the morphology satisfies fundamental rules for urban modelling, e.g. sets a filter size for the smallest possible obstacles, and it enables different grid sizes etc. to be modelled using the same inout file.

From a quick look through, potentially detailed instructions on the above are missing from the documentation. But I think we do use these in the examples. I will check on this.

wimvanderbauwhede commented 3 years ago

Thank you!