Coloring points by raster values in QGIS?Creating color tables for floating point raster maps in GDAL?Wrong values in Feature/Point to RasterHow to normalize multiple PNG rasters with differing colormapsextract shapefile attributes from raster colorsExtract all unique values from a RGB rasterStyle points using color gradients with QGISCalculating Distance from Vector Point to Raster PointsExtracting Spatial Points that match Raster Value using R?R: Display single band raster in true colorGeoServer: colormap for point data

Word for giving preference to the oldest child

Are some indefinite integrals impossible to compute or just don't exist?

If I buy and download a game through second Nintendo account do I own it on my main account too?

Why have both: BJT and FET transistors on IC output?

What is the most 'environmentally friendly' way to learn to fly?

Why don't short runways use ramps for takeoff?

How to gracefully excuse yourself from a meeting due to emergencies such as a restroom break?

How to define a functional that produces at runtime a function by evaluating selected parts in its definition?

Skipping same old introductions

Should 2FA be enabled on service accounts?

Is Norway in the Single Market?

Why should I use a big powerstone instead of smaller ones?

Can machine learning learn a function like finding maximum from a list?

Is the EU really banning "toxic propellants" in 2020? How is that going to work?

Backpacking with incontinence

How to prevent a single-element caster from being useless against immune foes?

The grades of the students in a class

Can black block with a hanging piece in a back rank mate situation?

Feedback diagram

A coworker mumbles to herself when working. How can I ask her to stop?

Best Ergonomic Design for a handheld ranged weapon

Does the Oath of Redemption paladin's Emissary of Peace feature reflect damage taken as a result of the Aura of the Guardian feature?

Does the problem of P vs NP come under the category of Operational Research?

Can I shorten this filter, that finds disk sizes over 100G?



Coloring points by raster values in QGIS?


Creating color tables for floating point raster maps in GDAL?Wrong values in Feature/Point to RasterHow to normalize multiple PNG rasters with differing colormapsextract shapefile attributes from raster colorsExtract all unique values from a RGB rasterStyle points using color gradients with QGISCalculating Distance from Vector Point to Raster PointsExtracting Spatial Points that match Raster Value using R?R: Display single band raster in true colorGeoServer: colormap for point data






.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty margin-bottom:0;








4















While it's simple to color a point shapefile by an attribute field, I can't figure out how to match the colors with those from a raster.



I have a raster file that I'm displaying with a continuous colormap, with values clipped between -5 and 5. Using 5 colors results in colors -5, 2.5 0, 2.5 and 5.
I'm forced to use the singleband_pseudocolor symbology so that I can clip the values.



The values in my point shapefile are all negative, between -0.5 and -2.3.
I want to match the colors to the 5 colors in the colormap, but the colormaps will only reflect the values in the point shapefile.



I've tried saving/applying the colormap of the raster file, and manually adding extra points to match my limits; the former does nothing and the latter causes the endpoints to mismatch so there is one less color than there should be. I've also tried to rasterize the points but this isn't working at all.



I'm doing this in QGIS and can attach screen shots if necessary.



raster styling



point styling










share|improve this question


























  • Can you add a screenshot of the style panel for the raster, and one of the style panel for the point shapefile? I have a couple workarounds in mind but it would help to see what settings and color ramps you're using.

    – csk
    Jul 23 at 15:26

















4















While it's simple to color a point shapefile by an attribute field, I can't figure out how to match the colors with those from a raster.



I have a raster file that I'm displaying with a continuous colormap, with values clipped between -5 and 5. Using 5 colors results in colors -5, 2.5 0, 2.5 and 5.
I'm forced to use the singleband_pseudocolor symbology so that I can clip the values.



The values in my point shapefile are all negative, between -0.5 and -2.3.
I want to match the colors to the 5 colors in the colormap, but the colormaps will only reflect the values in the point shapefile.



