Geographic Information Systems Stack Exchange is a question and answer site for cartographers, geographers and GIS professionals. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I have a road network in a PostGis database (db_routing). In another database (db_environment), I have some spatial features of the surrounding environment (trees as points and water bodies as polygons for example).

I would like to assign costs to my road segments depending on the surrounding environment. I envisage two possibilities:

  • through a raster: I can create a raster and each cell will have a cost depending on the features from db_environment it contains (trees density and presence or no of water for example). Then, I would have to give a cost to the road segments depending on the raster cells they intersect.

  • through a vector layer: I could run a proximity analysis around each of my road segments, by creating a buffer around it and looking at the features from db_environment contained in this buffer.

It seems to me that it would be easier to create a raster (by using simple mathematical additions to take the different cost into account, instead of performing spatial clips with a vector).

Do you have ideas on this, or examples of similar projects ?

Thanks in advance

Some thoughts on the pros and cons of each method:

  • Raster

    • Advantages: Easy to add incrementally more and more cost factors by using simple mathematical operations
    • Disadvantages: Complex to choose the right pixel size, and to find a proper way to transfer this data to the road network vector
  • Vector

    • Advantages: Efficient to perform proximity analysis
    • Disadvantages: Bad representation for continuous data
share|improve this question
Something like : update r set cost = count(t.the_geom) FROM roads r, trees as t WHERE ST_Contains(ST_buffer(r.the_geom) , t.the_geom) , i dont see whats hard on that. Ofcourse you can create raster too , but if you use pgRouring you still have to use vectors to route , so st_intersect changes to some raster operation – simplexio Apr 11 '13 at 13:32
I agree with you, the queries are not the problem as they will not be too complex in any way. My question concerns more the good practices in proximity analysis – FredB Apr 11 '13 at 13:39
up vote 1 down vote accepted

I went finally for a mix of raster and vector, using a vector grid, that has several advantages :

  • One column per cost factor, to be able to combine these factors in different combinations later
  • I can keep the grid unchanged and only update the road network : the environnement in a city doesn't change often
  • Easy to transfer the costs from the grid to the road network by simply running intersection analysis
share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

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