[GRASS-user] geogrid not smooth in ps.map output

Hi,

I'm making a map for inclusion in a manuscript. I have the basic layout
set, using the wx display system: https://flic.kr/p/CThHdE

Not perfect, but I can tweak the placement of labels in Inkscape.
However, when I try to transfer the code from d.mon to ps.map, the
gridlines become 'jointed', rather than smooth curves:
https://flic.kr/p/DEp7zL

I've tried setting the region resolution, but it doesn't seem to change
anything. How can I plot geographic grids as smooth curves with ps.map?
Or is there a better workflow to accomplish this?

Best,

Tyler

GRASS GIS 7.0.3

d.mon code:
---------------

d.vect map=provinces_ca@PERMANENT type=boundary
d.vect map=usa_country@PERMANENT type=boundary
d.vect map=boxes@PERMANENT type=point icon=basic/box fcolor=180:180:180
size=8
d.vect map=triangles@PERMANENT type=point icon=basic/triangle
fcolor=250:250:250 size=9

ps.map input:
-----------------

# g.region n=2000000 s=-1000000 e=3100000 w=-2550000 res=200

vlines provinces_ca
type boundary
color black
width 0.5
end

vlines usa_country
type boundary
color black
width 0.5
end

geogrid 15 d
color grey
numbers 1 grey
end

vpoints triangles
type point
color black
fcolor 200:200:200
size 4
symbol basic/triangle
width 0.5
end

vpoints boxes
type point
color black
fcolor 100:100:100
size 3
symbol basic/box
width 0.5
end

paper
width 6
height 4
left 0.1
right 0.1
top 0.1
bottom 0.1
end

--
plantarum.ca

Tyler,

The general issue (also exists in QGIS) is that grid/graticule creators
commonly only create nodes where 2 lines intersect. The solution
generically is that you need to increase the node density of each line
so that there are more points to bend the line along when projected.

As an example (or perhaps a solution) you can see my script that creates
such dense lines. It's a python script to create WGS 84 dense lines that
re-project well at world scales. I've written it to be standalone, or
it's available in QGIS Processing, you could also adapt it to GRASS
since it's pure python and writes a geojson file (ogr can read that).
https://github.com/wildintellect/pyGraticule

Enjoy,
Alex

On 02/05/2016 11:08 AM, Tyler Smith wrote:

Hi,

I'm making a map for inclusion in a manuscript. I have the basic layout
set, using the wx display system: https://flic.kr/p/CThHdE

Not perfect, but I can tweak the placement of labels in Inkscape.
However, when I try to transfer the code from d.mon to ps.map, the
gridlines become 'jointed', rather than smooth curves:
https://flic.kr/p/DEp7zL

I've tried setting the region resolution, but it doesn't seem to change
anything. How can I plot geographic grids as smooth curves with ps.map?
Or is there a better workflow to accomplish this?

Best,

Tyler

GRASS GIS 7.0.3

d.mon code:
---------------

d.vect map=provinces_ca@PERMANENT type=boundary
d.vect map=usa_country@PERMANENT type=boundary
d.vect map=boxes@PERMANENT type=point icon=basic/box fcolor=180:180:180
size=8
d.vect map=triangles@PERMANENT type=point icon=basic/triangle
fcolor=250:250:250 size=9

ps.map input:
-----------------

# g.region n=2000000 s=-1000000 e=3100000 w=-2550000 res=200

vlines provinces_ca
type boundary
color black
width 0.5
end

vlines usa_country
type boundary
color black
width 0.5
end

geogrid 15 d
color grey
numbers 1 grey
end

vpoints triangles
type point
color black
fcolor 200:200:200
size 4
symbol basic/triangle
width 0.5
end

vpoints boxes
type point
color black
fcolor 100:100:100
size 3
symbol basic/box
width 0.5
end

paper
width 6
height 4
left 0.1
right 0.1
top 0.1
bottom 0.1
end

On Fri, Feb 5, 2016 at 8:08 PM, Tyler Smith <tyler@plantarum.ca> wrote:

Hi,

I'm making a map for inclusion in a manuscript. I have the basic layout
set, using the wx display system: https://flic.kr/p/CThHdE

Not perfect, but I can tweak the placement of labels in Inkscape.
However, when I try to transfer the code from d.mon to ps.map, the
gridlines become 'jointed', rather than smooth curves:
https://flic.kr/p/DEp7zL

I've tried setting the region resolution, but it doesn't seem to change
anything. How can I plot geographic grids as smooth curves with ps.map?
Or is there a better workflow to accomplish this?

What about using v.mkgrid and then reprojection it using vertex
densification as provided by v.proj?

See for example
http://courses.neteler.org/grass-gis-7-vector-data-reprojection-automated-vertex-densification/

Best,
Markus

On Sun, Feb 7, 2016, at 05:17 PM, Markus Neteler wrote:

On Fri, Feb 5, 2016 at 8:08 PM, Tyler Smith <tyler@plantarum.ca> wrote:
>
> How can I plot geographic grids as smooth curves with ps.map?

What about using v.mkgrid and then reprojection it using vertex
densification as provided by v.proj?

Thanks Markus,

That sounds reasonable. However, based on your and Alex's comments, I
did some digging into ps.map. It appears the resolution of grid lines is
hardcoded to use 10 vertices across the length of each grid line, via:

  #define SEGS 10

in do_geogrid.c. I changed this to 100 and recompiled, and now I have
nice smooth grids. This suggests that perhaps a permanent fix would be
to replace the SEGS macro with an additional argument to the geogrid
command in the ps.map instruction set. That way users could tune the
value to suit the map they are preparing. Alternatively, some more
sophisticated calculation could be used to determine the number of
segments. Or it could just be set to a sufficiently high number.

I can look into one or more of these options if it sounds generally
useful; I don't yet understand how the ps.map arguments are parsed, but
it looks to be within my capabilities to make the change.

Best,

Tyler

On 08/02/16 16:48, Tyler Smith wrote:

On Sun, Feb 7, 2016, at 05:17 PM, Markus Neteler wrote:

On Fri, Feb 5, 2016 at 8:08 PM, Tyler Smith <tyler@plantarum.ca> wrote:

How can I plot geographic grids as smooth curves with ps.map?

What about using v.mkgrid and then reprojection it using vertex
densification as provided by v.proj?

Thanks Markus,

That sounds reasonable. However, based on your and Alex's comments, I
did some digging into ps.map. It appears the resolution of grid lines is
hardcoded to use 10 vertices across the length of each grid line, via:

   #define SEGS 10

in do_geogrid.c. I changed this to 100 and recompiled, and now I have
nice smooth grids. This suggests that perhaps a permanent fix would be
to replace the SEGS macro with an additional argument to the geogrid
command in the ps.map instruction set. That way users could tune the
value to suit the map they are preparing. Alternatively, some more
sophisticated calculation could be used to determine the number of
segments. Or it could just be set to a sufficiently high number.

I can look into one or more of these options if it sounds generally
useful; I don't yet understand how the ps.map arguments are parsed, but
it looks to be within my capabilities to make the change.

Try attached diff as a starting point. Certainly needs some more clean-up and inclusion in the documentation in ps.map.html.

Moritz

(attachments)

ps_map_geogrid_segments.diff (1.21 KB)