I've tried saving/applying the colormap of the raster file, and manually adding extra points to match my limits; the former does nothing and the latter causes the endpoints to mismatch so there is one less color than there should be. I've also tried to rasterize the points but this isn't working at all.



I'm doing this in QGIS and can attach screen shots if necessary.



raster styling



point styling










share|improve this question


























  • Can you add a screenshot of the style panel for the raster, and one of the style panel for the point shapefile? I have a couple workarounds in mind but it would help to see what settings and color ramps you're using.

    – csk
    Jul 23 at 15:26













4












4








4


1






While it's simple to color a point shapefile by an attribute field, I can't figure out how to match the colors with those from a raster.



I have a raster file that I'm displaying with a continuous colormap, with values clipped between -5 and 5. Using 5 colors results in colors -5, 2.5 0, 2.5 and 5.
I'm forced to use the singleband_pseudocolor symbology so that I can clip the values.



The values in my point shapefile are all negative, between -0.5 and -2.3.
I want to match the colors to the 5 colors in the colormap, but the colormaps will only reflect the values in the point shapefile.



I've tried saving/applying the colormap of the raster file, and manually adding extra points to match my limits; the former does nothing and the latter causes the endpoints to mismatch so there is one less color than there should be. I've also tried to rasterize the points but this isn't working at all.



I'm doing this in QGIS and can attach screen shots if necessary.



raster styling



point styling










share|improve this question
















While it's simple to color a point shapefile by an attribute field, I can't figure out how to match the colors with those from a raster.



I have a raster file that I'm displaying with a continuous colormap, with values clipped between -5 and 5. Using 5 colors results in colors -5, 2.5 0, 2.5 and 5.
I'm forced to use the singleband_pseudocolor symbology so that I can clip the values.



The values in my point shapefile are all negative, between -0.5 and -2.3.
I want to match the colors to the 5 colors in the colormap, but the colormaps will only reflect the values in the point shapefile.



I've tried saving/applying the colormap of the raster file, and manually adding extra points to match my limits; the former does nothing and the latter causes the endpoints to mismatch so there is one less color than there should be. I've also tried to rasterize the points but this isn't working at all.



I'm doing this in QGIS and can attach screen shots if necessary.



raster styling



point styling







qgis raster point






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited Jul 23 at 16:08







bbuzz31

















asked Jul 23 at 1:22









bbuzz31bbuzz31

607 bronze badges




607 bronze badges















  • Can you add a screenshot of the style panel for the raster, and one of the style panel for the point shapefile? I have a couple workarounds in mind but it would help to see what settings and color ramps you're using.

    – csk
    Jul 23 at 15:26

















  • Can you add a screenshot of the style panel for the raster, and one of the style panel for the point shapefile? I have a couple workarounds in mind but it would help to see what settings and color ramps you're using.

    – csk
    Jul 23 at 15:26
















Can you add a screenshot of the style panel for the raster, and one of the style panel for the point shapefile? I have a couple workarounds in mind but it would help to see what settings and color ramps you're using.

– csk
Jul 23 at 15:26





Can you add a screenshot of the style panel for the raster, and one of the style panel for the point shapefile? I have a couple workarounds in mind but it would help to see what settings and color ramps you're using.

– csk
Jul 23 at 15:26










2 Answers
2






active

oldest

votes


















1














The ramp_color(ramp_name,value) allows you to set symbol color based on a color ramp. The value parameter controls the position on the ramp to select the color from (as a real number between 0 and 1).



enter image description here



Your point attribute has numbers between -0.5 and -2.3, but you want to use them as though the range was between -5 and 5. To convert the point attribute into the value parameter, we take the following steps:



  • add 5 to convert range from (-5,5) to (0,10)

  • divide by 10 to convert range (0,10) to (0,1)

Converted into Expression Builder syntax, that's ("point_attribute"+5)/10, which we'll use in the next step.



Set point symbol color using data-defined override with this expression:



