Re: [Qgis-user] Raster to Vector without losing the symbology

2021-07-20 Thread Andy Harfoot

Hi Krishna,

It's hard to say what might be happening without seeing the data, but 
the issues with the union output may be due to invalid geometries being 
created by the polygonise. Check that the polygonise outputs are 
correctly capturing the band values and run them through the 'Check 
validity' tool.


If there are a lot of invalid polygons, then it will probably be easier 
to follow a raster approach such as outlined by Nicolas Cadieux, ie 
Raster Calculator: R * 100 + G * 1000 + B, followed by polygonise 
and then use an expression to extract the colour components again to 
colour the polygons.


Cheers,

Andy

On 19/07/2021 21:09, krishna Ayyala wrote:

*CAUTION:* This e-mail originated outside the University of Southampton.
Dear Andy,
Thanks for your reply. I did extract the image into three separate 
vectors using the Polygonize (Raster to vector) tool. I got three 
vector files which I named as Band1, Band2 and Band3. I did the union 
of Band1 and Band2 the result of which I named as "Band1_and_Band2". 
Again ran union tool with "Band1_and_Band2" and Band3. I named the 
result as Band1_and_Band2_and_Band3". This resultant vector file is 
not showing the entire area of the image. It is showing only part of 
the image. Lot of DN values for each band show null values.


Regards.

On Mon, Jul 19, 2021 at 7:40 AM Andy Harfoot > wrote:


Or extract the three bands into three separate vector files and
then union the three together to get the unique combinations of
RGB values.

Cheers,

Andy

On 18/07/2021 19:56, Nicolas Cadieux wrote:

*CAUTION:* This e-mail originated outside the University of
Southampton.
Hi,
You could create a style that could apply to both raster and
vector layers but that would not help much here.  The problem is
that you need to create the vector based on one of the raster
Bands and not all three.  One way could be to combine all three
fields into one.  If your RGB is 155 025 255, make this a raster
band with 155025255. Then, I guess you could use that 4th band to
make the vector layer, then resplit the data into 3 fields and
use that to create the colour profile.

Nicolas Cadieux
https://gitlab.com/njacadieux




Le 18 juill. 2021 à 12:51, krishna Ayyala
  a écrit :


I have an image on my qgis map that has 3 bands. Band1 (red),
Band2(green) and Band3(blue). This image has different colors.Is
it possible to convert this image into a vector which should
look exactly like the image.

That means; Is it possible to have the vector file that
should have the same colors as that of the image.

Regards.
___
Qgis-user mailing list
Qgis-user@lists.osgeo.org 
List info: https://lists.osgeo.org/mailman/listinfo/qgis-user


Unsubscribe: https://lists.osgeo.org/mailman/listinfo/qgis-user




___
Qgis-user mailing list
Qgis-user@lists.osgeo.org  
List info:https://lists.osgeo.org/mailman/listinfo/qgis-user  

Unsubscribe:https://lists.osgeo.org/mailman/listinfo/qgis-user  

Re: [Qgis-user] Raster to Vector without losing the symbology

2021-07-19 Thread Nicolas Cadieux

Hi,

I looked at your problem.  Indeed, using the Group Stat plugin, you will 
not be able to easily identify which polygon has the highest values.  
You can export a csv with the cross tabulation results but there is 
still no way to know which Polygon with the value A has highest value.


You can create a new field called "max" using the following expression.

maximum("Area",group_by:="Polygon")

That will giving you the highest value for each group.  Then, you can 
select polygon using the following expression


"Area" = "max"

Nicolas


On 2021-07-18 3:08 p.m., Nicolas Cadieux wrote:
Use the extract value by location to get the values from the point 
back into the vector grid…


Nicolas Cadieux
https://gitlab.com/njacadieux 

Le 18 juill. 2021 à 15:06, Nicolas Cadieux 
 a écrit :



Hi,

Another way is to create a vector grid with the same size and pixel 
posting as the original.  Then, get the centroids and use the point 
value tool to get the band values… This will give you a vector file 
but the file will be heavy. You could merge the vector grids after to 
merge values with similar values….


Ask yourself if you really need a vector file first.  This is not 
always the best file format for you data.


Nicolas Cadieux
https://gitlab.com/njacadieux 

Le 18 juill. 2021 à 14:56, Nicolas Cadieux 
 a écrit :


 Hi,
You could create a style that could apply to both raster and vector 
layers but that would not help much here.  The problem is that you 
need to create the vector based on one of the raster Bands and not 
all three.  One way could be to combine all three fields into one. 
 If your RGB is 155 025 255, make this a raster band with 155025255. 
