Which coordinate system in CE scene to integrate city in Unity scene with GPS points?

02-10-2021 05:59 AM
New Contributor

Dear all,

I am working with Unity and imported some GPS Points that include some environmental parameter. I want to add a city I build with CityEngine into my Unity scene. If I do so, the GPS points and the city dosen't fit. I think I would have to use a different coordinate system for the scene in CityEngine. Can someone tell me which one is the right one here?

Thanks a lot!

0 Kudos
9 Replies
by Anonymous User
Not applicable

CityEngine uses WGS84 to bring the "GetMapData" in from OpenMapsData. It looks like it can also reproject in CityEngine to UTM and MGRS.  Click the camera button and go down to View Coordinate System.  If you have a projection outside of these 3 then you will have to go to Arcgis Maps (or Pro). 

There are a lot of reprojection tools in Arcgis Maps.  You will just have to make sure that your base map is projected  to the same coordinate system as your gps points.  I would reproject the GPS coordinates to WGS84.   Then you can reimport that into CityEngine and go from there.  Then export it Unity.    

There might be several other workflows, but that is the one I would try.   There is a beta version of Arcgis Maps (direct) to Unity, that might be worth a go.

0 Kudos
New Contributor

Thank you for your help. In CE I have selected the coordinate system CE CS in meters - but it still doesen't fit.
I import the GPS data which is stored as csv-file directly in Unity and place some spheres on the GPS position. The proportions of the CE generated city and the GPS points do not match at all. The city is about ~10000 larger. If I compensate the size ratio by scaling, the GPS points still do not match the CE city.

I don't get it... :see_no_evil_monkey: Do you have an idea?

0 Kudos
by Anonymous User
Not applicable

Learned something new thanks to your question, and that's why I try.  Turns out you can do reprojection in CityEngine to more than just those 3 in the camera settings.  


Go to Edit > Preferences > Scene to change the projection in CityEngine. 

More importantly to answer your question, do you happen to know what datum your GPS receiver captured in?   Knowing that might save you a lot of time.   The default is usually UTM/WGS84, but it's possible yours was different.

To add to this: "The latitude and longitude of your current position are different for different datums. For example, the Cathedral in central Christchurch is at 172.63658E, 43.53103S in WGS-84 coordinates and 172.36344E, 43.53270S in Geodetic 1949 coordinates. If you are working with latitude/longitude coordinates and you get an error of a couple of hundred metres, you most likely are using the wrong datum."

If you don't know and you can't find out, try changing your scene's projection to these common projections and maybe you'll get lucky:

  • Projected>World>WGS84 Web Mercator
  • Projected>UTM>WGS84,<yourhemisphere>,<your time zone>
  • Projected>UTM>NAD1983,<your time zone>
0 Kudos
New Contributor

Thanks again.

I changed the coordinate system in CE (it dosen't look like there is something changed when I am doing so), export the model, and import it in Unity. All the models dosen't differ at all. Looks like CE is ignoring the coordinate system change and also when exporting. Do I have to state this somewhere separately?

0 Kudos
by Anonymous User
Not applicable

It's more likely that Unity is ignoring the coordinate system and projections as they use a simple scene coordinates and the projection is basically an infinite flat plane, unless you are running some additional custom script/plugin to tell Unity how to handle the georeferenced data.  That's why I recommend using a GIS application (including CityEngine) to line everything up first, then export to Unity. 

I would find your GPS datum and coordinate system,

Then either, start a new project in CityEngine using the scene wizard, set the coordinate system to that of your GPS data, or, take your existing City and set the scene to that of GPS coordinate system (CS).  Then import the GPS data into CityEngine, hopefully it lines up with your city (it should if you know your CS), build your city/import your city, then export it Unity, where it will still be lined up but it won't be projected to real world coordinates unless you specifically did something extra like a plugin/script/etc. 

If that doesn't work, then your question isn't really a CityEngine question.  It could be a Unity question if you are trying to find a script/plugin to handle GPS projections because you are trying to line them up in Unity.  It could also be a question for GPS users with experience in lining up datums/coordinate systems, especially if you don't know your GPS's datum/coordinate systems.

New Contributor

@Anonymous User wrote:

It's more likely that Unity is ignoring the coordinate system and projections as they use a simple scene coordinates and the projection is basically an infinite flat plane, unless you are running some additional custom script/plugin to tell Unity how to handle the georeferenced data. 

That could be the solution to the riddle...

I already imported the GPS data in CE and then export it in the same way as the generated city and that worked fine. The reason I wanted to import the GPS points in Unity was that I want to be able to change e.g. size and color of the single points according to their values they bring with them in the csv.

0 Kudos
by Anonymous User
Not applicable


You can do that in CityEngine.  

Tutorial 21: CSV import—ArcGIS CityEngine Resources | Documentation

Here's  a sample of a code I am writing for stormwater calculations.  It colors them based on "LandUseAssign", which then connects to the associated 3rd column in my spreadsheet (LandUse_data[0:numLandUse-1,2]) which is the color.  Also, you could do a column for scale, relative to 1.  Then under "Start" rule write (for reference: s('x,'y,'z)) and (LandUseType is reference to my code):


Just copy this and replace all the terms relative to your data.  Add columns by creating constants with column assignments relative to the first column.

For example: 

const colors = LandUse_data[0:numLandUse-1,2]  (replace the 2 with a 3,4,5 etc. to match column and rename the const "colors" to desired column title.  For you, you will create const Scale (as I have done just above in scale rule)

The print function is very valuable to learning this and keeping things in line.  You can print every function and constant to see what is happening.




 * File:    SCS_Method_Calculator.cga
 * Created: 8 Feb 2021 20:00:37 GMT
 * Author:  cheeb

version "2020.1"

const LandUse_filename = "rules/rules/Snippets/GreenInfrastructure/SCS_Runoff_Coefficients.csv"
const LandUse_data = readStringTable(LandUse_filename)
const numLandUse = nRows(LandUse_data)

attr LandUseTypes = LandUse_data[0:numLandUse-1,0]

const CurveNumber = floatArray(LandUse_data[0:numLandUse-1,1])
const colors = LandUse_data[0:numLandUse-1,2]

RunoffCurve(LandUseType) = 
	_RunoffCurveFromIndex(findFirst(LandUseTypes, LandUseType))
	_RunoffCurveFromIndex(LandUseTypeInd) =
		case LandUseTypeInd==-1:           0
		else:                        CurveNumber[LandUseTypeInd]

Color(LandUseType) = 
	_ColorFromIndex(findFirst(LandUseTypes, LandUseType))

	_ColorFromIndex(LandUseTypeInd) =
		case LandUseTypeInd==-1:           "#FFFFFF"
		else:                        colors[LandUseTypeInd]

attr LandUseAssign = "Unassigned"





0 Kudos
New Contributor

Thanks again 🙂 I am not sure if I understood you correctly. I know I can use parameters in CE to set size and color (I converted csv to shape-file in ArcGIS und used that). But the thing is, I want to keep the parameters of each GPS point in Unity, e.g. because I want to choose whether the size of an object is based on the value of parameter 1 (e.g. temperature) or parameter 2 (e.g. humidity) or parameter x ... during runtime.

Maybe it could be a solution to convert/project the GPS points in ArcMap to a coordinate system which is similar "a simple scene coordinates and the projection is basically an infinite flat plane"... and then import the resulting table of the shapefile in Unity and use the converted coordinates and the "passed on" parameters.

0 Kudos
New Contributor

I am sorry, I am getting out of CE topic with this approach, I guess I should go to Unity forum 😉

0 Kudos