ramp_color('ramp_name',("point_attribute"+5)/10)


Where the expression says 'ramp_name', substitute the name of the color ramp that you used for your singleband pseudocolor raster style. It looks like you're using the color ramp 'RdBu', but you can check the color ramp names in the style panel:



enter image description here



If you used a custom color ramp, the easiest solution is to save that color ramp with a name, and use the name in the expression. It's also possible to create a custom ramp directly in the expression builder. See the expression builder help for the ramp_color expression for more details.






share|improve this answer



























  • sorry you beat me before i could add the screenshots! will take a stab at your solution now

    – bbuzz31
    Jul 23 at 16:09











  • That's fine. I didn't end up needing the screenshot because I found a better solution that doesn't depend on your settings. The workaround I was originally thinking of was going to involve making a custom color ramp by fiddling with the color stops, which would be a lot of work, not a perfect solution, and not transferable if you decide to put the raster in a different color ramp.

    – csk
    Jul 23 at 16:11












  • excellent this works. it's more what I was expecting based on how I did it in python. I am quite new to qgis though could you tell me where to do ("point_attribute"+5)/10... i just created a new field in the points attribute table

    – bbuzz31
    Jul 23 at 16:46











  • You don't actually need to do ("point_attribute"+5)/10 as a separate step, since it's incorporated into the ramp_color expression. I was just explaining the process that went into creating the final expression.

    – csk
    Jul 23 at 17:01


















6














You can use a data-defined override for the 'Fill color' property of the point layer to achieve this.



First you need to export your singleband raster as 3-band RGB image. Once you apply the colormap, right-click -> Export -> Save As.. In the export raster layer dialog, choose Output mode as 'Rendered Image'. Once exported and loaded, you can use the following expression



Assuming your RGB raster is called 'raster', use the expression as below:



concat(raster_value('raster', 1, $geometry), ',', raster_value('raster', 2, $geometry), ',', raster_value('raster', 3, $geometry))


This samples the value in the R, G and B bands of the raster and creates a string such as 119,20,89 which is used as r,g,b values for the fill color.



data defined override



marker color from raster






share|improve this answer






















  • 1





    This would work if the raster values are the components of RGB colors, but their raster has a single band with values between -5 and 5. The colors come from the "singleband pseudocolor" symbology.

    – csk
    Jul 23 at 14:28











  • thanks but as @csk says this doesn't work for singleband pseudocolor symbology...

    – bbuzz31
    Jul 23 at 15:06






  • 1





    Good catch. @csk I have updated the answer. You can save the layer as a 3-band raster after applying the "singleband pseudocolor" symbology as a 'rendered image' and use the expression.

    – spatialthoughts
    Jul 23 at 15:43











  • thanks for the update; your solution does indeed work as intended. however, I discovered I have no data values in the raster at the point locations, so they are coming up black (no data color) with this approach

    – bbuzz31
    Jul 23 at 16:10













Your Answer








StackExchange.ready(function()
var channelOptions =
tags: "".split(" "),
id: "79"
;
initTagRenderer("".split(" "), "".split(" "), channelOptions);

StackExchange.using("externalEditor", function()
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled)
StackExchange.using("snippets", function()
createEditor();
);

else
createEditor();

);

function createEditor()
StackExchange.prepareEditor(
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: false,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: null,
bindNavPrevention: true,
postfix: "",
imageUploader:
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
,
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
);



);













draft saved

draft discarded


















StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fgis.stackexchange.com%2fquestions%2f329621%2fcoloring-points-by-raster-values-in-qgis%23new-answer', 'question_page');

);

Post as a guest















Required, but never shown

























2 Answers
2






active

oldest

votes








2 Answers
2






active

oldest

votes









active

oldest

votes






active

oldest

votes









1














The ramp_color(ramp_name,value) allows you to set symbol color based on a color ramp. The value parameter controls the position on the ramp to select the color from (as a real number between 0 and 1).



