help cnborder

Title

cnborder -- Baidu Map API is widely used in China. By using the address, this STATA module aids in determining whether a point is on the boundary. To use this command, users need to install cngcode and cnaddress from SSC.

Syntax

cnborder, baidukey(string) address(string) [options]

Description

cnborder uses the Baidu Map API address, and based on the provided address this command identifies the latitude, longitude, province, city, and county. Moreover, this command also finds eight different locations surrounding the provided address (i.e., east, west, north, south, northeast, northwest, southeast, and southwest).
Finally, based on the said data, this command determines that the aforementioned eight places share the same province, city, or county as the center point (address), and this also indicates that the center point is not on the boundary.

cnborder require Stata version 14 or higher.

Detailed equations on how to calculate the eight points:

east_latitude = center_latitude, eastlongitude=center_longitude + radius/(111*cos(center_latitude*_pi/180)).

west_latitude = center_latitude, west_longitude=center_longitude - radius/(111*cos(center_latitude*_pi/180)).

north_latitude = center_latitude + radius/111, north_longitude = center_longitude.

south_latitude = center_latitude - radius/111, south_longitude = center_longitude.

northeast_latitude = center_latitude + radius/2^0.5/111, northeast_longitude = center_longitude + radius/2^0.5/(111*cos((center_latitude + radius/2^0.5/111)*_pi/180)).

northwest_latitude = center_latitude + radius/2^0.5/111, northwest_longitude = center_longitude - radius/2^0.5/(111*cos((center_latitude + radius/2^0.5/111)*_pi/180)).

southeast_latitude = center_latitude - radius/2^0.5/111, southeast_longitude = center_longitude + radius/2^0.5/(111*cos((center_latitude + radius/2^0.5/111)*_pi/180)).

southwest_latitude = center_latitude - radius/2^0.5/111, southwest_longitude = center_longitude - radius/2^0.5/(111*cos((center_latitude + radius/2^0.5/111)*_pi/180)).

Options for cnborder

Credentials(required)

baidukey(string) is required before using this command.
You can get a secret key from Baidumap open platform(http://lbsyun.baidu.com).
The process normally will take 3-5 days after you submit your application online.

Address(required)

address(string)is the precise address of the center location. This STATA command extract the latitude, longitude, province, city, county, and eight different locations from the provided address.

Search options

radius(int) is an optional factor, and the user can determine the radius around the center point. However, the default radius is 20 km.

Response switches

province_border(newvar) is string variable and user can specify the name of the outcome of province_borde. Default choice is province_border.

city_border(newvar) is string variable and user can specify the name of the outcome of city_border. Default choice is city_border.

county_border(newvar) is string variable and user can specify the name of the outcome of county_border. Default choice is county_border.

Example

Example 1, check whether those firms are located at regional border (within 20km, the default radius)

`"clear all"'

`"input str80 company_address"'

`""广东省深圳市盐田区大梅沙环梅路33号万科中心""'

`""广东省广州市荔湾区沙面北街45号""'

`""河南省漯河市双汇路1号双汇大厦""'

`""山东省济南市历城区经十路2503号""'

`""贵州省仁怀市茅台镇""'

`""四川省宜宾市翠屏区岷江西路150号""'

`"end"'

`"local bdk your-secret-key"'

`"cnborder,baidukey(`bdk') address(company_address)"'

Example 2, check whether those firms are located at regional border within 5km, with radius(5) option

`"clear all"'

`"input str80 company_address"'

`""广东省深圳市盐田区大梅沙环梅路33号万科中心""'

`""广东省广州市荔湾区沙面北街45号""'

`""河南省漯河市双汇路1号双汇大厦""'

`""山东省济南市历城区经十路2503号""'

`""贵州省仁怀市茅台镇""'

`""四川省宜宾市翠屏区岷江西路150号""'

`"end"'

`"local bdk your-secret-key"'

`"cnborder,baidukey(`bdk') address(company_address) radius(5)"'

Example 3, check whether those firms are located at regional border (within 20km, the default radius) but set variable names for the three outputs.

`"clear all"'

`"input str80 company_address"'

`""广东省深圳市盐田区大梅沙环梅路33号万科中心""'

`""广东省广州市荔湾区沙面北街45号""'

`""河南省漯河市双汇路1号双汇大厦""'

`""山东省济南市历城区经十路2503号""'

`""贵州省仁怀市茅台镇""'

`""四川省宜宾市翠屏区岷江西路150号""'

`"end"'

`"local bdk your-secret-key"'

`"cnborder,baidukey(`bdk') address(company_address) province_border(border1) city_border(border2) county_border(border3)"'

Outcomes

There will be three binary (1/0) outcome of this Stata module (i.e., prov_border, city_border, and county_border). The value of 1 represents province/city/county is on the border of central point and 0 otherwise.

Author

Chuntao LI

China Stata Club(爬虫俱乐部)

Wuhan, China

chtl@zuel.edu.cn

Guangzhong Liu

China Stata Club(爬虫俱乐部)

Kaifeng, China

liugz_henu@163.com

Muhammad Usman

Division of Management and Administrative Sciences, UE Business School, University of Education

Lahore, Pakistan

m.usman@ue.edu.pk