Skip to content

Export DF world map for use in GIS tools - #5376

Merged
ab9rf merged 28 commits into
DFHack:developfrom
chdoc:export-map-2
Aug 22, 2026
Merged

Export DF world map for use in GIS tools#5376
ab9rf merged 28 commits into
DFHack:developfrom
chdoc:export-map-2

Conversation

@chdoc

@chdoc chdoc commented Apr 3, 2025

Copy link
Copy Markdown
Member

The goal of this plugin is to export the world map at the region-tile (i.e., embark tile or midmap-tile) level for use with GIS programs like ArcGIS or QGIS. For a medium-sized map, this amounts to (129*16)^2 = 4260096 region tiles with biome information for every region tile fetched from one of the surrounding world tiles.

In order to keep the output down to a manageable size (17 MB of CSV for a medium-sized world), region tiles are clustered by the world tile they take their information from, and every cluster is exported as a single feature with its geometry described as a WKT (MULTI)POLYGON, resulting in an export of only 129^2 = 16641 features.

  • documentation and change log

Comment thread plugins/CMakeLists.txt Outdated
Comment thread plugins/export-map.cpp Outdated
@chdoc
chdoc marked this pull request as ready for review August 2, 2026 17:57
@@ -1,4 +1,4 @@
coord2d(uint16_t _x, uint16_t _y) : x(_x), y(_y) {}
coord2d(int16_t _x, int16_t _y) : x(_x), y(_y) {}

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I've been reluctant to make this change myself because I've been uncertain of the consequences - how well tested is this behaviorally?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Apart from the fact that it now allows using brace initialization using the correct type for the members, I have not noticed any adverse effects. I haven't played a whole lot on this branch, but I did play a few hours in total and I didn't notice anything off.

Comment thread library/include/MiscUtils.h Outdated
Comment thread plugins/export-world-map.cpp Outdated
Comment thread plugins/export-world-map.cpp Outdated
Comment thread library/include/MiscUtils.h Outdated
Comment thread plugins/export-world-map.cpp Outdated

// If you change anything in this vector, don't forget to change the
// corresponding comments and arguments in the call to print_csv below
vector<std::string> headings = {

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

consider std::string_view or const char * here to avoid heap allocations

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Also this code appear repetitive of code elsewhere, should there be an abstraction here?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I went with constexpr std::array<std::string_view, _> and I did factor out the print_csv definitions. Beyond that, one would actually have to use a real class of a CSV writer. However, that wouldn't really be a good fit, because the current implementation uses unfinished lines to then add the geometry as a separate step.

@chdoc
chdoc requested a review from ab9rf August 22, 2026 13:31
@ab9rf
ab9rf merged commit 9d64c6a into DFHack:develop Aug 22, 2026
14 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants