maps with different projection ?

Smallpox vs. largepox, gen2 vs gen5, early war vs. peaceful alliances. Which is your favourite gaming style?
User avatar
meynaf
Veteran
Posts: 124
Joined: Sun Jan 21, 2018 10:27 am
Location: Lyon / France
Contact:

maps with different projection ?

Postby meynaf » Wed Sep 08, 2021 5:43 pm

I suppose ordinary Earth maps in Freeciv use Mercator projection ?
Are other ones available anywhere ? (Obviously not just images but maps containing terrain type so a civ game can use them.)
I'm especially interested in Winkel-tripel projection, which looked like a good compromise to me, at least for a video game (Mercator destroys sizes, Gall-Peters destroys shapes...)

Molo_Parko
Veteran
Posts: 57
Joined: Fri Jul 02, 2021 4:00 pm

Re: maps with different projection ?

Postby Molo_Parko » Sun Oct 03, 2021 12:09 am

Image

It is possible to convert the jpeg at your link to a Freeciv map. The process varies a bit depending on the format of the original image but it's basically the following:

  • Use an image editing program to limit the number of colors in the image to 13 (for the 13 terrain tiles in Freeciv.) Use the "posterize" option in Photoshop. In Graphic Converter use Picture menu > Colors > Change color usage dynamically.
  • Proportionately reduce the image size to the desired Freeciv map size -- for instance, with constrained proportions reduce the width to 200 pixels for a 200 tile wide Freeciv map. In some programs, this causes the color palette to increase because the programmer thought it "smart" to add new shades when resizing. If that occurs, then again limit the number of colors to 13.
  • Save a copy of the new map in a graphics format which can be converted to Freeciv terrain map format
  • Convert the map

There have been a couple of programs over the years to convert from topographic images to Freeciv maps, I think they were called "mapper" and "ppm2maps" but I can no longer find them via web search. If you are able to save a copy of the image to the PPM ASCII format (Lemke Software's Graphic Converter works and can be used free as shareware), it is quite easy to search and replace the color sequences to Freeciv terrain tile types (a=arctic/glacier, d=desert, and so on.) The command-line utility sed does a terrific job of it with substitution commands such as: " sed -e 's/ 255 255 255/a/g' -e 's/ 200 196 179/d/g' " which would convert the white pixels to "a" for arctic/glacier, and the light khaki/beige-ish pixels to "d" for desert. There should only be 13 different sequences in the file for the 13 different Freeciv terrain types.

Image
^ PPM ASCII format img file contents viewed in a text editor. The highlighted portion is the first line of pixels running across the top of the image. The sequence "255 255 255" is the RGB value for a completely white pixel.

The most tedious part is step 1 of the process in which it is important to get 13 distinct colors before reducing the number of colors -- three for ocean, deep ocean, lake, and 10 for the various land tiles. It often takes a bit of fiddling with color levels / balance to get distinct colors for areas like grassland vs. forest, or desert vs. plains. In the image at the link you posted, there is very little difference between jungle and forest so as a Freeciv map it's likely to have only one or the other and not both (all forest, or all jungle.)

Elevation / topographical maps are generally easier to convert because they already tend to have a limited color set - like this one:
Image but the elevation levels don't actually indicate forests, jungles, swamps, rivers and so on (although some of that can be inferred), so the map converted for Freeciv generally requires a bit of editing to add those features.

EDIT: You could also try using any image-to-ASCII-art converter that allows specifying which characters to use. I've used 'jp2a' before with good results on some maps. jp2a also allows forcing width/height of the text (Freeciv map) output to alter the aspect ratio. http://csl.name/jp2a/

User avatar
meynaf
Veteran
Posts: 124
Joined: Sun Jan 21, 2018 10:27 am
Location: Lyon / France
Contact:

Re: maps with different projection ?

Postby meynaf » Mon Oct 04, 2021 7:39 am

Thanks for your reply, i wasn't expecting any 8-)

Well, the problem is probably more about finding a suitable source map rather than actually converting it.
As none of the maps i've found contain relevant data, i.e. civ-like terrain types.
And they often have things drawn on top of it, e.g. lines for meridians. Not easy to remove.

So if the colors get simply converted, terrains will just be wrong. It will remotely look like Earth, but not be it. It will confuse plains with grasslands, put mountains in deserts because of the brown shades, not do shallow/deep ocean difference, etc.
Mere conversion to 13 colors won't give me 10 lands and 3 waters (oceans and lakes will surely look the same).

Else, reducing color numbers and shrinking images are no big deal. Same for converting pixels to ascii map (or vice versa).

An alternative could be to start with a high definition image (or, better, a huge civ map) and recompute the projection from it.
I can make a program doing that, no problem for me, but i don't have the maths skills so i'd need a blind formula to apply.
And of course a big enough map, with all the information, must be found.

All that, for a final map with cells somewhere between 20 to 100 km wide (with as correct as possible total surface of 510 millions km²).

Molo_Parko
Veteran
Posts: 57
Joined: Fri Jul 02, 2021 4:00 pm

Re: maps with different projection ?

Postby Molo_Parko » Mon Oct 04, 2021 4:21 pm

You dream big, don't you? :)

Even at 20 to 100 Km cells, features like San Francisco would likely end-up being a single tile overstating the size of the town by at least 100%, and would probably become just one hill tile in the Freeciv map at 1-to-1 conversion. What limit might you choose for final size of the Freeciv map?

If a map were rendered or accurately converted into a scalable format, a la Postscript or SVG, that might solve the size issue for the outline / shape of continents and islands without requiring the math originally necessary to the map projection method at all.

This map might work as a source for conversion to scalable format. The longitude and latitude lines could be knocked-out pretty easily.
https://upload.wikimedia.org/wikipedia/ ... ed.svg.png

I just realized that was generated from an SVG file. :) The original SVG map from which that image was derived: https://upload.wikimedia.org/wikipedia/ ... ntered.svg