enter image description here



Your point attribute has numbers between -0.5 and -2.3, but you want to use them as though the range was between -5 and 5. To convert the point attribute into the value parameter, we take the following steps:



  • add 5 to convert range from (-5,5) to (0,10)

  • divide by 10 to convert range (0,10) to (0,1)

Converted into Expression Builder syntax, that's ("point_attribute"+5)/10, which we'll use in the next step.



Set point symbol color using data-defined override with this expression:



ramp_color('ramp_name',("point_attribute"+5)/10)


Where the expression says 'ramp_name', substitute the name of the color ramp that you used for your singleband pseudocolor raster style. It looks like you're using the color ramp 'RdBu', but you can check the color ramp names in the style panel:



enter image description here



If you used a custom color ramp, the easiest solution is to save that color ramp with a name, and use the name in the expression. It's also possible to create a custom ramp directly in the expression builder. See the expression builder help for the ramp_color expression for more details.






share|improve this answer



























  • sorry you beat me before i could add the screenshots! will take a stab at your solution now

    – bbuzz31
    Jul 23 at 16:09











  • That's fine. I didn't end up needing the screenshot because I found a better solution that doesn't depend on your settings. The workaround I was originally thinking of was going to involve making a custom color ramp by fiddling with the color stops, which would be a lot of work, not a perfect solution, and not transferable if you decide to put the raster in a different color ramp.

    – csk
    Jul 23 at 16:11












  • excellent this works. it's more what I was expecting based on how I did it in python. I am quite new to qgis though could you tell me where to do ("point_attribute"+5)/10... i just created a new field in the points attribute table

    – bbuzz31
    Jul 23 at 16:46











  • You don't actually need to do ("point_attribute"+5)/10 as a separate step, since it's incorporated into the ramp_color expression. I was just explaining the process that went into creating the final expression.

    – csk
    Jul 23 at 17:01















1














The ramp_color(ramp_name,value) allows you to set symbol color based on a color ramp. The value parameter controls the position on the ramp to select the color from (as a real number between 0 and 1).



enter image description here



Your point attribute has numbers between -0.5 and -2.3, but you want to use them as though the range was between -5 and 5. To convert the point attribute into the value parameter, we take the following steps:



  • add 5 to convert range from (-5,5) to (0,10)

  • divide by 10 to convert range (0,10) to (0,1)

Converted into Expression Builder syntax, that's ("point_attribute"+5)/10, which we'll use in the next step.



Set point symbol color using data-defined override with this expression:



ramp_color('ramp_name',("point_attribute"+5)/10)


Where the expression says 'ramp_name', substitute the name of the color ramp that you used for your singleband pseudocolor raster style. It looks like you're using the color ramp 'RdBu', but you can check the color ramp names in the style panel:



enter image description here



If you used a custom color ramp, the easiest solution is to save that color ramp with a name, and use the name in the expression. It's also possible to create a custom ramp directly in the expression builder. See the expression builder help for the ramp_color expression for more details.






share|improve this answer



























  • sorry you beat me before i could add the screenshots! will take a stab at your solution now

    – bbuzz31
    Jul 23 at 16:09











  • That's fine. I didn't end up needing the screenshot because I found a better solution that doesn't depend on your settings. The workaround I was originally thinking of was going to involve making a custom color ramp by fiddling with the color stops, which would be a lot of work, not a perfect solution, and not transferable if you decide to put the raster in a different color ramp.

    – csk
    Jul 23 at 16:11












  • excellent this works. it's more what I was expecting based on how I did it in python. I am quite new to qgis though could you tell me where to do ("point_attribute"+5)/10... i just created a new field in the points attribute table

    – bbuzz31
    Jul 23 at 16:46











  • You don't actually need to do ("point_attribute"+5)/10 as a separate step, since it's incorporated into the ramp_color expression. I was just explaining the process that went into creating the final expression.

    – csk
    Jul 23 at 17:01













