1

I need to generate random points within geometries, which works quite good, but there are some small errors. Take the picture below. There are some greenish and redish Polygons(?!) which do not have any points in it, but they should. My questions is why?

To be more specific about what I do:

  • My Code uses python shapely to generate the points within polygons
  • It weights the area (green = residential) with 50%, so that more points are generated in the red (industrial), yellow (retail) and turkis (commercial) areas.
  • The Polygons are take from OSM
  • The points represent an end point of a commuter route

So are there any functions etc I can run on the polygons so that there are points generated in them? My guess is, that they are not vaild. Sample Image

UPDATE

Okay I found the problem. As you can see below the areas of interest are split. Meaning that they have parts that belong to another community. The Query I use to find the Geometries within a community looks like this:

CREATE TEMPORARY TABLE living_areas ON COMMIT DROP AS 
SELECT 
 way as geom, 
 CASE WHEN p.landuse = 'residential' THEN (0.5*ST_Area(way)) ELSE ST_Area(way) END AS area 
FROM de_osm_polygon p 
INNER JOIN de_shp_{shp!s} s ON (s.rs = %(rs)s AND ST_Within(p.way, s.geom)) 
WHERE OR landuse ='industrial' OR landuse='commercial' OR landuse='retail'

What must I change in this Query to either get the whole polygon that also is part of another community or just the part that lies within the community?

With gemeinden

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.