I want to turn rasters into vectors, what I think is called vectorization. However, I cannot find an otb_cli function that does simple vectorization (hopefully for large grids). I know that there is the tool LSMSVectorization, however this requires two input rasters, one with spectral signatures and one with a segmented image, output is a vector, i.e. shapefile.
So my question is: is there another possibility than using LSMSVectorization to turn a raster into a vector?
Hi !
What kind of image do you want to vectorize ?
LSMSVectorization is used to turn into polygons homogeneous areas of an image : it needs the input image to be segmented (all pixels of the neighbourhood have the same value).
You can have a look at the LSMSSegmentation application, or read the “segmentation” recipe in the Cookbook ([https://www.orfeo-toolbox.org/CookBook/recipes/improc.html#large-scale-mean-shift-lsms-segmentation]).
but my output looks like this! It seems that it only took one object and was done. I already changed the tilesize to 4, but then it takes awfully long and the output is a single rectangle but again not the desired output. Any thoughts?
Hi, I think the large scale vectorization tool will not work because all your foreground pixels have the same label. Can you try to convert this image to a new one, where each connected component has a unique id ?
Alternatively, you can give a try to otbcli_ConnectedComponentSegmentation
Hi,
I obtained some results by using the full large scale meanshift framework. As you already have a segmented image you do not need to worry about spatial and range smoothing.
During this processing each of your circle will become labelled disk (for getting real disk you might need to tune the parameters a bit or pre-processed your input), and thus the vectorisation will work fine.
Hope it helps! train4_v3.shp (3.0 MB)
I did not find any (quick) way to enumerate each segment. Seems not to be a standard task. CCS also failed because I am not sure how to use it correctly. The value of each pixel in each segment is 2, so I wanted to set the expression as “b1 = 2” but the error was"unexpected token “b1” found at position 1". When I use this code
I think one problem with the CCS is the unknown syntax. I initially wanted to the set the expression b1 = 2, so that he connects objects/pixels which are of value 2, but b1 is not recognized. Is there a better documentation of the syntax? In the cookbook I cannot find this info and in the software guide I cannot find the connected components
What does OBIA have as options? The only parameter I saw in the CCS example is SHAPE_Elongation, and CCS is the only cookbook page that has OBIA as a word (nothing in the software guide either). If you could hint me at the commands, I could also contribute to the cookbook with more examples.
indeed this worked! The output text while running showed several errors and the shapfile´s table got filled up with some nonsense info (-inf), but the polygons are there! Awesome and many thanks