1












1








1







The ramp_color(ramp_name,value) allows you to set symbol color based on a color ramp. The value parameter controls the position on the ramp to select the color from (as a real number between 0 and 1).



enter image description here



Your point attribute has numbers between -0.5 and -2.3, but you want to use them as though the range was between -5 and 5. To convert the point attribute into the value parameter, we take the following steps:



  • add 5 to convert range from (-5,5) to (0,10)

  • divide by 10 to convert range (0,10) to (0,1)

Converted into Expression Builder syntax, that's ("point_attribute"+5)/10, which we'll use in the next step.



Set point symbol color using data-defined override with this expression:



ramp_color('ramp_name',("point_attribute"+5)/10)


Where the expression says 'ramp_name', substitute the name of the color ramp that you used for your singleband pseudocolor raster style. It looks like you're using the color ramp 'RdBu', but you can check the color ramp names in the style panel:



enter image description here



If you used a custom color ramp, the easiest solution is to save that color ramp with a name, and use the name in the expression. It's also possible to create a custom ramp directly in the expression builder. See the expression builder help for the ramp_color expression for more details.






share|improve this answer















The ramp_color(ramp_name,value) allows you to set symbol color based on a color ramp. The value parameter controls the position on the ramp to select the color from (as a real number between 0 and 1).



enter image description here



Your point attribute has numbers between -0.5 and -2.3, but you want to use them as though the range was between -5 and 5. To convert the point attribute into the value parameter, we take the following steps:



  • add 5 to convert range from (-5,5) to (0,10)

  • divide by 10 to convert range (0,10) to (0,1)

Converted into Expression Builder syntax, that's ("point_attribute"+5)/10, which we'll use in the next step.



Set point symbol color using data-defined override with this expression:



ramp_color('ramp_name',("point_attribute"+5)/10)


Where the expression says 'ramp_name', substitute the name of the color ramp that you used for your singleband pseudocolor raster style. It looks like you're using the color ramp 'RdBu', but you can check the color ramp names in the style panel:



enter image description here



If you used a custom color ramp, the easiest solution is to save that color ramp with a name, and use the name in the expression. It's also possible to create a custom ramp directly in the expression builder. See the expression builder help for the ramp_color expression for more details.







share|improve this answer














share|improve this answer



share|improve this answer








edited Jul 23 at 17:03

























answered Jul 23 at 16:01









cskcsk

13.7k13 silver badges37 bronze badges




13.7k13 silver badges37 bronze badges















  • sorry you beat me before i could add the screenshots! will take a stab at your solution now

    – bbuzz31
    Jul 23 at 16:09











  • That's fine. I didn't end up needing the screenshot because I found a better solution that doesn't depend on your settings. The workaround I was originally thinking of was going to involve making a custom color ramp by fiddling with the color stops, which would be a lot of work, not a perfect solution, and not transferable if you decide to put the raster in a different color ramp.

    – csk
    Jul 23 at 16:11












  • excellent this works. it's more what I was expecting based on how I did it in python. I am quite new to qgis though could you tell me where to do ("point_attribute"+5)/10... i just created a new field in the points attribute table

    – bbuzz31
    Jul 23 at 16:46











  • You don't actually need to do ("point_attribute"+5)/10 as a separate step, since it's incorporated into the ramp_color expression. I was just explaining the process that went into creating the final expression.

    – csk
    Jul 23 at 17:01

















  • sorry you beat me before i could add the screenshots! will take a stab at your solution now

    – bbuzz31
    Jul 23 at 16:09











  • That's fine. I didn't end up needing the screenshot because I found a better solution that doesn't depend on your settings. The workaround I was originally thinking of was going to involve making a custom color ramp by fiddling with the color stops, which would be a lot of work, not a perfect solution, and not transferable if you decide to put the raster in a different color ramp.

    – csk
    Jul 23 at 16:11












  • excellent this works. it's more what I was expecting based on how I did it in python. I am quite new to qgis though could you tell me where to do ("point_attribute"+5)/10... i just created a new field in the points attribute table

    – bbuzz31
    Jul 23 at 16:46











  • You don't actually need to do ("point_attribute"+5)/10 as a separate step, since it's incorporated into the ramp_color expression. I was just explaining the process that went into creating the final expression.

    – csk
    Jul 23 at 17:01
















