I have two layers:
- a shapefile with states and counties (shp)
- a raster file (with colors and some text and borders, but not a perfect map) (tiff)
I want to use the colors in the raster file to associate values to one of the attributes of the shapefile. I've started to do so manually with qgis. I overlayed the shapefile and the raster, and I read the color and fill in the value in the attribute editor:
I was wondering if this can be done programmatically. The pseudocode would be something like:
for county in polygons_in_shapefile: center_of_polygon = county.center() color = raster_color(center_of_polygon.x, center_of_polygon.y) if color == blue: county.value = 1 if color == red: county.value = 2 ... etc ...
I am totally new when it comes to GIS, so maybe it's very obvious (and the code may be totally the wrong strategy).