More: https://commons.wikimedia.org/wiki/Cate ... projection

Once the outline of the land areas is ~accurate, programmatically matching terrain to a given tile location by converting Freeciv tile x,y to actual longitude and latitude on Earth, then pulling data from a source like USGS ( http://www.usgs.gov/media/images/nation ... er-dataset ) about foliage and/or elevation might work to determine majority feature of the individual tile (as "forest" vs. "desert", or "mountain" vs "hill" for instance.)

^ It just occurred to me that one could create a "blank" Freeciv map of any dimensions, then convert x,y of each tile to longitude and latitude to auto-create an Earth map from the USGS data ( http://www.usgs.gov/centers/eros/scienc ... ation-glcc ) at the scale of the Freeciv map size. 100x100 tile map would be very rough. 10000x10000 map would be much more detailed, and so on.

Rotating Winkel-Tripel globe: https://bl.ocks.org/mbostock/3790085

User avatar
meynaf
Veteran
Posts: 124
Joined: Sun Jan 21, 2018 10:27 am
Location: Lyon / France
Contact:

Re: maps with different projection ?

Postby meynaf » Mon Oct 04, 2021 6:10 pm

Molo_Parko wrote:You dream big, don't you? :)

Probably :)


Molo_Parko wrote:Even at 20 to 100 Km cells, features like San Francisco would likely end-up being a single tile overstating the size of the town by at least 100%, and would probably become just one hill tile in the Freeciv map at 1-to-1 conversion. What limit might you choose for final size of the Freeciv map?

It can be as big as possible, due it's a lot easier to resize to a smaller map than to a bigger one.
With 20km cells we already have more than 1.2 million cells.
Sure thing is that 80x50 isn't enough :lol:


Molo_Parko wrote:If a map were rendered or accurately converted into a scalable format, a la Postscript or SVG, that might solve the size issue for the outline / shape of continents and islands without requiring the math originally necessary to the map projection method at all.

This map might work as a source for conversion to scalable format. The longitude and latitude lines could be knocked-out pretty easily.
https://upload.wikimedia.org/wikipedia/ ... ed.svg.png

I just realized that was generated from an SVG file. :) The original SVG map from which that image was derived: https://upload.wikimedia.org/wikipedia/ ... ntered.svg

Shapes are not the real problem. It's terrain types. If you know that, then terrain type = water indicates the shape.



Nothing with civ-like infos there, it seems.


