Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Randomized symbology for forests work #6

Closed
4 of 5 tasks
pnorman opened this issue Jan 17, 2015 · 8 comments
Closed
4 of 5 tasks

Randomized symbology for forests work #6

pnorman opened this issue Jan 17, 2015 · 8 comments
Labels

Comments

@pnorman
Copy link
Owner

pnorman commented Jan 17, 2015

upstream gravitystorm#938

  • Generate SVG with @imagico tool
  • Add forests to landcover overlay
  • Identify cause of blurry pixel alignment
  • Recolor overlay
  • Recolor fill pass 2
@pnorman
Copy link
Owner Author

pnorman commented Jan 17, 2015

image

Possible cause - maybe clip off the end, or adjust tool settings?

@imagico
Copy link

imagico commented Jan 17, 2015

I am not exactly sure what you mean by blurry pixel alignment.

In any case when redesigning the forest pattern i think moving to a different symbology would be a good idea. Taking leaf_type into account is not possible in the short term but the current symbol implying coniferous trees does not seem optimal.

@pnorman
Copy link
Owner Author

pnorman commented Jan 18, 2015

I am not exactly sure what you mean by blurry pixel alignment.

image

White background added for clarity.

The SVG for each symbol is

<g><path d="m 4,0 -3.25,3.25 0.75,0.75 2.5,-2.5 0,2.5 
-3.25,3.25 0.75,0.75 2.5,-2.5 0,5.5 
1,0 0,-5.5 2.5,2.5 0.75,-0.75 -3.25,-3.25 0,-2.5 
2.5,2.5 0.75,-0.75 -3.25,-3.25 z" />

<path d="m 12.5,0 a 3,3 0 0,1 0,6 l 0,-1 
a 2,2 0 0,0 0,-4 
a 2,2 0 0,0 0,4 l 0,1
a 3,3 0 0,1 0,-6
z" />
<path d="m 12,5 l 1,0 0,6 -1,0 z"/>
</g>

A SVG was created with your tool, pixel aligned.

The SVG from your tool was converted to PNG with inkscape -e forest.png -y 0 forest.svg

All symbols are misaligned by the same approximately quarter-pixel. As the left edge extends a quarter-pixel, I was thinking it could be a cause.

@pnorman
Copy link
Owner Author

pnorman commented Jan 18, 2015

To compare, @gravitystorm's outdoors symbology.
image
image

One cool approach would be to have relaxed randomly displaced patterns with randomly selected sizes, but that's beyond what I'm going to attempt for now.

@pnorman
Copy link
Owner Author

pnorman commented Jan 18, 2015

Adding an offset with the tool fixed the pixel alignment - but I still prefer the corners chopped.

I also got better results with the conversion by converting in gimp to 8192x8192 and then down-scaling with Lanczos to 512x512

image
image

@pnorman
Copy link
Owner Author

pnorman commented Jan 18, 2015

Some more adjustments gets it sharper with
image

from

<g>
<path d="m 3.5,0 -3.5,3.5 0,0.5 0.5,0 2.5,-2.5 0,2
-3,3 0,0.5 0.5,0 2.5,-2.5 0,5.5 
1,0 0,-5.5 2.5,2.5 0.5,0 0,-0.5 -3,-3 0,-2
2.5,2.5 0.5,0 0,-0.5 z" fill="rgb(108,158,74)"/>

<path d="m 10.5,0 a 2.5,3 0 0,1 0,6 l 0,-1 
a 1.5,2 0 0,0 0,-4 
a 1.5,2 0 0,0 0,4 l 0,1
a 2.5,3 0 0,1 0,-6
z" fill="rgb(108,158,74)"/>
<path d="m 10,5 l 1,0 0,5 -1,0 z" fill="rgb(108,158,74)"/>
</g>

pnorman added a commit that referenced this issue Jan 18, 2015
This adds a random symbology for forests, lightens forests, and
unifies natural=wood and landuse=forest rendering.

Using http://www.imagico.de/map/jsdotpattern.php a random pattern
was generated from the SVG

    <path d="m 3.5,0 -3.5,3.5 0,0.5 0.5,0 2.5,-2.5 0,2
    -3,3 0,0.5 0.5,0 2.5,-2.5 0,5.5
    1,0 0,-5.5 2.5,2.5 0.5,0 0,-0.5 -3,-3 0,-2
    2.5,2.5 0.5,0 0,-0.5 z" fill="rgb(58,135,39)"/>

    <path d="m 10.5,0 a 2.5,3 0 0,1 0,6 l 0,-1
    a 1.5,2 0 0,0 0,-4
    a 1.5,2 0 0,0 0,4 l 0,1
    a 2.5,3 0 0,1 0,-6
    z" fill="rgb(58,135,39)"/>

This was then converted with GIMP into a PNG which Mapnik can use.

The forest fill was lightened, but there are now darker symbols on.

This necessitated adjusting the text colour for forests, which was
done in Lch colour space. The frequent symbols also required some
halo adjustments.

There are multiple interpretations in use of landuse=forest vs.
natural=wood. Rather than attempt to sort this out when the tagging
has not settled, the same appearance is used for both.

This commit doesn't use different symbologies for different types
of forests (mixed/coniferous/broad_leaved/palm) (gravitystorm#822), but that
can be considered later.

Fixes gravitystorm#938
Fixes forest part of gravitystorm#937
Closes #6
@imagico
Copy link

imagico commented Jan 19, 2015

Yes, offset calculation is not working properly for pixel aligned rendering - see imagico/jsdotpattern#1

As far as rendering the SVG is concerned - you should try the options offered by ImageMagick:

convert -density 720 trees1.svg -scale 12.5% -depth 8 trees1a.png
convert -density 720 trees1.svg -filter Sinc -resize 12.5% -depth 8 trees1b.png
convert -density 720 trees1.svg -adaptive-resize 12.5% -depth 8 trees1c.png
convert -density 720 trees1.svg -filter box -resize 12.5% -depth 8 trees1d.png

For more options see:

http://www.imagemagick.org/Usage/resize/
http://www.imagemagick.org/Usage/filter/

@pnorman
Copy link
Owner Author

pnorman commented Jan 19, 2015

As far as rendering the SVG is concerned - you should try the options offered by ImageMagick:

convert -density 720 trees1.svg -scale 12.5% -depth 8 trees1a.png
convert -density 720 trees1.svg -filter Sinc -resize 12.5% -depth 8 trees1b.png
convert -density 720 trees1.svg -adaptive-resize 12.5% -depth 8 trees1c.png
convert -density 720 trees1.svg -filter box -resize 12.5% -depth 8 trees1d.png

These look to be effectively the same as gimp - just different ways of handling the resize/filter. Lanczos and cubic in gimp are both good options, and I think at this point to get improved sharpness I'd get more out of doing the SVG -> bitmap conversion by hand for one symbol

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants