python-mapnik icon indicating copy to clipboard operation
python-mapnik copied to clipboard

MarkersSymbolizer's transform and allow_overlap attributes have no effect.

Open ardean80 opened this issue 9 years ago • 3 comments

The following python-mapnik code should draw more overlapping markers on my map:

...
markers_icon_symbolizer = mapnik.MarkersSymbolizer()
markers_icon_symbolizer.spacing = 100
markers_icon_symbolizer.allow_overlap = "true"
markers_icon_symbolizer.ignore_placement = "true"
...

The problem is that, for two or more very close points, only one marker is drawn, that is not what I expect. I even used some variants (spacing = 0, spacing = 1, allow_overlap/ignore_placement = "true"/"yes"/True, etc.), but I still can not get what I need.

Besides, I need markers to be shifted upward, compared to the coordinates of the points they represent, so I used the transform attribute:

markers_icon_symbolizer.transform = "translate(0 -50)"

I also tried the comma separator ("translate(0,50)") but nothing...it doesn't have effect, because the marker icon is always centerd on the point it represent. Is there anything I could do in order to address these issues?

ardean80 avatar Oct 12 '16 10:10 ardean80

We are running into this issue as well. I noticed this, https://github.com/mapnik/python-mapnik/issues/126#issuecomment-270682211, and decided to try and render markers by loading via mapnik XML.

data.geoson (just a set of points that are rather close to each other): https://gist.githubusercontent.com/anonymous/4ae423c570c2fb83b99df6cc32648322/raw/390a66be6e1770038bc13fc10d3c5dfeabae8448/map.geojson

Style.xml:

<Map background-color="steelblue" srs="+proj=longlat +ellps=WGS84 +datum=WGS84 +no_defs">

  <Style name="My Style">
    <Rule>
      <MarkersSymbolizer fill="#f2eff9" allow-overlap="true" ignore-placement="true" width="100" />
    </Rule>
  </Style>

  <Layer name="world" srs="+proj=longlat +ellps=WGS84 +datum=WGS84 +no_defs">
    <StyleName>My Style</StyleName>
    <Datasource>
      <Parameter name="type">geojson</Parameter>
      <Parameter name="file">data.geojson</Parameter>
    </Datasource>
  </Layer>

</Map>

test.py:

def generate_map_image_xml():
    stylesheet = 'style.xml'
    image = 'test_xml.png'
    m = mapnik.Map(600, 300)
    mapnik.load_map(m, stylesheet)
    m.zoom_all() 
    mapnik.render_to_file(m, image)
    print "rendered image to '%s'" % image

This produces the expected image with overlapping circles.

ftwillms avatar Jul 19 '17 03:07 ftwillms

Same for PointSymbolizer. This does nothing:

symbolizer.transform = "scale(5.0)"

These bindings are seriously broken. See #7, #184.

alexandervlpl avatar May 04 '18 09:05 alexandervlpl

Any updates on this? I am running into the transform issues in python as well

polinabee avatar Jul 08 '19 20:07 polinabee