Then, I guess you could use that 4th band to make the vector layer, 
then resplit the data into 3 fields and use that to create the 
colour profile.


Nicolas Cadieux
https://gitlab.com/njacadieux 

Le 18 juill. 2021 à 12:51, krishna Ayyala  
a écrit :



I have an image on my qgis map that has 3 bands. Band1 (red), 
Band2(green) and Band3(blue). This image has different colors.Is it 
possible to convert this image into a vector which should look 
exactly like the image.


That means; Is it possible to have the vector file that should have 
the same colors as that of the image.


Regards.
___
Qgis-user mailing list
Qgis-user@lists.osgeo.org
List info: https://lists.osgeo.org/mailman/listinfo/qgis-user
Unsubscribe: https://lists.osgeo.org/mailman/listinfo/qgis-user


--
Nicolas Cadieux
https://gitlab.com/njacadieux

___
Qgis-user mailing list
Qgis-user@lists.osgeo.org
List info: https://lists.osgeo.org/mailman/listinfo/qgis-user
Unsubscribe: https://lists.osgeo.org/mailman/listinfo/qgis-user


Re: [Qgis-user] Raster to Vector without losing the symbology

2021-07-19 Thread Craig Shelden
Krishna, 

Can you share a bit more about the raster image source file?  How discrete are 
the colors?

If there are only a few colors, then this workflow may meet the need, however 
kludged it may be.  

See if this approach helps... it worked for me with only a few colors... with 
more than a few, it would almost certainly fail.

Step 0 - determine how unique the colors are that you're working from...and how 
many there are.

Step 1 - take core RGB raster and split into three greyscale images... keep 
dimensions the same as the original and duplicate the world files for the core 
RGB raster so there's also a world file for each channel.

Step 2 - import the three greyscale images into QGIS.  

Step 3 = In Raster Calculator [1] extract each single R, G, xor B unique color 
value of interest into an output image 

Step 4 - Use Polygonize [2] on the output from step 3  ... AND also using Step 
# 3's output as a Screen under Polygonize's advanced options.  

Step 5 - apply the unique colors to the output.

Step 6 - Save the output shape file.

Repeat as needed.

This approach worked sufficiently well to take LIDAR-generated raster 
vegetation base maps from the mapping software OCAD [3] and convert those 
raster images to shape files for returning to OCAD as vectors and assignment to 
vegetation types.  Those shape files do get big... and over any substantive 
area, I can easily end up with > 150 K shapes in each file.

I set up a presentation file showing the approach using the QGIS graphical 
modeler [4] in a shared Google Drive, if you want to look it over.

Shortfalls and work arounds:: theoretically, I **think** the raster calculator 
should work on the original RGB source file, but I could never get it to work, 
so I tried the decompose-and-reassemble approach ...and it did work. ...and 
being lazy and busy, once I found a working approach I kept using it.

I'm sure it could be improved, but I don't use it often enough to warrant a 
hard scrub for optimization... and there are lots of other things to do while 
the graphical modeler runs through the hoops.

[1] Raster Calculator documentation page: 
https://docs.qgis.org/3.16/en/docs/user_manual/working_with_raster/raster_analysis.html#raster-calculator

[2] Polygonize documentation page:
https://docs.qgis.org/3.16/en/docs/user_manual/processing_algs/gdal/rasterconversion.html?highlight=polygonize#polygonize-raster-to-vector

[3] OCAD Home Page https://www.ocad.com/en/

[3] My efforts at creating shapes from rasters 
Filename: Creating_shapes_007.pdf 
 
https://drive.google.com/drive/folders/1y7OKQM3XNqrTMFEgj8YM5-4WSY0CAQnl?usp=sharing
 

Hope this helps.

All my best,
Craig

[Message trimmed]

> 
> 
> Today's Topics:
> 
>1. Re: Raster to Vector without losing the symbology (Andy Harfoot)
> 
> 
> --
> 
> Message: 1
> Date: Mon, 19 Jul 2021 14:40:06 +0100
> From: Andy Harfoot 
> To: qgis-user@lists.osgeo.org
> Subject: Re: [Qgis-user] Raster to Vector without losing the symbology

> 
> Or extract the three bands into three separate vector files and then 
> union the three together to get the unique combinations of RGB values.
> 
> Cheers,
> 
> Andy

