Importing Geospatial Data (vector) in Houdini

   11339   17   4
User Avatar
Member
6 posts
Joined: Jan. 2019
Offline
I'm trying to import shapefiles into Houdini to create scientific animation for a water policy scientific conference. I've managed to import just the geometry by converting the shapefiles into dxf, but this does not hold any of the descriptive attributes I will need for animation (specifically plant community names).

I've spent quite a bit of time looking online and have found a number of broken links /dead ends for different community members working on these projects, but nothing I could get working.

https://gis4design.wordpress.com/2015/11/03/houdini-exporting-3d-models-obj-shp/ [gis4design.wordpress.com]

https://github.com/danleesmith/HOU_GeoTools [github.com]

https://github.com/ttvd/houdini-sop-shapefile [github.com]


Does anyone know of an exchange file types I could try, or another workflow I could try to solve this problem? The data is VegCamp which has polygons with associated attributes. webviewer @ https://map.dfg.ca.gov/bios/?bookmark=940, [map.dfg.ca.gov] download a sample from https://map.dfg.ca.gov/metadata/ds0723.html [map.dfg.ca.gov]

I'm hoping to use Houdini in my doctoral program I start this fall, and being able to utilize shapefiles or other geodatabases would open up a lot of functionality for environmental science research and education. I've always been interested in the intersection of 3D animation and ecology. Houdini stands out with it's procedural workflow and good training resources, but if there is a better software to use please let me know.

Thank you for your time.
User Avatar
Member
6 posts
Joined: Jan. 2019
Offline
Okay after a bit of digging I think I figured it out.

You can use the node from this Github page:

https://github.com/emilsvfx/HOU_GeoTools [github.com]

As far as input for the node, if you use the newest version of QGIS (3.6.1) to export from shapefile to GeoJSON then it might not work because it formats the polygons as “type”: “MultiPolygon” instead of “type”: “Polygon”, which requires a manual fix, but I got it working using ogr2ogr from http://fwtools.maptools.org/ [fwtools.maptools.org] to convert a test shapefile into GeoJSON. This workflow keeps my string attribute fields with the correct habitat classes, which I can now use in my ecohydrology simulations, so excited!!

Attachments:
Capture.PNG (91.9 KB)

User Avatar
Member
1 posts
Joined: Feb. 2017
Offline
voidcloud
I'm trying to import shapefiles into Houdini to create scientific animation for a water policy scientific conference. I've managed to import just the geometry by converting the shapefiles into dxf, but this does not hold any of the descriptive attributes I will need for animation (specifically plant community names).

I've spent quite a bit of time looking online and have found a number of broken links /dead ends for different community members working on these projects, but nothing I could get working.

https://gis4design.wordpress.com/2015/11/03/houdini-exporting-3d-models-obj-shp/ [gis4design.wordpress.com]


So I used the contact form on Gis4Design and got a response pretty much straight away! They have a bunch of stuff on Github including the shape file OTL.

https://github.com/design-automation/houdarcs [github.com]
User Avatar
Member
6 posts
Joined: Jan. 2019
Offline
Thank you JamesKelly,

I was able to download the scripts from Github and run the installation .bat successfully, though I'm not able to get the otls running in Houdini. I had to add the otls manually where I had a couple of run time errors for missing modules, though I was able to pip install them (pyshp, state). The installation resolved those errors, but now I'm getting runtime errors for variables that are used without being initialized ('state').

I have gotten into contact with the principal investigator for tips to troubleshoot the scripts, he has been responsive but a little busy; were you able to successfully run the otls in Houdini? If it worked for you, do you have any advice? I might be missing something obvious.

I appreciate any help!

Attachments:
shape_file1.png (82.7 KB)

User Avatar
Member
385 posts
Joined: July 2018
Offline
voidcloud
Thank you JamesKelly,

I was able to download the scripts from Github and run the installation .bat successfully, though I'm not able to get the otls running in Houdini. I had to add the otls manually where I had a couple of run time errors for missing modules, though I was able to pip install them (pyshp, state). The installation resolved those errors, but now I'm getting runtime errors for variables that are used without being initialized ('state').

I have gotten into contact with the principal investigator for tips to troubleshoot the scripts, he has been responsive but a little busy; were you able to successfully run the otls in Houdini? If it worked for you, do you have any advice? I might be missing something obvious.

I appreciate any help!

i have the same problem, installed python 2.7.16 because newer versions dont work, the setup_env.bat worked, so now when i open Houdini the otls are there but i get runtime errors about missing modules, specifically shapefile and kml. I just contacted them and i m waiting for a reply. i pip installed the shapefile and state library and it didnt change anything.

Attachments:
Capture.JPG (48.6 KB)

User Avatar
Member
6 posts
Joined: Jan. 2019
Offline
papsphilip
voidcloud
Thank you JamesKelly,

