Ccode to Python
C/C++ arrays are row major, meaning rows are stored contiguously in memory.
G&N talk about the horizontal (
xsize) and vertical (
ysize) of a grid to mean the number of columns and rows, respectively, in the corresponding matrix.
|Item||C variable||Python variable|
The GN uspop.dat file has 512 rows and 1024 columns, xsize=1024 and ysize=512.
Latitude (altitude) \(\phi\) measures the elevation from the equator, \(-\pi/2\le\phi\le\pi/2\).
Longitude (azimith, heading) \(\lambda\) measures the angle from the prime meridian (Greenwich), positive East and negative West, \(-\pi < \phi \le \pi\). Longitude wraps at \(\pi\) and is undefined at the poles.
Spelling out lat/long is essentially \((y,x)\) in Cartesian coordinates.
A graticle (graticule) is a grid of lat/long lines.
A geoid is a model of the surface of the ocean accounting for gravity and the rotation of the Earth, but no other effects. It is an idealized surface model. Influences such as winds and tides are ignored.
There is no FIPS 3…it is reserved for American Samoa. etc.
pyfftw and builders…should be able to reproduce the DCT with some transposing?
Basic Real FFT help: https://www.fftw.org/fftw3_doc/Real_002dto_002dReal-Transforms.html
FFTW_REDFT10 computes an
REDFT10 transform, i.e. a DCT-II (sometimes called “the” DCT).
FFTW_ESTIMATE specifies that, instead of actual measurements of different algorithms, a simple heuristic is used to pick a (probably sub-optimal) plan quickly. With this flag, the input/output arrays are not overwritten during planning.
Rcartogram, an interface to C code for “fitting” diffusion cartograms to a grid of densities.
cartogramConstruct a continuous area cartogram by a rubber sheet distortion algorithm (Dougenik et al. 1985), non-contiguous Area Cartograms (Olson 1976), and non-overlapping Circles Cartogram (Dorling el al. 1996) in R.
Run the cartogram generator at the command line by running
cartogram. You should see the following output:
$ cartogram USAGE: Process GeoJSON File: cartogram -p json_file_name Generate Cartogram: cartogram [-dei] -g map_file_name -a area_file_name OR: cartogram [-dei] -g map_file_name -s -d: use Gastner-Newman (i.e. diffusion) method -e: generate cartogram figure in EPS format -i: calculate inverse transform
Note: If you run into issues, look at the Troubleshooting section below.
To generate a cartogram, you need a map and the associated statistical data you want to visualize. The cartogram generator accepts maps in GeoJSON and ArcInfo Generate formats, and statistical data in CSV format. To generate a cartogram, you need to:
Process your GeoJSON map file using the following command:
cartogram -p json_file_name
The cartogram will generate 2 new files: a XX_processedmap.json file and XX_data.csv file. Open the CSV file with your preferred spreadsheet program, and fill in the data value for each region under the ‘Region Data’ column.
Support for the ArcInfo Generate format is provided for backwards compatability with existing maps.
Once you have processed your map file and generated a CSV file with the data you want to visualize, you can run the following command to generate a cartogram:
cartogram -g processedmap_file_name -a csv_file_name
The generated cartogram will be saved in the same format as the map input in the current working directory with the filename
cartogram.json, if the input map is in GeoJSON format (
cartogram.gen, if the input map is in ArcInfo Generate format).
For the 2016 US presidential election data, navigate to the
Then run the following command. Note that the sample data has already been processed using
cartogram -g usa_contiguous_arcgis.json -a usa_contiguous_electors.csv
To generate an EPS image of the original map and cartogram, use the
cartogram -eg usa_contiguous_arcgis.json -a usa_contiguous_electors.csv
Running this command will produce three files:
cartogram.jsoncontains the cartogram in GeoJSON format
map.epscontains the original map in EPS format
cartogram.epscontains the generated cartogram in EPS format
For our example,
map.eps should look as follows:
cartogram.eps should look like:
|-e||Output an EPS file of the original map (
|-d||Use Gastner-Newman (i.e. diffusion) instead of fast flow-based method|
|-i||Print inverse transform to file|
|-g||Location of file for the original map|
|-a||Location of the area information file. Cannot be used with -s.|
|-s||Read the area information from