> >
> >> Le 18 juill. 2021 ? 12:51, krishna Ayyala  a 
> >> ?crit?:
> >>
> >> ?
> >> I have an image on my qgis map that has 3 bands. Band1 (red), 
> >> Band2(green) and Band3(blue). This image has different?colors.Is it 
> >> possible to convert this image into a vector?which should look 
> >> exactly like the image.
> >>
> >> That means; Is it possible to have the vector file that should?have 
> >> the same colors as that of the image.
> >>
> >> Regards.
___
Qgis-user mailing list
Qgis-user@lists.osgeo.org
List info: https://lists.osgeo.org/mailman/listinfo/qgis-user
Unsubscribe: https://lists.osgeo.org/mailman/listinfo/qgis-user


Re: [Qgis-user] Raster to Vector without losing the symbology

2021-07-19 Thread Andy Harfoot
Or extract the three bands into three separate vector files and then 
union the three together to get the unique combinations of RGB values.


Cheers,

Andy

On 18/07/2021 19:56, Nicolas Cadieux wrote:

*CAUTION:* This e-mail originated outside the University of Southampton.
Hi,
You could create a style that could apply to both raster and vector 
layers but that would not help much here.  The problem is that you 
need to create the vector based on one of the raster Bands and not all 
three.  One way could be to combine all three fields into one.  If 
your RGB is 155 025 255, make this a raster band with 155025255. Then, 
I guess you could use that 4th band to make the vector layer, then 
resplit the data into 3 fields and use that to create the colour profile.


Nicolas Cadieux
https://gitlab.com/njacadieux 



Le 18 juill. 2021 à 12:51, krishna Ayyala  a 
écrit :



I have an image on my qgis map that has 3 bands. Band1 (red), 
Band2(green) and Band3(blue). This image has different colors.Is it 
possible to convert this image into a vector which should look 
exactly like the image.


That means; Is it possible to have the vector file that should have 
the same colors as that of the image.


Regards.
___
Qgis-user mailing list
Qgis-user@lists.osgeo.org
List info: https://lists.osgeo.org/mailman/listinfo/qgis-user
Unsubscribe: https://lists.osgeo.org/mailman/listinfo/qgis-user


___
Qgis-user mailing list
Qgis-user@lists.osgeo.org
List info: https://lists.osgeo.org/mailman/listinfo/qgis-user
Unsubscribe: https://lists.osgeo.org/mailman/listinfo/qgis-user


--
Andy Harfoot

Skype: gdi_ajph
Teams: a...@soton.ac.uk

GeoData Institute
University of Southampton
Southampton
SO17 1BJ

www.geodata.soton.ac.uk

___
Qgis-user mailing list
Qgis-user@lists.osgeo.org
List info: https://lists.osgeo.org/mailman/listinfo/qgis-user
Unsubscribe: https://lists.osgeo.org/mailman/listinfo/qgis-user


Re: [Qgis-user] Raster to Vector without losing the symbology

2021-07-18 Thread Nicolas Cadieux
Use the extract value by location to get the values from the point back into 
the vector grid…

Nicolas Cadieux
https://gitlab.com/njacadieux

> Le 18 juill. 2021 à 15:06, Nicolas Cadieux  a 
> écrit :
> 
> 
> Hi,
> 
> Another way is to create a vector grid with the same size and pixel posting 
> as the original.  Then, get the centroids and use the point value tool to get 
> the band values… This will give you a vector file but the file will be heavy. 
> You could merge the vector grids after to merge values with similar values…. 
> 
> Ask yourself if you really need a vector file first.  This is not always the 
> best file format for you data.
> 
> Nicolas Cadieux
> https://gitlab.com/njacadieux
> 
>>> Le 18 juill. 2021 à 14:56, Nicolas Cadieux  a 
>>> écrit :
>>> 
>> Hi,
>> You could create a style that could apply to both raster and vector layers 
>> but that would not help much here.  The problem is that you need to create 
>> the vector based on one of the raster Bands and not all three.  One way 
>> could be to combine all three fields into one.  If your RGB is 155 025 255, 
>> make this a raster band with 155025255. Then, I guess you could use that 4th 
>> band to make the vector layer, then resplit the data into 3 fields and use 
>> that to create the colour profile.
>> 
>> Nicolas Cadieux
>> https://gitlab.com/njacadieux
>> 
 Le 18 juill. 2021 à 12:51, krishna Ayyala  a 
 écrit :
 
>>> 
>>> I have an image on my qgis map that has 3 bands. Band1 (red), Band2(green) 
>>> and Band3(blue). This image has different colors.Is it possible to convert 
>>> this image into a vector which should look exactly like the image. 
>>> 
>>> That means; Is it possible to have the vector file that should have the 
>>> same colors as that of the image.
>>> 
>>> Regards.
>>> ___
>>> Qgis-user mailing list
>>> Qgis-user@lists.osgeo.org
>>> List info: https://lists.osgeo.org/mailman/listinfo/qgis-user
>>> Unsubscribe: https://lists.osgeo.org/mailman/listinfo/qgis-user
___
Qgis-user mailing list
Qgis-user@lists.osgeo.org
List info: https://lists.osgeo.org/mailman/listinfo/qgis-user
Unsubscribe: https://lists.osgeo.org/mailman/listinfo/qgis-user


