1

I have a land use map in the format of TIFF. I imported this file as a table in PostGIS using raster2pgsql. The land use file has 7 different classes.

enter image description here

How can I select all those pixels that have the value (class) of 5? The table has only two columns (rid, rast).

  • What do you intend to do with the selection? Have you looked at this doc?: postgis.net/2014/09/26/tip_count_of_pixel_values – Aaron Aug 11 at 22:42
  • I want to select the areas that are lake or river. because in our problem we should avoid those areas. so I need the location of the pixels that have the value of 5. – milad Aug 12 at 2:47
  • I found ST_PixelOfValue() But it returns the number of row and column. I am searching for something that returns me those pixels in a resulting table, a function that clips those pixels with value of 5 and creates a coverage of those ones. – milad Aug 12 at 2:51
2

have you tried to polygonize you raster? then you can clip the original raster with the right polygon and you should be good!

  • Yes, It is a good idea, but I have a very big data set (for a province). I want to find the fastest way to do it. Actually, I want to find the lakes to import them as forbidden areas in the rest of the calculations. – milad Aug 12 at 15:49
1

You normally would ST_ReClass() the useless values of your raster to nodata (NULL). Then you can convert the withvalue pixel zones to polygons with ST_DumpAsPolygons() or you could intersect them with other polygons with ST_Clip() or ST_Intersection().

  • Thanks Pierre your solution is also interesting. I think it should work fast enough for my case. Milad Moradi – milad Aug 12 at 19:12

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.