Smathermather's Weblog

Remote Sensing, GIS, Ecology, and Oddball Techniques

Archive for July, 2008

POV-Ray for viewsheds code

Posted by smathermather on July 30, 2008

global_settings {
max_trace_level 1
}

#include “shapes.inc”
#include “colors.inc”
#include “textures.inc”

height_field {
png “c:\temp\povray\n2225625.png” // 16-bit integer digital elevation
water_level 0.0

texture {
pigment {
image_map { png “C:\temp\povray\n2225625_drape.png” map_type 0 interpolate 2 once// Aerial
rotate x*90
}
}
scale <5000, 65536, 5000>  // Scale to real world size
translate <2224868,0,625008>  // Translate to location in Ohio state plane
}

/// Orthographic Camera
camera {
orthographic
location <2227368.0, 6000, 627508>
look_at <2227368.0, 0, 627508>
right 5000*x //x size of view  (feet)
up 5000*y // y size of view  (feet)
}

// Observer Points

light_source { <2227885, 720, 625464> color Cyan }
light_source { <2228247, 727, 626277> color Yellow }
light_source { <2228091, 729, 626761> color Magenta }

Posted in POV-Ray | Tagged: , , , , | Leave a Comment »

Follow on to POV-Ray for GIS Analyses–metametacode, no code yet, sorry!

Posted by smathermather on July 30, 2008

Ok, here’s the basic idea– we have an orthographic scene with a height_field object scaled to real world units. The observers in the viewshed become points of light, thus for each observer, we “light” the areas visible from each observer, render, and boom, viewshed created. In addition, if we have three or fewer view points, we can render them in, say cyan, yellow, and magenta, and thus tell which observer points can view a given location. But I digress. I keep leaving the actual code at work so I’ll start out by giving you the

Povray Viewshed Calculation Meta-Metacode:

In a Povray height_field, input elevation images are scaled 1 unit in all 3 dimensions. In our case, the input image is 5000 feet on a side in real world units. So, we multiply x and y dimension by 5000 to scale it. Since the unit values in the Z-direction are scaled to one as well, and they were input as 16-bit, that means that povray effectively divides the data by 65536, so we multiply by 65536 to get back to elevation in feet. Now our x, y, and z dimensions are scaled appropriately to each other.

Since we’re working with geographic data, well put it back in the real world (just in case we want to put other data in our system as well), in this case the Ohio State Plane North NAD83 HARN (feet) projection. So, translate to location in real space (the state plane centroid of the image) and set an orthographic camera above it with an image plane equal to the x and y dimensions. The orthographic camera prevents distortion from perspective, so we retain a flat map. (Side note: I’m contemplating using an orthographic camera and DEM to correct for terrain distortions in uncorrected imagery (and maybe shading as well), but that will take more thought, and may become another post).

Ok. Now to calculate viewshed from a point, place a point light in the scene at the location in question. Render, and boom, we have a viewshed from a point. Want a few points, add a few more point lights. Want to constrain the effect in the x, y, or z direction, add some opaque baffles (I haven’t done this in my code yet), or directional lights.

Finally, just for kicks, we can drape an aerial image on top, and our viewshed lights will only light the parts of interest, something I’ve never seen done in a GIS. But again, (see previous post) the main point is to be able to simulate vegetation, buildings and other comprehensive aspects of the scene, not just a digital terrain (elevation) model. If that’s all we wanted, a GIS would suffice. So, next step, add buildings and trees. Long term, I’d like to do this in Physically Based Renderer (PBRT) or (now that I know it exists…) LuxRender. Heck with physically based rendering, we can do some inverse modeling of physical/chemical characteristics, or WiFi placement optimizations. But again, I digress… .

Posted in POV-Ray | Tagged: , , , , , , , | Leave a Comment »

POV-Ray for GIS Analyses

Posted by smathermather on July 25, 2008

Well, I tried something that so far has been a real success. I did a viewshed analysis in POV-Ray. Nothing significant in that analysis– it’s just a topography based analysis, just like one might do in GRASS or ArcGIS. But what is interesting, is now I can add buildings (also not hard in a GIS) and trees (which can be quite hard to add). Suddenly the viewshed including trees need not be a solid wall of trees, but something partially penetrable and complex. I’ll do this in part with some new lidar data I have… and update here. In the next couple days, I’ll post the code and results I have so far. The code is very simple and not terribly flexible yet– just a test of concept, but we’ll see where we can go with this.

Posted in POV-Ray | Tagged: , , , , | 1 Comment »

PostGIS Onesie

Posted by smathermather on July 20, 2008

Nothing more appropriate for the baby elephant than to be displayed on a onesie.

Nothing more appropriate for the baby elephant than to be displayed on a onesie.

Well, I have to put it out there: is this an original, the one and only PostGIS onesie? My son was born recently, and as he was sleeping quietly, I surfed to the PostGIS website. One look at that baby elephant icon, and another to our newborn, and I realized I had the perfect inspiration, so time to go make my own onesie, and start a FOSS GIS blog.

FYI, I’m working on a PostGIS/GeoServer/OpenLayers set of services for my day job, but this probably doesn’t count as work.

Posted in PostGIS | Tagged: , , , | Leave a Comment »