From: Allin C. <cot...@wf...> - 2020-04-13 21:16:51
|
On Fri, 6 Mar 2020, Ethan A Merritt wrote: [a propos Manfred Schwarb's suggestion of using GeoJSON files for geographic plotting in gnuplot] > Good call. Geojson looks quite promising. > A real parser should be easy, but even a quick pass through sed > or a text editor makes it usable. > I have posted a proof-of-principle example using US state boundary > data from a sample file on the geojson development site: > > http://skuld.bmsc.washington.edu/people/merritt/gnuplot/ Thanks for the example, Ethan. I've recently returned to this issue, exploring the shapefiles option. I've written some relevant utilities in C, designed to link against Frank Warmerdam's lipshape. (I'll be happy to share these once they're better tested.) With their help I've managed to create quite a nice map of the US states, colorized by state population levels. See http://ricardo.ecn.wfu.edu/pub/gretl/datamaps/statepop.png . But the method I'm using for the colorization is clunky and I'm sure it can be improved upon. Here's my input file: <gnuplot> set term pngcairo size 660,400 set output 'statepop.png' set linetype 1 lc rgb "white" lw 1 set palette model HSV file 'statepop.hsv' set cbrange [0:50] unset colorbox set xrange [95:210] set yrange [-175:-135] set noxtics set noytics set border 0 unset key plot for [i=0:*] 'merc.dat' index i with filledcurves \ fc palette cb i, 'merc.dat' with lines lt 1 </gnuplot> In the above, 'merc.dat' contains the state outlines from the .shp file. The population data get into the picture via the pre-processed 'statepop.hsv'. To produce this (with its shades of blue) I ran a loop across the states using H = 229/360, V = 93/100, and S[i] = population of state i divided by the max population value. Any suggestions on the best way to do the colorization within gnuplot? And also, perhaps, how to discretize it (by decile for instance)? Is there a way to replace fc palette cb i with something like fc palette cb <function of i and the data to be colorized> ? Allin Cottrell |