sorry you beat me before i could add the screenshots! will take a stab at your solution now

– bbuzz31
Jul 23 at 16:09





sorry you beat me before i could add the screenshots! will take a stab at your solution now

– bbuzz31
Jul 23 at 16:09













That's fine. I didn't end up needing the screenshot because I found a better solution that doesn't depend on your settings. The workaround I was originally thinking of was going to involve making a custom color ramp by fiddling with the color stops, which would be a lot of work, not a perfect solution, and not transferable if you decide to put the raster in a different color ramp.

– csk
Jul 23 at 16:11






That's fine. I didn't end up needing the screenshot because I found a better solution that doesn't depend on your settings. The workaround I was originally thinking of was going to involve making a custom color ramp by fiddling with the color stops, which would be a lot of work, not a perfect solution, and not transferable if you decide to put the raster in a different color ramp.

– csk
Jul 23 at 16:11














excellent this works. it's more what I was expecting based on how I did it in python. I am quite new to qgis though could you tell me where to do ("point_attribute"+5)/10... i just created a new field in the points attribute table

– bbuzz31
Jul 23 at 16:46





excellent this works. it's more what I was expecting based on how I did it in python. I am quite new to qgis though could you tell me where to do ("point_attribute"+5)/10... i just created a new field in the points attribute table

– bbuzz31
Jul 23 at 16:46













You don't actually need to do ("point_attribute"+5)/10 as a separate step, since it's incorporated into the ramp_color expression. I was just explaining the process that went into creating the final expression.

– csk
Jul 23 at 17:01





You don't actually need to do ("point_attribute"+5)/10 as a separate step, since it's incorporated into the ramp_color expression. I was just explaining the process that went into creating the final expression.

– csk
Jul 23 at 17:01













6














You can use a data-defined override for the 'Fill color' property of the point layer to achieve this.



First you need to export your singleband raster as 3-band RGB image. Once you apply the colormap, right-click -> Export -> Save As.. In the export raster layer dialog, choose Output mode as 'Rendered Image'. Once exported and loaded, you can use the following expression



Assuming your RGB raster is called 'raster', use the expression as below:



concat(raster_value('raster', 1, $geometry), ',', raster_value('raster', 2, $geometry), ',', raster_value('raster', 3, $geometry))


This samples the value in the R, G and B bands of the raster and creates a string such as 119,20,89 which is used as r,g,b values for the fill color.



data defined override



marker color from raster






share|improve this answer






















  • 1





    This would work if the raster values are the components of RGB colors, but their raster has a single band with values between -5 and 5. The colors come from the "singleband pseudocolor" symbology.

    – csk
    Jul 23 at 14:28











  • thanks but as @csk says this doesn't work for singleband pseudocolor symbology...

    – bbuzz31
    Jul 23 at 15:06






  • 1





    Good catch. @csk I have updated the answer. You can save the layer as a 3-band raster after applying the "singleband pseudocolor" symbology as a 'rendered image' and use the expression.

    – spatialthoughts
    Jul 23 at 15:43











  • thanks for the update; your solution does indeed work as intended. however, I discovered I have no data values in the raster at the point locations, so they are coming up black (no data color) with this approach

    – bbuzz31
    Jul 23 at 16:10















6














You can use a data-defined override for the 'Fill color' property of the point layer to achieve this.



First you need to export your singleband raster as 3-band RGB image. Once you apply the colormap, right-click -> Export -> Save As.. In the export raster layer dialog, choose Output mode as 'Rendered Image'. Once exported and loaded, you can use the following expression