I was able to download the scripts from Github and run the installation .bat successfully, though I'm not able to get the otls running in Houdini. I had to add the otls manually where I had a couple of run time errors for missing modules, though I was able to pip install them (pyshp, state). The installation resolved those errors, but now I'm getting runtime errors for variables that are used without being initialized ('state').

I have gotten into contact with the principal investigator for tips to troubleshoot the scripts, he has been responsive but a little busy; were you able to successfully run the otls in Houdini? If it worked for you, do you have any advice? I might be missing something obvious.

I appreciate any help!

i have the same problem, installed python 2.7.16 because newer versions dont work, the setup_env.bat worked, so now when i open Houdini the otls are there but i get runtime errors about missing modules, specifically shapefile and kml. I just contacted them and i m waiting for a reply. i pip installed the shapefile and state library and it didnt change anything.


I'm glad that I'm not alone with some of these problems. I will keep looking at other scripts, and I will post if I find any elegant solutions.
User Avatar
Member
385 posts
Joined: July 2018
Offline
voidcloud
papsphilip
voidcloud
Thank you JamesKelly,

I was able to download the scripts from Github and run the installation .bat successfully, though I'm not able to get the otls running in Houdini. I had to add the otls manually where I had a couple of run time errors for missing modules, though I was able to pip install them (pyshp, state). The installation resolved those errors, but now I'm getting runtime errors for variables that are used without being initialized ('state').

I have gotten into contact with the principal investigator for tips to troubleshoot the scripts, he has been responsive but a little busy; were you able to successfully run the otls in Houdini? If it worked for you, do you have any advice? I might be missing something obvious.

I appreciate any help!

i have the same problem, installed python 2.7.16 because newer versions dont work, the setup_env.bat worked, so now when i open Houdini the otls are there but i get runtime errors about missing modules, specifically shapefile and kml. I just contacted them and i m waiting for a reply. i pip installed the shapefile and state library and it didnt change anything.


I'm glad that I'm not alone with some of these problems. I will keep looking at other scripts, and I will post if I find any elegant solutions.

so i am trying something else today, but i am a bit of stuck. i converted the shapefile to csv and had to do a bit of manual work to clean it up. now i have a sequence of longtitudes and latitudes for each multipolygon and if i knew vex i would convert them to pairs of xy coordinates. Can someone enlighten us with some vex code?

Attachments:
1.JPG (151.2 KB)
2.JPG (61.3 KB)

User Avatar
Member
140 posts
Joined: July 2005
Offline
I got this to work, sort of. I wound up making a Python 2.7 Anaconda environment to get around my native pip being too old to pass the authentication on pypi.org. From there, I was able to grab the state, pyshp, kml, and geojson packages. If you don't have these packages in your PYTHONPATH, you can't read those filetypes.

I copied the state folder, geojson folder, and shapefile.py to the houdarcs/python_libs folder.

The setup_env process is borked. The repo has a bin_win_libs_64bit directory, but the setup only adds the 32bit directory to your PATH, which no longer exists in the repo. If you add that manually to your PATH variable, it should work.

Both shapfile and geojson file read data, more or less correctly. The hardest part is exporting the stuff from QGIS correctly. Pro tip: Create a boundary polygon in your vector layer export that matches the extents of your raster heightfield. That way, you can offset your map center back to the origin using the bounding information instead of a wild-ass guess or the mark 1 eyeball.
Edited by stjohn - July 9, 2019 20:34:39

Attachments:
CurvesAndHf.png (1.7 MB)

User Avatar
Member
6 posts
Joined: Jan. 2019
Offline
Thank you for your additional information. I tried shapefiles into ESRI's CityEngine and then use the Palladio plugin to get that into Houdini but it doesn't support attributes in the way I had hoped.

I'm copying over the libraries into the python_libs folder which is what the PYTHONPATH is set to, but I'm still getting the same:

Python error: Traceback (most recent call last):
File “”, line 19, in
NameError: name ‘state’ is not defined

I'm curious if this is related to something else, when I open Houdini the only phtj node I see is neat, I have to manually open one of the otl before it will show all the nodes. Do all the nodes normally show up for you with a normal installation?
User Avatar
Member
385 posts
Joined: July 2018
Offline
stjohn
I got this to work, sort of. I wound up making a Python 2.7 Anaconda environment to get around my native pip being too old to pass the authentication on pypi.org. From there, I was able to grab the state, pyshp, kml, and geojson packages. If you don't have these packages in your PYTHONPATH, you can't read those filetypes.

I copied the state folder, geojson folder, and shapefile.py to the houdarcs/python_libs folder.

The setup_env process is borked. The repo has a bin_win_libs_64bit directory, but the setup only adds the 32bit directory to your PATH, which no longer exists in the repo. If you add that manually to your PATH variable, it should work.

Both shapfile and geojson file read data, more or less correctly. The hardest part is exporting the stuff from QGIS correctly. Pro tip: Create a boundary polygon in your vector layer export that matches the extents of your raster heightfield. That way, you can offset your map center back to the origin using the bounding information instead of a wild-ass guess or the mark 1 eyeball.

