2

I have a map in a bitmap image format (.bmp) where each region is assigned an RGB colour. What I want is a list of every adjacent region, for every region.

So if region1 is adjacent to region2 and region3, I want this output in a text/csv file:

region1, region2
region1, region3

I can also deal with the output where we have duplicate adjacency links:

region1, region2
region1, region3
region2, region1
region3, region1

And I can also deal with an adjacency matrix:

(whatever), region1, region2, region3
region1, 0, 1, 1
region2, 1, 0, 0
region3, 1, 0, 0

And I can deal with the regions being named after their colour number. (probably the simplest thing to do) So the actual output would probably look like:

hFF0000, h00FF00
hFF0000, h0000FF

(or)

hFF0000, h00FF00
hFF0000, h0000FF
h00FF00, hFF0000
h0000FF, hFF0000

(or)

(whatever), hFF0000, h00FF00, h0000FF
hFF0000, 0, 1, 1
h00FF00, 1, 0, 0
h0000FF, 1, 0, 0

The output will then be processed in Excel.

This is the map, but there are others like it that I'd also like to process once I got the automation down: A colourized map of regions in what looks like China.

I feel like what I'm looking for is a very basic feature for a geography software, and I've tried to find it in QGIS, but I didn't find it and I am confused by all the vocabulary I don't understand. What I remember from my last geography class is that we talked about rocks and coloured maps.

Like, I know what's a raster and what's a vector, but the software is constantly asking me for a coordinate system, and I don't know what to answer because this isn't a real world map and I don't care about the GPS coordinate. Also, every raster operation seem to want to operate on a single band, the bands are named after the RGB colour, so are all of those processes only working with 1 colour component of my pixels?? I can't deal with that, because I need all 3 colour components to know which region is which.

This map is the regions map for the Total War Three Kingdoms video game, taking place in China circa 200 AD, and I want the adjacency dataset because I'm building a modelling Excel workbook, and some buildings give a critical effect to their adjacent regions.

So my precise questions are :

  1. Is this doable in QGIS?
  2. If not doable in QGIS, can another free software do it? (free as in money)
  3. And finally, how can I do this in said software?
  • Welcome to GIS SE. As a new user, please take the Tour, which explains how our "Focused question/Best answer" model operates, and emphasizes the importance of asking One question per Question. The assumption here is that most GIS tools can do anything GIS-like, so "doable" isn't much of a consideration. Unfortunately, the how of this question is rather involved, and certainly beyond the scope of a typical question here. I'm afraid the answers to your questions might be, "Probably; Probably; You probably can't without more experience/training." Sorry. – Vince Jul 6 '19 at 11:44
  • Thanks @Vince ! This is a great answer! I was actually afraid to ask if I was correct in assuming it was a simple thing to do with those softwares, because I was afraid of breaking the "no opinion based questions" rule. Anywayz, knowing that there isn't an easy path here is a precious information, and I am very grateful for it. – Amélia Jul 6 '19 at 18:45
  • 1
    It's doable, but possibly more work than it's worth. First, polygonize your raster. Hopefully this will create a vector layer with one polygon for each region. If the regions are broken up in to lots of tiny squares, go back and reclass your raster into distinct values (one and only one value per region), then polygonize again. Then use either the join attributes by location tool or the join attributes by location (summary) tool to add the names of adjacent regions to each region. – csk Jul 8 '19 at 18:15
  • Don't worry about the CRS. Just use EPSG:4326 for everything, and don't try to do any distance measurements. Or, since you mention that this game is set in China, you could make your best guess of the real-world area it represents and georeference your raster to that area. That way if you want to use your region polygons for something later, they're approximately correct. Note: all of the tools I mentioned can be found in the Processing Toolbox, except for the georeferencer which is in the raster menu. – csk Jul 8 '19 at 18:18