Assuming your RGB raster is called 'raster', use the expression as below:



concat(raster_value('raster', 1, $geometry), ',', raster_value('raster', 2, $geometry), ',', raster_value('raster', 3, $geometry))


This samples the value in the R, G and B bands of the raster and creates a string such as 119,20,89 which is used as r,g,b values for the fill color.



data defined override



marker color from raster






share|improve this answer






















  • 1





    This would work if the raster values are the components of RGB colors, but their raster has a single band with values between -5 and 5. The colors come from the "singleband pseudocolor" symbology.

    – csk
    Jul 23 at 14:28











  • thanks but as @csk says this doesn't work for singleband pseudocolor symbology...

    – bbuzz31
    Jul 23 at 15:06






  • 1





    Good catch. @csk I have updated the answer. You can save the layer as a 3-band raster after applying the "singleband pseudocolor" symbology as a 'rendered image' and use the expression.

    – spatialthoughts
    Jul 23 at 15:43











  • thanks for the update; your solution does indeed work as intended. however, I discovered I have no data values in the raster at the point locations, so they are coming up black (no data color) with this approach

    – bbuzz31
    Jul 23 at 16:10













6












6








6







You can use a data-defined override for the 'Fill color' property of the point layer to achieve this.



First you need to export your singleband raster as 3-band RGB image. Once you apply the colormap, right-click -> Export -> Save As.. In the export raster layer dialog, choose Output mode as 'Rendered Image'. Once exported and loaded, you can use the following expression



Assuming your RGB raster is called 'raster', use the expression as below:



concat(raster_value('raster', 1, $geometry), ',', raster_value('raster', 2, $geometry), ',', raster_value('raster', 3, $geometry))


This samples the value in the R, G and B bands of the raster and creates a string such as 119,20,89 which is used as r,g,b values for the fill color.



data defined override



marker color from raster






share|improve this answer















You can use a data-defined override for the 'Fill color' property of the point layer to achieve this.



First you need to export your singleband raster as 3-band RGB image. Once you apply the colormap, right-click -> Export -> Save As.. In the export raster layer dialog, choose Output mode as 'Rendered Image'. Once exported and loaded, you can use the following expression



Assuming your RGB raster is called 'raster', use the expression as below:



concat(raster_value('raster', 1, $geometry), ',', raster_value('raster', 2, $geometry), ',', raster_value('raster', 3, $geometry))


This samples the value in the R, G and B bands of the raster and creates a string such as 119,20,89 which is used as r,g,b values for the fill color.



data defined override



marker color from raster







share|improve this answer














share|improve this answer



share|improve this answer








edited Jul 23 at 15:42

























answered Jul 23 at 6:04









spatialthoughtsspatialthoughts

4,40817 silver badges33 bronze badges




4,40817 silver badges33 bronze badges










  • 1





    This would work if the raster values are the components of RGB colors, but their raster has a single band with values between -5 and 5. The colors come from the "singleband pseudocolor" symbology.

    – csk
    Jul 23 at 14:28











  • thanks but as @csk says this doesn't work for singleband pseudocolor symbology...

    – bbuzz31
    Jul 23 at 15:06






  • 1





    Good catch. @csk I have updated the answer. You can save the layer as a 3-band raster after applying the "singleband pseudocolor" symbology as a 'rendered image' and use the expression.

    – spatialthoughts
    Jul 23 at 15:43











  • thanks for the update; your solution does indeed work as intended. however, I discovered I have no data values in the raster at the point locations, so they are coming up black (no data color) with this approach

    – bbuzz31
    Jul 23 at 16:10












  • 1





    This would work if the raster values are the components of RGB colors, but their raster has a single band with values between -5 and 5. The colors come from the "singleband pseudocolor" symbology.

    – csk
    Jul 23 at 14:28











  • thanks but as @csk says this doesn't work for singleband pseudocolor symbology...

    – bbuzz31
    Jul 23 at 15:06






  • 1





    Good catch. @csk I have updated the answer. You can save the layer as a 3-band raster after applying the "singleband pseudocolor" symbology as a 'rendered image' and use the expression.

    – spatialthoughts
    Jul 23 at 15:43











  • thanks for the update; your solution does indeed work as intended. however, I discovered I have no data values in the raster at the point locations, so they are coming up black (no data color) with this approach

    – bbuzz31
    Jul 23 at 16:10