Nice! do you think you could provide the steps you mentioned in a more detailed fashion? i'm having trouble following you on the python part. Also which version of Houdini are you using?
User Avatar
Member
9 posts
Joined: July 2019
Offline
Anyone figure this out? I am receiving the same error (19)…running Python 2.7.14, pip 9.0.1. Not sure if I should update or leave it. Any assistance would be appreciated. It would be really handy to be able to import .shp files directly into Houdini.
User Avatar
Member
9 posts
Joined: July 2019
Offline
Here is my error when trying to load the shape_file node.


Error
Python error: Traceback (most recent call last):
File “”, line 19, in
NameError: name ‘state’ is not defined


Last Cook
0.09 ms
Total Cooks
21
Created
30 Jul 2019 05:06 PM
Modified
30 Jul 2019 05:10 PM
Defined By
cprogram files/side effects software/houdini 17.5.293/python27/houdarcs/otls/phtj_shape_files_02.otl?Sop/shape_file


I checked my environment variables and my PYTHONPATH is set to my Python27 folder in houdini17.5 . I installed geojson, kml, state and shape packages to that location and copied those corresponding folders to the Houdini/Python27/houdarcs folder…and made sure that was also added to my PYTHONPATH environment variable. Still no dice. Any help would be huge. THX.
User Avatar
Member
6 posts
Joined: Jan. 2019
Offline
I think I figured it out, one of the authors of the Palladio extension was able help me.

Essentially you use ESRI's CityEngine (has 30-day trial):
1. Import your geospatial data
2. Copy assignRandomSeed.py from this Python code (https://github.com/Esri/palladio/blob/master/README.md#documentation)
3. Create a rule file (shapeExport.cga) with code from the previous link, add this line of code to the second to last line for your desired attribute field ‘report(“desiredAttribute”, desiredAttribute)’ and maybe add ‘ attr desiredAttribute = “ ” ’ for a string or ‘attr desiredAttribute = 0’ for an integer to the first or second line.
4. Assign the rule to all your shapes (select all of them when you assign). Run the python script
5. Under your Inspect > Shape: Connect your attributes (under shapeExport drop down) to the desired layer attribute
6. Select all and export your models as an Alembic (*.abc) file.
7. Install Palladio https://esri.github.io/palladio/ [esri.github.io] and get the Favela example Houdini project from https://esri.github.io/palladio/#examples [esri.github.io]
8. Open the Favela houdini project and go to the python node and at the line with ‘if n != “rule” and n != “seed”:’ and add in an ‘and n!= “desiredAttribute” ’
9. Replace their Alembic file with your file (in the first node).
10. If you look at the spreadsheet for your Python node it should show your attributes, at least for the primitive variables.
11. Cook your geometry at least to the Python node click on the View and press space + g to fly to your geometry.

I'm not a strong Python coder (I use R), so this took me some time to understand, but I hope it's helpful, let me know if you have any questions. Additionally the author I received help from is very responsive on Slack.

I know that CityEngine is not free, but since it is an ESRI product it has strong support for many geospatial file types. Potentially you could circumvent CityEngine if you could export an alembic file from another software like 3DS Max (or Blender?) because the alembic file type has the capacity to store Object Attributes for each polygon. The only issue would be figuring out how to import the shapefile into these other Software and retain the desired attributes and then properly exporting to .abc with these attributes.

Cheers!

Attachments:
buildCapture.png (145.6 KB)
alembic_capture.png (441.3 KB)

User Avatar
Member
9 posts
Joined: July 2019
Offline
@voidcloud - Does this enable you to directly import and parse a .shp file into Houdini? That is what I am trying to accomplish.

THX,
Jared
User Avatar
Member
2 posts
Joined: Aug. 2019
Offline
I had a similiar problem. The easiest way is to use .osm instead of shapefiles using osm_import node from Game Development Toolset https://www.youtube.com/watch?v=8YDWj0-QFVQ&ab_channel=Houdini [www.youtube.com]

and it supports attributes

I know it's not shapefiles but you can convert .shp into .osm using multiple ways (the easiest imo is using GlobalMapper but it's not free) or you can get .osm file of the same area from openstreetmap.org
User Avatar
Member
11 posts
Joined: June 2019
Offline
anyone able to get the houdarcs tools working? also getting "no module named shapefile" error
User Avatar
Member
11 posts
Joined: June 2019
Offline
stjohn
PYTHONPATH
i ve switched to py2.7, added those libs to my libs archive but now i'm getting
Error
Python error: Traceback (most recent call last):
File "<stdin>", line 92, in <module>
TypeError: int() argument must be a string or a number, not 'NoneType'

instead of the shapefile lib not found.
any suggestions?
User Avatar
Member
6 posts
Joined: Dec. 2012
Offline
mara91
I had a similiar problem. The easiest way is to use .osm instead of shapefiles using osm_import node from Game Development Toolset
Thank you friend.
Thanks for this information.
I am very grateful.
  • Quick Links