My first python script: getElevation & backdrop, matured into a kit. In glorious camel case :)
Important: you need to have a full python 2(.6.6) install along with the PIL module. Look here
to get a build for PIL. Or it won't work. Mac users, try your luck with this Mac build
I strongly suggest reading through the posts in this thread for support and more info to get you going.
Delete what you had before and use this instead.
Fixed the "No module named unidecode" part " and added yet another error checking routine. Should work now, but the kit is still highly experimental as usual. Things to come, major? speed increase whenever I get around working my way through the Python API. That will mean that you'll no longer be limited by Google's quota.geoKit_2013-1125.rar
Update 2013-0627: Lotsa things. 701 compatible, added OSM feature import functionality, miscellaneous stuff. Broke some things along the way probably too. Experimental release...
And added tooltip info etc. So take your time and hover over those buttons. F1 works also on some.geoKit_2013-0627.rar
Update 2012-1202: Added Takumi's routine that takes care of siteDir and PIL troubles. If you have Python installed in a different directory than the one listed in the siteDir variable in the geoLauncher script, Modo will ask you to locate the PIL.pth file. You should browse to the location and select that file. Smooth sailing afterwards, hopefully. a BIG thank you to Takumi san for helping out.
Also added a checking routine that will warn you if the mesh layer is empty and it'll exit gracefully.geoKit 2012-1203
Update 2012-1130: It's a kit! And rewrote it completely too. By default it'll submit multiple locations per query which will allow a user to sample more elevation data on a daily basis. Added a 2 sec delay between each query by default so a user doesn't run into trouble right away. Support for vert per vert queries is still there, but the button (shift click) doesn't trigger that function yet. Same with polyline submission (control click.) Don't think there is much use for polyline anyway and it is even less accurate.
And for the backdrop part, you'll now have an option for map type too. Default is the sexy satellite style.
Still some work to do, but it works fine in most cases. If you look at the projection module I wrote, you can see it'll allow you to use a different map source for the backdrop. The functions will allow you to switch to different "coordinate" spaces if you will. Bing is certainly an option. Feel free to experiment! :)
Acces the kit by clicking on the little Luxorange globe button on the toolbar.geoKit 2012-1130
Check the path in the geoLauncher.py file and change it if needs be. Right now, it is looking at:
siteDir = "C:\\Python26\\Lib\\site-packages"
Update v1.61: Added proper error code status parsing--thanks Colas!!! :)--and figured out how long to wait if Google is bitching about too many queries, too fast. If you find yourself waiting for half a minute and you don't see a progress bar (or it doesn't move,) you're probably out of luck for the remainder of the day. Try again later or the next day. You'll also get an error window confirming the error. Other critical errors are being dealt with and if needs be, inform the user. Both progress bars now work too!
And this wraps it up. Feel free to play around and add functions. Support for multiple locations per query and polyline submission would be nice to have :)getElevation v1.61
Update v1.55: Added a controller for the map's zoom level and a function to estimate the resolution you'll be trying to create. That way you can see if you're overdoing it or not :)
Also added some things behind the scenes, to handle the exceptions.getElevation v1.55
Update v1.52: If you decide on having an image in the backdrop, click on the get backdrop button. If you want elevation, click on that one. Two different operations. The image will be added to Modo and set accordingly. Sorry for screwing up the version numbers earlier today.getElevation v1.54
Update v1.52: You can now specify a filename/type and location for the backdrop image. Also cleaned up the script and made some functions. This is getting somewhere now... Myeah, cheated on the update date :) Be sure to replace all the config files. Maybe you need to trash your Modo config too. Or else delete the getElevation entries if you know what your're doing.getElevation v1.52
Update v1.44: Added a texture map retrieval routine. It will save a PNG to "C:\Temp\" so make sure you have that folder. Not sure about Mac users, but I'll add a filerequester later on so you can specify path and filename. The filename is always something like "-47.223,3.4555.png" for now.
Be very careful not to overdo it. Currently I stick to creating sectors that are 1km² with a total of 1089 verts, and process those as I go along. The texture will be ~2500x if you stick to those dimensions.getElevation v1.44
Update v1.36: Added scene scale and an OSM map export toggle (it is off by default.)getElevation v1.36
Update v1.34: Sensor part in the URL construction didn't work (anymore?) switched back to using a "&" instead of "%26"--Google would throw an error and no elevation was being set. Fixed.getElevation v1.34
Update v1.33: you can now enter coordinates. Go to the Mesh item properties and you'll see a "Get Elevation" entry at the bottom. Keep in mind that you need to use a "." and not a "," for the decimal coordinates. Click on the button to launch the query.
What this script does is query Google maps to get elevation values returned for each selected vert in modo. Or all, if you haven't selected any.
This is the first public release and the decimal coordinates for Modo's origin are hardcoded in the script. If you want to sample another location, you should change the values in the script itself (search for "sceneLat =" and "sceneLong =".) You can use Google maps for that by RMB'ing on a spot on the map and selecting "what's here?"
So the idea is that you establish the coordinates for the origin (exactly the same as the physical sun feature,) and then you can draw planes all over the place with as many subdivisions as you need. Select verts to translate and run the script. It is now located somewhere in the Grand Canyon.
I'd suggest to use a plane which is 3 km on X and Z with 21 subdivs on each axis max, nicely centered around the origin.
Keep in mind that it can take a while (minutes) if you sample many points, so start of with something like 200 or so. The script has a error checking loop inside to keep trying until it gets a value returned. No cancel button or progress indicator yet.
From time to time you can also get a spike in your mesh (google hickup?) so just select those verts and run the script again to fix'm.
Also, when done, it will launch three urls. One to get a satellite image of the area covered, one to Open Street Map with a bounding box and one to directly get a png of the exact area. You can use the latter as a texture or backdrop (set it to fit.) Problem is that I still need to figure out a scale setting routine for a png export that sets the scale to something valid. Meaning that you might find yourself in a situation where OSM says it is too big.
So this is all clearly under heavy construction, but it works and maybe somebody out there will find it useful. I'd like to create a form for this script so you can type in geo locations and check if you'd like to have map images or not. Originally I wanted to use the physical sun geo feature but it turns out it misses a few digits to be accurate enough for this sort of thing. Bummer.
If you're a coder, do have a look and tell me where I can clean up things or make it more efficient. I started this project so I can learn a trick or two.
Finally, a big thank you goes out to my buddy Colas Fiszman for providing me with the getElevation function and the time loop trick. And for answering my questions. :)
Let's see where this will bring us...
Message edited by xtof on 11/25/2013 - 3:15 AM