Molo_Parko wrote:Once the outline of the land areas is ~accurate, programmatically matching terrain to a given tile location by converting Freeciv tile x,y to actual longitude and latitude on Earth, then pulling data from a source like USGS ( http://www.usgs.gov/media/images/nation ... er-dataset ) about foliage and/or elevation might work to determine majority feature of the individual tile (as "forest" vs. "desert", or "mountain" vs "hill" for instance.)

Yes but i don't know how to extract data from this site and it appears it's "national" data, not "whole planet" data...


Molo_Parko wrote:Rotating Winkel-Tripel globe: https://bl.ocks.org/mbostock/3790085

Didn't work when i tried it (i get empty image).

Molo_Parko
Veteran
Posts: 57
Joined: Fri Jul 02, 2021 4:00 pm

Re: maps with different projection ?

Postby Molo_Parko » Mon Oct 04, 2021 6:38 pm

Image
Well, I eventually found some USGS "Land Cover" data which looks like it would be easily translated to specific Freeciv tile types, see picture above. However, I have yet to find any documentation explaining what it means and how to get the data for a specific global coordinate on Earth.

https://www.usgs.gov/faqs/where-can-i-g ... e_products

Their "EarthExplorer" seems to be visually oriented which is not what I want. I want a text/xml list by global coordinates or a live-lookup by coordinates.

The data exists, but I can't tell where. :) The page linked below shows:
Layer of Coverage

Field Definition: The classification name of the land cover.
^ Which sounds like what I want but I can't figure out how to get it!

https://www.usgs.gov/centers/eros/scien ... er_objects

The government website is giving me a headache. I'm gonna go look at the sky for awhile. :|

Image
^ Apparently Google Earth also has the NASA global land cover data available. However, nowhere can I find any mention of getting a simple json response of land cover type to a query by global coordinates. https://developers.google.com/earth-eng ... 06_MCD12Q1 The hex color per land cover type appears to be at least partially defined in the user guide linked below.

Image
^ USGS' MODIS Land Cover user guide (https://lpdaac.usgs.gov/documents/101/M ... ide_V6.pdf) does show the classification values for land cover though, looks great. Still can't manage to get it by coordinates.

User avatar
meynaf
Veteran
Posts: 124
Joined: Sun Jan 21, 2018 10:27 am
Location: Lyon / France
Contact:

Re: maps with different projection ?

Postby meynaf » Tue Oct 05, 2021 8:53 am

Found this while following the links :
https://lcviewer.vito.be/

It looks closer but i can't get it to give me what i want.
Even if it were the case, i'd be unable to redo the projection anyway.

Molo_Parko
Veteran
Posts: 57
Joined: Fri Jul 02, 2021 4:00 pm

Re: maps with different projection ?

Postby Molo_Parko » Tue Oct 05, 2021 2:32 pm

I am actually surprised that every single site hosting land cover data seems to share only image files. 53 GigaBytes worth of image files. I still have not found any site that shares text results of land cover classification by area. I find that odd to the point of being unbelievable, and yet that is exactly how the situation appears to be... weird.

I don't think that it would be necessary to re-do the projection. If you find a land cover/terrain/elevation map that looks like a winner, load the Winkel Tripel svg map, then underlay the land-cover map. Distort the land cover map to fit the existing svg map - which can be done by point-and-click with a mouse, no math required. Photoshop should make it fairly easy ?

Image
^ This is a partial screenshot of Photoshop showing Madagascar from the Winkel Tripel SVG file with the outline of the land cover map from https://www.wildmadagascar.org/maps/land_cover.html I used the Edit > Transform > Warp feature of Photoshop to fit the land cover image to the SVG image of the island.

Image
^ The end result is land cover image matching the Winkel Tripel projection of Madagascar. The "warp" process took a few seconds.

User avatar
meynaf
Veteran
Posts: 124
Joined: Sun Jan 21, 2018 10:27 am
Location: Lyon / France
Contact:

Re: maps with different projection ?

Postby meynaf » Tue Oct 05, 2021 8:25 pm

Molo_Parko wrote:If you find a land cover/terrain/elevation map that looks like a winner, (...)

No winners on the web, apparently :(

Molo_Parko
Veteran
Posts: 57
Joined: Fri Jul 02, 2021 4:00 pm

Re: maps with different projection ?

Postby Molo_Parko » Tue Oct 05, 2021 9:30 pm

The main problem I see with most land cover maps on the 'net is that they have far too many types of land cover for an easy, simple conversion to Freeciv tile types.

Image
^ This one has both elevation and land cover maps. This land cover map has relatively few types of land cover compared to most of the maps, and fewer would be easier to convert. When converting to Freeciv tiles, one could alternate mountain or hill tiles with whichever land cover type is indicated at a particular high-elevation spot on the map. "fmfmfm" could be derived programmatically for an area of the Freeciv map where the corresponding area of the elevation map shows mountain, and the corresponding area of the land cover map shows forest. That would be simple. I'd match all forest areas to forest tiles, shrub and mangrove to jungle tiles, bare soil to desert tiles and in all cases, intermix either hill or mountain tiles if the area indicates medium to high elevation. All three water types would match to lake tiles since the ocean is not included in the "land" cover map. The conversion is very easy to figure out with a map that doesn't have umpteen-bajillion types of land cover.

But most of the land cover maps seem to have so many different types that I'm not sure which Freeciv tile type(s) would be best, or whether to try to mix several across multiple tiles to give an impression of the actual area. Like the Madagascar land cover map I used in my prior post. Here is the color key for that map:
Image
^ Their idea of "grassland" strikes me more as plains (in Freeciv.) "Dry cropland and pasture" is what?! exactly? A desert? Or again, plains??? How about "Savanna"... should that become forest or plains or a mix of both tile types in that area? Or a mix of desert and forest? Or all three?

It would be easier with fewer, and more common designations than with many somewhat odd terrain types.

This is a nice color key image: Image