Re: [Qgis-user] Raster to Vector without losing the symbology

2021-07-18 Thread Nicolas Cadieux
Hi,

Another way is to create a vector grid with the same size and pixel posting as 
the original.  Then, get the centroids and use the point value tool to get the 
band values… This will give you a vector file but the file will be heavy. You 
could merge the vector grids after to merge values with similar values…. 

Ask yourself if you really need a vector file first.  This is not always the 
best file format for you data.

Nicolas Cadieux
https://gitlab.com/njacadieux

> Le 18 juill. 2021 à 14:56, Nicolas Cadieux  a 
> écrit :
> 
> Hi,
> You could create a style that could apply to both raster and vector layers 
> but that would not help much here.  The problem is that you need to create 
> the vector based on one of the raster Bands and not all three.  One way could 
> be to combine all three fields into one.  If your RGB is 155 025 255, make 
> this a raster band with 155025255. Then, I guess you could use that 4th band 
> to make the vector layer, then resplit the data into 3 fields and use that to 
> create the colour profile.
> 
> Nicolas Cadieux
> https://gitlab.com/njacadieux
> 
>>> Le 18 juill. 2021 à 12:51, krishna Ayyala  a écrit 
>>> :
>>> 
>> 
>> I have an image on my qgis map that has 3 bands. Band1 (red), Band2(green) 
>> and Band3(blue). This image has different colors.Is it possible to convert 
>> this image into a vector which should look exactly like the image. 
>> 
>> That means; Is it possible to have the vector file that should have the same 
>> colors as that of the image.
>> 
>> Regards.
>> ___
>> Qgis-user mailing list
>> Qgis-user@lists.osgeo.org
>> List info: https://lists.osgeo.org/mailman/listinfo/qgis-user
>> Unsubscribe: https://lists.osgeo.org/mailman/listinfo/qgis-user
___
Qgis-user mailing list
Qgis-user@lists.osgeo.org
List info: https://lists.osgeo.org/mailman/listinfo/qgis-user
Unsubscribe: https://lists.osgeo.org/mailman/listinfo/qgis-user


Re: [Qgis-user] Raster to Vector without losing the symbology

2021-07-18 Thread Nicolas Cadieux
Hi,
You could create a style that could apply to both raster and vector layers but 
that would not help much here.  The problem is that you need to create the 
vector based on one of the raster Bands and not all three.  One way could be to 
combine all three fields into one.  If your RGB is 155 025 255, make this a 
raster band with 155025255. Then, I guess you could use that 4th band to make 
the vector layer, then resplit the data into 3 fields and use that to create 
the colour profile.

Nicolas Cadieux
https://gitlab.com/njacadieux

> Le 18 juill. 2021 à 12:51, krishna Ayyala  a écrit :
> 
> 
> I have an image on my qgis map that has 3 bands. Band1 (red), Band2(green) 
> and Band3(blue). This image has different colors.Is it possible to convert 
> this image into a vector which should look exactly like the image. 
> 
> That means; Is it possible to have the vector file that should have the same 
> colors as that of the image.
> 
> Regards.
> ___
> Qgis-user mailing list
> Qgis-user@lists.osgeo.org
> List info: https://lists.osgeo.org/mailman/listinfo/qgis-user
> Unsubscribe: https://lists.osgeo.org/mailman/listinfo/qgis-user
___
Qgis-user mailing list
Qgis-user@lists.osgeo.org
List info: https://lists.osgeo.org/mailman/listinfo/qgis-user
Unsubscribe: https://lists.osgeo.org/mailman/listinfo/qgis-user


[Qgis-user] Raster to Vector without losing the symbology

2021-07-18 Thread krishna Ayyala
I have an image on my qgis map that has 3 bands. Band1 (red), Band2(green)
and Band3(blue). This image has different colors.Is it possible to convert
this image into a vector which should look exactly like the image.

That means; Is it possible to have the vector file that should have the
same colors as that of the image.

Regards.
___
Qgis-user mailing list
Qgis-user@lists.osgeo.org
List info: https://lists.osgeo.org/mailman/listinfo/qgis-user
Unsubscribe: https://lists.osgeo.org/mailman/listinfo/qgis-user