1




1





This would work if the raster values are the components of RGB colors, but their raster has a single band with values between -5 and 5. The colors come from the "singleband pseudocolor" symbology.

– csk
Jul 23 at 14:28





This would work if the raster values are the components of RGB colors, but their raster has a single band with values between -5 and 5. The colors come from the "singleband pseudocolor" symbology.

– csk
Jul 23 at 14:28













thanks but as @csk says this doesn't work for singleband pseudocolor symbology...

– bbuzz31
Jul 23 at 15:06





thanks but as @csk says this doesn't work for singleband pseudocolor symbology...

– bbuzz31
Jul 23 at 15:06




1




1





Good catch. @csk I have updated the answer. You can save the layer as a 3-band raster after applying the "singleband pseudocolor" symbology as a 'rendered image' and use the expression.

– spatialthoughts
Jul 23 at 15:43





Good catch. @csk I have updated the answer. You can save the layer as a 3-band raster after applying the "singleband pseudocolor" symbology as a 'rendered image' and use the expression.

– spatialthoughts
Jul 23 at 15:43













thanks for the update; your solution does indeed work as intended. however, I discovered I have no data values in the raster at the point locations, so they are coming up black (no data color) with this approach

– bbuzz31
Jul 23 at 16:10





thanks for the update; your solution does indeed work as intended. however, I discovered I have no data values in the raster at the point locations, so they are coming up black (no data color) with this approach

– bbuzz31
Jul 23 at 16:10

















draft saved

draft discarded
















































Thanks for contributing an answer to Geographic Information Systems Stack Exchange!


  • Please be sure to answer the question. Provide details and share your research!

But avoid


  • Asking for help, clarification, or responding to other answers.

  • Making statements based on opinion; back them up with references or personal experience.

To learn more, see our tips on writing great answers.




draft saved


draft discarded














StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fgis.stackexchange.com%2fquestions%2f329621%2fcoloring-points-by-raster-values-in-qgis%23new-answer', 'question_page');

);

Post as a guest















Required, but never shown





















































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown

































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown







Popular posts from this blog

Category:9 (number) SubcategoriesMedia in category "9 (number)"Navigation menuUpload mediaGND ID: 4485639-8Library of Congress authority ID: sh85091979ReasonatorScholiaStatistics

Circuit construction for execution of conditional statements using least significant bitHow are two different registers being used as “control”?How exactly is the stated composite state of the two registers being produced using the $R_zz$ controlled rotations?Efficiently performing controlled rotations in HHLWould this quantum algorithm implementation work?How to prepare a superposed states of odd integers from $1$ to $sqrtN$?Why is this implementation of the order finding algorithm not working?Circuit construction for Hamiltonian simulationHow can I invert the least significant bit of a certain term of a superposed state?Implementing an oracleImplementing a controlled sum operation

Magento 2 “No Payment Methods” in Admin New OrderHow to integrate Paypal Express Checkout with the Magento APIMagento 1.5 - Sales > Order > edit order and shipping methods disappearAuto Invoice Check/Money Order Payment methodAdd more simple payment methods?Shipping methods not showingWhat should I do to change payment methods if changing the configuration has no effects?1.9 - No Payment Methods showing upMy Payment Methods not Showing for downloadable/virtual product when checkout?Magento2 API to access internal payment methodHow to call an existing payment methods in the registration form?