Take the 2-minute tour ×
Geographic Information Systems Stack Exchange is a question and answer site for cartographers, geographers and GIS professionals. It's 100% free, no registration required.

I'm intesecting a polygon with a raster using PostGIS > 2.0. The outer boundary of the polygon is formed by the convex hull of polygons (building outlines plus safety margin) and the inner rings are actually the building outlines itself. In summary I want to get all the raster values that are within the polygon but are not within buildings - so all raster points in free area basically.

The problem is that even if buildings are actually adjacent, in between the buildings I get values from the raster, which are artefacts from the rastering routine of the polygons.

The query I perform looks like this:

select ST_AsText(ST_Centroid(ST_Transform((inside.geomval).geom,32633))) 
  As geomwkt, (inside.geomval).val from 
    (select ST_Intersection(rast, ST_GeomFromText('...',32633)) AS geomval 
      from elevation where ST_Intersects(rast, ST_GeomFromText('...',32633))) AS inside;

Here's an example from QGIS: buildings considered are marked in yellow, the raster data is actually the blue background:

http://i41.tinypic.com/d8z9j.png

Here's the output of the query routine, where ... is a polygon containing the convex hull of the three buildings, and the buildings itself as inner rings.

http://i42.tinypic.com/2z8zzfo.png

I want to get rid of the sample points in between the selected buildings. Unfortunately I can't easily use something like concavehull, because on a larger set of buildings (e.g. on opposite side of streets), this will not work...

Is there any way to tackle this problem?

share|improve this question
add comment

Your Answer

 
discard

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

Browse other questions tagged or ask your own question.