Installation | Syntax | Examples | Feedback | Disclaimer | Change log
(12 Jan 2025)
A Stata module for generating spatial flow arcs.
The package can be installed via SSC or GitHub. The GitHub version, might be more recent due to bug fixes, feature updates etc, and may contain syntax improvements and changes in default values. See version numbers below. Eventually the GitHub version is published on SSC.
The SSC version (v1.0):
ssc install geoflow, replaceOr it can be installed from GitHub (v1.0):
net install geoflow, from("https://raw.githubusercontent.com/asjadnaqvi/stata-geoflow/main/installation/") replaceInstall the following dependencies:
ssc install graphfunctions, replaceAdditional code for the maps shown below:
ssc install schemepack, replace
set scheme white_tableau
graph set window fontface "Arial Narrow"Software packages take countless hours of programming, testing, and bug fixing. If you use this package, then a citation would be highly appreciated:
Click here for the latest SSC citation.
otherwise the following BibTeX citation can be used:
@software{geoflow,
author = {Naqvi, Asjad},
title = {Stata package ``geoflow''},
url = {https://github.com/asjadnaqvi/stata-geoflow},
version = {1.0},
date = {2025-01-12}
}geoflow numvar [if] [in] {using}, from(varname) to(varname) key(var) saving(filename) [ replace cuts(num) top(num) points(num) ]
The package assumes that the users have the following two files:
- file1: This file should contain a numeric numvar flow variable defined by from() and to() identifiers. This file should already be loaded before using the command.
- file2: This file should contain a unique key() variable for which coordinates are defined and can be merged with from() and to() variables in file1.
The coordinates should be in the form _CX and _CY. These are generated by default if spshape2dta is used.
See help geoflow for details.
Get the global boundary data using the latest version of the geoboundary package:
geoboundary WLD, replace convert remove source(worldbank) Clean it up a up since ISO3 values have duplicates due to territories:
use WB_ADM0, clear
duplicates list ISO_A3
drop if ISO_A3=="-99"
drop if TYPE=="Dependency"
drop if inlist(WB_A3, "BES", "TKL")
compress
save iso_meta, replace
This create our master node attributes file that also contains the coordinates.
Load the sample trade data file derived from COMTRADE BACI for 2022:
use "https://github.com/asjadnaqvi/stata-geoflow/blob/main/GIS/baci_2022.dta?raw=true", clear
Create flow arcs for the top 20 values:
geoflow value using iso_meta, from(ex_iso3) to(im_iso3) key(ISO_A3) top(20) save(links) geoframe replace markAlso see return list that stores the radius value in local r(georadius). Since we specified the geoframe option, we can view the data by switching to this frame: frame change links.
Now create another frame that contains the boundaries and the node attributes:
geoframe create metadata iso_meta, replace shp(WB_ADM0_shp)Note here that we are using the our cleaned up file for the attributes. You can view the data by switching to this frame frame change metadata.
Plot the information:
geoplot ///
(area metadata i.REGION_WB, color(%40) lw(0.1) lc(white)) ///
(line links i._ID, lwidth(0.4) color(black) ) ///
(point metadata [w=GDP_MD_EST] if _mark==1, color(white%95) msize(1.6) mlcolor(black) ) ///
(label metadata ISO_A3 if _mark==1, color(black) size(1.5) ) ///
, tight legend(pos(7)) ///
title("Top 20 trade flows in 2022") note("Source: COMTRADE BACI")Please open an issue to report errors, feature enhancements, and/or other requests.
v1.0 (12 Jan 2025)
- First release

