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

2016-02-07 Thread Alex Mandel
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=200 s=-100 e=310 w=-255 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
> 
> 
> 

___
grass-user mailing list
grass-user@lists.osgeo.org
http://lists.osgeo.org/mailman/listinfo/grass-user

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

2016-02-07 Thread Markus Neteler
On Fri, Feb 5, 2016 at 8:08 PM, 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?


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
___
grass-user mailing list
grass-user@lists.osgeo.org
http://lists.osgeo.org/mailman/listinfo/grass-user

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

2016-02-08 Thread Tyler Smith
On Sun, Feb 7, 2016, at 05:17 PM, Markus Neteler wrote:
> On Fri, Feb 5, 2016 at 8:08 PM, Tyler Smith  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
___
grass-user mailing list
grass-user@lists.osgeo.org
http://lists.osgeo.org/mailman/listinfo/grass-user

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

2016-02-11 Thread Moritz Lennert

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  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
Index: ps/ps.map/do_geogrid.c
===
--- ps/ps.map/do_geogrid.c	(révision 67702)
+++ ps/ps.map/do_geogrid.c	(copie de travail)
@@ -20,7 +20,7 @@
 #define CENTER 2
 
 /* number of segments in curved geographic lines */
-#define SEGS 10
+#define SEGS PS.segments
 
 static void init_proj(struct pj_info *, struct pj_info *);
 static void get_ll_bounds(double *, double *, double *, double *);
Index: ps/ps.map/getgrid.c
===
--- ps/ps.map/getgrid.c	(révision 67702)
+++ ps/ps.map/getgrid.c	(copie de travail)
@@ -225,6 +225,12 @@
 	PS.geogrid_font = G_store(data);
 	continue;
 	}
+
+	if (KEY("segments")) {
+	PS.segments = atoi(data);
+	continue;
+	}
+
 	if (KEY("width")) {
 	PS.geogrid_width = -1.;
 	ch = ' ';
Index: ps/ps.map/ps_info.h
===
--- ps/ps.map/ps_info.h	(révision 67702)
+++ ps/ps.map/ps_info.h	(copie de travail)
@@ -36,6 +36,7 @@
 char celltitle[100];
 int level;
 int grey;
+int segments;
 int mask_needed;
 int do_header;
 int do_raster;
___
grass-user mailing list
grass-user@lists.osgeo.org
http://lists.osgeo.org/mailman/listinfo/grass-user