RoadGenerator - A real-world road generator!

Hey everyone! After seeing @Widgeon’s creation on Twitter (https://twitter.com/WidgeonRBLX/status/1239264957000105986) where he seemingly generated real roads (and buildings), I decided to attempt to replicate it and open-source a module for everyone to use!

I present to you, RoadGenerator!


RoadGenerator is a module script that I put together that will allow you to generate real world roads from a JSON file containing the road data.

How to use

Using RoadGenerator is quite simple. First you need to obtain your JSON file containing the road data.

Obtaining the JSON file

  1. First, navigate to https://www.openstreetmap.org/export.
  2. Then find any area with roads that you’d like to convert into Roblox! For example:
  3. Once you’ve found the roads you want to export, press the blue “Export” button! You should get a file named something like map.osm
  4. Navigate to a website that allows you to convert .osm files to .geojson. I personally found that https://mygeodata.cloud/converter/osm-to-geojson works very well.
  5. If you used the above website, you should see this screen with a section titled “Input Data”. Under that in the box titled “Input Layers to Convert”, you should remove all types of layers except “roads”. After that your screen should look similar to this:
  6. Press “Convert now!” to download a file titled “mygeodata.zip”. This zip file should contain a file titled “roads.geojson” somewhere.
  7. Once you’ve located “roads.geojson” in your “mygeodata.zip”, open it in a text editor. I personally use Notepad++.
  8. Select and copy all contents of road.geojson.

Now for the fun part!

Generating the road

  1. Assuming you’ve got the RoadGenerator modulescript in a game, expand it in the workspace and open up the module inside of it titled “RoadData”.
    image
  2. Near the top of the RoadData modulescript, you should see an empty multi-line string stored under the variable “Data”.
  3. Inside the multi-line string, paste all the contents of roads.geojson.
  4. Finally, run RoadGenerator.generateRoads() and you’ve got your roads!

Customization

You are also able to customize the generated roads.

RoadGenerator.generateRoads(colorRoads, drawPoints, roadWidth, scaleMultiplier)

colorRoads - can either be true or false. If set to true, it will color each road it’s own unique color!


drawPoints - can either be true or false. If set to true, it will make the points that make up the roads visible.

roadWidth - can be any integer, the roads will be that many studs wide. Defaults to .5.
scaleMultiplier - can be any integer. The lower the number the smaller the road layout is. Bigger = a larger scale layout, roads longer and spaced further apart. Defaults to 10000.

Viewing the roads

In case you are curious, you can also view the names of the roads! If for some reason a road doesn’t have a name, it will be called “Unknown” when generated.
To view the road names, open up the model in workspace called “Roads”. It contains all the generated roads as models!
image

Extra

Here is Park Place, the road that Roblox HQ is on!
image

As you can tell from the screenshots, this is not 100% perfect. For example, there are gaps where roads turn. However, as this is open-sourced, you are welcome to fix anything you encounter! If you feel like it, you can even add onto this script however you’d like.

If you do happen to make any fixes or add anything and you’d like to share it, feel free to post it in the replies! I love seeing what people are able to do with my creations. :smile:

85 Likes

WHAAAT

This is super cool and awesome for anyone trying to remodel an actual place that exists! Wow, this is super neat I can’t get over this haha

6 Likes

This is really cool. I haven’t checked, but does building data come with this? If not, where can you get it?

1 Like

I am attempting to eventually get building data to work with this, however the current version does not come with support for building data. You can obtain the building data by keeping the “buildings” layer on step 5. You should have a file titled something similar to “buildings.geojson” in the mygeodata.zip file when you convert it.

From there I assume that you could figure out how to use it!

2 Likes

Yeah I’m already doing it, actually. So far so good!

I’m currently exporting a section of London so I can get some more building data.

3 Likes

Wow, that looks great! If you are willing to, feel free to share the changes you made to the module (or how you did it). Good luck!

Yeah I will, but I need to finish it first!
I also want to scale everything up so you can actually walk around in your home town - that’d be awesome!

I’m not at my computer right now, but you should be able to locate the part of the script where I multiply two coordinates by 10000. (you can probably just search for the number 10000 with ctrl+f)

If you increase both 10000s, it will scale it up. You’ll want to play around with the roadWidth variable to get the roads to a width that matches the scale of the roads.

I will probably build a variable into the function to control the amount that the coordinates are multiplied by to make it easier for people.

1 Like

Added scaleMultiplier variable, will allow you to change the amount that the coordinates are multiplied by! Defaults to 10000

Also added a modulescript called RoadData inside of the RoadGenerator module. Using the new version you will have to put your road data in that instead. Just thought it’d be better to keep the main module at a lower amount of lines.

One of the coolest open sources asset I have seen In a while. This can help in studying a city or map designing. Thank you for your contribution

1 Like

I had an idea to make this even better for developers:
To make this into a plugin!

I haven’t tested this yet, but I’m pretty sure this only works in-game. A plugin would remove the hassle of copying and pasting.

Thanks for your contribution, it’s awesome and helps a lot with my game!

2 Likes

Got this error when i single clicked the module on a blank baseplate.


Amazing, Just generated my own road here!

2 Likes

That appears to be a Roblox error, not a result of my module.

Great work, this could definitely be useful.

1 Like

Seems to be broken, when I run it i get this:

Any fixes?

Are you sure you haven’t modified the module in any ways? As far as I know, it should work completely fine as long as the instructions are properly followed.

All I did was import the model from toolbox, add the geojson, and run it.

Day (something) of Quarantine and they are already making a city in Roblox.

Jokes aside, this is really cool. I assume you used another programming language to get data from Google Earth .com?

It is OSM. You can see the steps to extracting the data in the post!

1 Like