2

Does anyone know of an effective workflow to convert 3d-enabled shapefiles to X3D format? I have several projects containing anywhere from 10 to 5000 features (building sections) that I would like to convert into X3D format. The shapefiles in question have topheight and baseheight attribute fields.

I have read these:

How can a 3D model of a building be displayed in a web-browser?

Georeferenced 3D Model Import

I have browsed this list of applications and resources to see what is available for import/export/conversion. I have experimented with ArcGlobe, exporting my shapes to COLLADA using Layer 3D to Feature Class and Multipatch to Collada. This tool limited me to exporting building sections or contiguous building sections (whole buildings). I then used Meshlab to convert COLLADA to 3DX. The only downfall with this is that I would have to convert thousands of building files to 3DX.

I would be interested in hearing of other workflows for similar situations.

3
  • meshlab can do batch processing, if i recall correctly.
    – til_b
    Commented Jun 13, 2013 at 19:35
  • 1
    Have you looked into FME? Commented Jun 13, 2013 at 20:01
  • 1
    Yes, FME can read Shape data and write to X3D so should be able to do this easily enough. Our web page has a full list of supported formats at: safe.com/fme/format-search Commented Jun 13, 2013 at 20:13

2 Answers 2

2

Clearly you need some batch processing method. Unfortunately, I don't recall Meshlab having any means of natively reading shapefiles so some coding there would be necessary. Meshlab is a great package but I've never tried extending it as I tend to use Blender.

FME has been recommended and if you have it (perhaps as the Data Interoperability Suite) then that is an excellent route.

Though not quite batch processing, using ArcScene, you could merge your building files or have them in multiple layers and export to VRML and thereby reduce your manual input. VRML is X3D's older cousin and is viewable in most X3D viewers and modelling packages. What I never tried was to see if you could have a script in ArcObjects or ArcPy load the shapefiles and export to VRML automatically. My gut feeling is you can't... but like I said, I never tried to do it, so who knows?

If you don't have FME and the ArcScene route is too 'clunky', then there is not such a direct route from a shapefile to X3D unless you don't mind a bit of programming. The X3D format is pretty straightforward, so, using ArcPy or the Python GDAL libraries (other programming languages are available). It is a simple enough task to either write a script to pull the shapefile geometry into a modelling package and have it spit out the X3D or write not much more code and have your script just write the X3D file directly. You can then configure this as a batch process and with a bit of multiprocessing, rattle through your files quickly. It also shouldn't be too hard to set face normals, texture vertices and lights too.

If I had a LOT of files to work through and especially if there is the possibility of having to repeat the process in the future, I think I would opt for the stand-alone, home-grown version. That said, if you are intending to go further and edit your scene in a 3D package, then finding one which supports Python or one of the other GDAL APIs would be beneficial. You then adapt your code to pull the geometry in to the modelling package in its internal format (I do this a lot with Blender).

A related aside:
For other sorts of data you can actually use Excel to create much of your X3D/VRML code! This is a nasty but effective little trick I used to use for rapidly creating scenes with thousands of trees or other instantiated objects represented by point data from shapefiles. Use SpatialAnalyst to get the Z value from your DEM and export your data as a CSV with X,Y and Z columns. Open the CSV in Excel (or OpenOffice Calc) and insert some columns so you can add code for a transform node for one row ending with open brackets in the column before your XYZ columns. Then close all your brackets at the other end. Auto fill down for all your rows. In your first point, reference your model that is to be placed at the point (e.g. a tree). In your second point, instantiate the first point and then copy/fill down for all remaining points. Add a few rows at the top of the spreadsheet and insert the VRML/X3D header line and then save as a text file but give it the appropriate extension. This method is quick and dirty and gets results. You can even get fancy and randomize your output to (say) jitter your points, rotate them about the Z axis or apply a random scaling factor (thus making your trees or whatever look a bit more natural) and you can do this by using applying a formula to appropriate cells in Excel.

8
  • Thank you for the response MappaGnosis. Fortunately I have access to FME and am currently looking into it. I also wanted to clarify that my final product does not have to be individual building shapes. I think it would be easier if all the buildings were in the same file, but as individual records, if this is possible. In ArcScene, the shapes are already contained in a single file, until I convert them to COLLADA format.
    – Barbarossa
    Commented Jun 14, 2013 at 14:07
  • If you convert to VRML you should have a new transform node for each record and I would expect something similar in Collada (though I don't have a copy of SrcScene to hand to test). You will probably find that all the buildings are grouped under one parent node but their geometry should be separate (unless they are multipolygons in the original data of course). Commented Jun 14, 2013 at 14:49
  • I can successfully convert 3d shapefiles (multipatch) into Collada using ArcGlobe/ArcScene and then into .x3d using X3D-Edit 3.3. However, these x3d files do not have a global coordinate system attached to them, only a local (relative) coordinate system, from what I understand. When creating the collada files, an additional kml file was created for each shape. Is there a way to somehow mesh the dae and kml into an x3d? I'm open to writing code (with my limited capacity) that will enable me to create x3d from shapefiles. There is limited documentation about geolocating X3Ds. Suggestions?
    – Barbarossa
    Commented Jun 17, 2013 at 20:27
  • To geolocate your export from ArcScene, the origin (0,0,0) is exactly in the center of your ArcScene Scene. So, determin what that is and everything will be relative to it. Commented Jun 18, 2013 at 11:24
  • 1
    Thank you MappaGnosis. You have been most helpful. I haven't solved my conundrum as of yet, but your response has put me on the right path. I am not very familiar with xml so that has become a brick wall. I was hoping for a more straight forward path to get my 3d shapes into a georeferenced x3d, but I will keep you posted.
    – Barbarossa
    Commented Jun 18, 2013 at 15:38
-2

Check out "The X3D geospatial component: X3DOM implementation of GeoOrigin, GeoLocation, GeoViewpoint, and GeoPositionInterpolator nodes" (http://dl.acm.org/citation.cfm?id=2775315&CFID=558021087&CFTOKEN=20562928 - may be pay walled).

1

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.