Stadtplan-Dateien (*.sgs) Map File Format

So you may have seen an old program kicking around called “Roleplaying City Map Generator 5.4” which is pretty useful for making city maps. There are a few problems with it, like you can’t edit the map once it’s been generated, but it works well for what it does. There’s an importer into the excellent “NBOS fractal mapper” that can be found here.

Roleplaying City Map Generator 5.4

Roleplaying City Map Generator 5.4

But I wanted to figure out how to read and edit the save file itself. It turns out the map result save file (.sgs extension) is in plaintext, and easily decoded. It’s a vector format, editable in notepad++ or whatever text editing tool you prefer.

The file is newline delimited (each line holds a “piece” of data), so I’ll be going through each line describing what it is (as far as I can tell). For this guide each bulletpoint is a line of text, with an example in parenthesies. Values that you can safely edit are preceeded by a pound symbol (#like this). Values I don’t know what they are are preceeded by a question mark (?like this). Some values have a single space preceeding them. I’ve marked these with an underscore (_like this). I don’t know if the space is important, but it makes the file easier to read. Repeated values, or arrays of data are inside brackets [like this]. Evertrhing is located as X and Y coordinates, from the top-left corner, x = horizontal (right), y = vertical (down).

  • Version number (5.40)
  • ? (0.9) Maybe a sub-version?
  • #Name of the city (Haea Ofrivu)
  • _#Size of the city ( 350)
  • ?[twelve lines, the first is 1 and the rest are 0] I don’t know what these do.
  • ?_[four more zeros, preceded by spaces]
  • #_the number of “line” type objects. This is the total number of roads and rivers. ( 10) Don’t change this value unless you actually add or remove one of the “line” entries, or the program will crash on loading the file.
  • ?_I think this is always 562, not sure why ( 562)
  • ?Same here, always 0.5 (0.5)
  • ?(3.5)

Now we get to the fun stuff. The following is the “line” data format. There is one of these entries for each of the roads and rivers (and lakes). If you add or remove one of these sets of data, remember to change the “number of “line” type objects” value above.


  • #_Type 0 = road, 1 = river, 2 = lake ( 0)
  •  #_half the length of datalist, the number of xy pairs ( 52) Edit this if you change the number of defined points… or it will crash instead of loading.
  • #Width (3.5)
  • ?_zero in every known case ( 0)
  • #[datalist of point coordinates] for this example, there will be 52 pairs, or 104 entries.


After the “line” type objects come the buildings.

  • #_Number of buildings ( 200) Change this if you change the number of buildings or crash etc.

And then all the building data.


  • ?_a zero ( 0) though I think this can be any number… just don’t make it text. It doesn’t do anything though.
  • #_The type of building. 0 = square, 1 = round. ( 0)

If the type is 0, or square

  • #[four pairs, eight lines, the four corners of the building]

But if the type is 1, or round

  • #this is the X (136.91)
  • #and then this is the Y (198.26)
  • #and this is the size, diameter (3.08)


Okay. Got roads, rivers, and buildings. Next is a bit more confusing, and involves squares, parks, walls, towers, etc. Try and keep up…trees are last and they are super straightforward.

  •  #_number of “squares” ( 11) Always one more than the actual number, and the last entry is blank.
  • ?_ thirty thousand ( 30000) don’t ask me why. You can change any of the digits, though it doesn’t do anything, but don’t change the length.

And then the data for the squares. “Squares” in this case are areas enclosed by dotted lines on roads. The x-y coordinates mark out where the dots go.


  • ?_zero ( 0)
  • #_Number of data pairs ( 31) as above, change if you alter the number of points
  • ?A decimal value number. (0.852139) This doesn’t seem to do anything.
  • #[The data points, x y pairs]


As a note, the last “square” data will look like this:
( 0

and, since the number of data pairs is zero (the second zero) it will be followed by no pairs. These blank entries can also be found elsewhere.

Then the data for the parks. This is exactly the same as for the squares.

  • #[same as for the “squares”, only these are “parks” aparently. Includes the 30000 and all that stuff.]

After all that data is the “are there walls and towers?” entry.

  • #_one or zero ( 1)

If 0, skip straight to trees. If 1, it is followed by…

  • #_Number of wall points. ( 135)
  • #thickness of the wall. (3) though it can be a decimal number.

And then all the wall points, in series (this makes a loop)


  • #X (294.71)
  • #Y (94.15)
  • #_Present/absent ( 1) If 1, this point will “connect” to the previous and subsequent points. If 0, the point will not connect.


And then the towers.

  • #_Number of towers ( 13)


  • #_presence, 1 = visible, 0 = invisible ( 1)
  • #_Type, 1 = round, 2 = square( 2)

If Type = 2

  • #[four point pairs, same as for square buildings]

If Type = 1

  • #[x, y, and radius, same as for round buildings]


We’ve made it! Now there’s a bajillion trees!

  • #_number of trees ( bajillion)


  • #x (115.01)
  • #y (155.05)
  • #diameter (3.77)


The file ends with a blank line, or a newline character, depending on how you look at it.

I hope someone puts this to good use, maybe writes a convertor into .svg format… actually, I could do that… Hmm… Also an importer into Blender would be cool… Ideas.

About Ziggy

I strive to be awesome for God. Support my efforts at:
This entry was posted in Articles and tagged . Bookmark the permalink.

2 Responses to Stadtplan-Dateien (*.sgs) Map File Format

  1. Belug says:

    Juste wanted to thank you for this description here’s what i’ve done with it :

  2. Ziggy says:

    Excellent! Thanks for putting all that theory into practice!

Leave a Reply

Your email address will not be published. Required fields are marked *