1

I use a Raster, based on .png and .pgw file. (plans from a town)

The plans include information about where buildings are allowed to be built and maximum building height, ground elevation etc.

Now i need this information in a .csv file: Coordinates of building, max building height, elevation....

I already tried gdal2xyz, but it only results in a huge 1 GB file i cant open. I dont need all "sublayer", just a few.

Do I need a special plugin to handle this?

enter image description here

  • By sublayers do you mean raster bands or do you mean values within a band? Also CSV is a verbose text format so you should expect large files. Also - can you tell us what you are going to do with the CSV - there may be a better option. – MappaGnosis Mar 11 '19 at 15:04
  • Yes, by sublayer I mean raster bands, but QGIS says there is only one Channel when I do a rightclick and have a look on Information => Dimensions. That is confusing, because I see different bands in my Raster (=>Screenshot). The final result should be a map with the coordinates of the buildingareas and the maximum height it is allowed to build on that place, because there is an airport near this town. For this i need building coordinates and max height values, ground elevation etc. Thank you for your support :-) – Daniel_B Mar 11 '19 at 15:12
  • You see the different colours because your raster probably has a colour table associated with it. The "sub-bands" (1,2,3 etc in the TOC) are just pixel values and are all contained within the one band. I have a couple more questions: 1) when you say you want the building coordinates, is that the outline of the building footprint or a centroid; 2) If you need the outline, are the blue boundaries shown above sufficient? – MappaGnosis Mar 12 '19 at 8:08
  • The blue lines shown above are the building coordinates and yes, they are sufficient and I need them :-) – Daniel_B Mar 13 '19 at 9:09
1

Following our discussion above here is a workflow that should get you what you need. However, please bear in mind that I anticipate some bumps in the road because I can predict from the image above that one or two steps wont go smoothly - but I'll suggest steps to overcome that.

  1. We are only interested in the blue lines so get rid of everything else. Reclassify your raster using r.reclass or Reclassify by table from the Processing toolbox. Set all values of 3 (blue) to equal 1 and everything else to NoData.
  2. Here is your first 'gotcha'. Those little black lines will cause breaks in the blue which will cause us problems later on. You have a whole slew of options involving raster resolutions and statistical filter passes but I am going to suggest a very simple fix that, while not the quickest method, is robust and easy to understand.... so we'll move on for now...
  3. Convert your new raster to polygons. Given the width of the blue lines compared to the black, this will result in slim polygons that represent a fat, broken outline of each building (not exactly what we want but getting there).
  4. Buffer and then de-buffer (negative buffer distance) the polygons by the same amount, where that amount generously spans the gaps in the blue 'walls' created by those pesky black lines. Ensure you dissolve the results of the first buffer operation. The buffer-with-dissolve 'heals' the breaks in the walls and bridges the tiny gaps. De-buffering again, reduces the buildings back to the size they ought to be. This process also has the advantage of removing some of the jagginess that vectorizing a raster can result in - which is why it may ultimately prove as fast or faster than some of my raster-based solutions to the black lines mentioned above.
  5. You now have doughnuts of the correct external size representing your buildings. So, loose the holes by using Delete Holes from the Processing Toolbox.

That gives you a polygon vector file from which you can either derive centroids or use the whole geometry as required. Bear in mind, if the latter is what you want, the buffering operation adds extra vertices, especially at the corners. You can use Simplify to shed the extra verts and that may be beneficial (depending on your use-case).

You mention max building height and ground elevation - from the image presented, there is no obvious way of automatically deriving this. But if you can get another data source for the ground elevation (DTM). For the building heights - I suspect that there are probably blanket rules by zones, rather than individual properties. If so, I would overlay my new building polygons, add a new field for maxHeight and manually select groups of buildings - setting the height field for all in your selection in one go (saving some time over doing it building by building).

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.