Importing/referencing spreadsheet data in(to) scenes/cga scripts

07-22-2016 05:29 AM
Occasional Contributor

Is there a way to import or reference spreadsheet data in scene files or cga scripts?

I have an excel spreadsheet with building data organized by geo-references from Google maps (see figure) which I would like to use in my cga script. Basically, I want to generate existing buildings from lot shapes, using this data. It means that I need my script to query the location of the lot shape and see if there is a match with the spreadsheet, and, if so, to generate buildings based on the data in the subsequent columns.

The data was generated manually and it is not an option to use a GIS system.

Any help is much appreciated.




0 Kudos
1 Reply
Regular Contributor

You could read that table as csv with Python.

If your lots have matching LotIDs, you could use ce.getAttribute to grab the shape's LotID and use that to match the loaded csv lines and then use ce.setAttribute to append them to the shapes.

If you don't (meaning you only have your coordinates), you could instead use ce.getPosition to get the shape's position and (with some fiddling) use that as match attribute.


- the values will probably not match perfectly so you'll have to use a search radius (yuck, math)

- you probably have to convert between coordinate systems, as CE returns position in meters (yuck, much more math)

Easy solution: do it with a desktop GIS system (there are some free ones too, like QGIS), or ask someone to do it for you. It would take like five minutes. All you'd have to do is convert the XY table data to a point shape and then do a spatial join with the lot polygons.

0 Kudos