help geoqueryclipgeo v2.1 (GitHub)

GEOQUERY (beta)

geoquery is an intermediate program that calculates the summary statistics of the shapefile and stores them as locals.
These values can be passed on to clippolygon or clippolyline.

Syntax

Make sure the attributes files is loaded before using geoquery. For example, if we have mydata.dta and mydata_shp.dta,
then we want to map variables from mydata.dta using mydata_shp.dta where mydata_shp.dta is the file we want to clip.

geoquery shapefile [if] [in], [offset(num)]

geoquery shapefile The shapefile must be a valid shapefile generated by Stata's spshape2dta, otherwise the program will break.

offset(value) Offset defines the how much the box needs to shrink or expand in size. The default value is set at 0 (no change in box size). If we set offset(0.1) then it implies that bounds on the axes are increased by
delta = (max - min) * 0.1, or 10% of the axis extent. A negative value implies a reduction in the bounds.
The x- and y-axis extents are calculated separately, such that the new bounds are,
xmin = xmin + xdelta, xmax = xmax - xdelta for the x-axis. Simiarly, yxmin = ymin + ydelta, ymax = ymax - ydelta for the y-axis.

After the command, relevant values are stored in e-class locals. Type return list to view the estimates.

Psuedo code

Load the main file
. use myfile.dta, clear

Query the corresponding shapefile, using conditions and offset
. geoquery myfile_shp if id==X, offset(0.3)

Display the bounds (optional)
. return list
. di "`e(bounds)'"

Pass the bounds to the clipolygon or clipolyline command
. clippolygon myfile_shp, box("`e(bounds)'")

Test the mapped values
. spmap _ID using myfile_shp_clipped, id(_ID)

See GitHub for actual examples.

Keywords: Stata, graphs, maps, query, shapefile
Version: geoquery version 2.1
This release: 14 May 2024
First release: 31 Jul 2022
License: MIT

Author: Asjad Naqvi
E-mail: asjadnaqvi@gmail.com
Twitter: @AsjadNaqvi

Feedback

Please submit bugs, errors, feature requests on GitHub by opening a new issue.

References

Jann, B. (2018). Color palettes for Stata graphics. The Stata Journal 18(4): 765-785.

Jann, B. (2022). Color palettes for Stata graphics: an update. University of Bern Social Sciences Working Papers No. 43.

Other visualization packages

arcplot, alluvial, bimap, bumparea, bumpline, circlebar, circlepack, clipgeo, delaunay, joyplot,
marimekko, polarspike, sankey, schemepack, spider, streamplot, sunburst, treecluster, treemap, waffle