help clippolygonclippolygon v2.0 (GitHub)

CLIPPOLYGON (beta)

clippolygon takes a polygon shapefile and clips it on a manually defined bounding box or a circle. The program implements the Sutherland–Hodgman algorithm.

clippolygon supercedes clippolyline due to more flexibility with clipping over convex polygons.

Syntax

clippolygon shapefile, method(box|circle)
[ box(xmin, xmax, ymin, ymax) ]
[ xmid(num) ymid(num) radius(num) points(num) angle(num) ]

clippolygon shapefile Where shapefile is the *_shp.dta file generated by Stata's spshape2dta command and contains polygon coordinates.

method() Specify the clipping method which is either box or circle.

Box options

box(xmin, xmax, ymin, ymax) The bounding box coordinates need to be specified in the correct order. Can be inferred from the geoquery command.

Circle options

xmid(num) The center x value of the circle. Can be inferred from the geoquery command. Default value is 0.

ymid(num) The center y value of the circle. Can be inferred from the geoquery command. Default value is 0.

radius(num) The radius of the circle. Can be inferred from the geoquery command.

points(num) The radius of the circle. Default value is 60. For a smoother circle, use a higher value, but it will also be slower.
Lower values (<10) will draw regular polygons. E.g. p(6) is a hexagon, p(8) is an octagon, etc.

angle(num) The angle defines the rotation of the points in degrees. For example, a(45) is a 45 degree rotation. Default value is 0.

See the GitHub repository for examples.

Keywords: Stata, graphs, map, polygon clipping, Sutherland-Hodgman algorithm
Version: clippolygon version 2.0
This release: 08 Sep 2022
First release: 02 Apr 2022
License: MIT

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