chrismuir / geolocchina Goto Github PK
View Code? Open in Web Editor NEWNative Geolocation of Chinese Strings in R (no API keys required)
Native Geolocation of Chinese Strings in R (no API keys required)
This issue is related to instances in which geolocChina::geo_locate()
has to resort to searching through the county_2015
package data substrings to try to fill in the output city variables.
# Establish variables for examples below
base_str <- "工业路25号"
df <- geolocChina::get_package_data()
When using the county_2015
substrings after no matches have been found for province, city, nor county, the function works great:
x <- paste0("北市区", base_str)
geolocChina::geo_locate(x)
#> location province city county province_code city_code county_code
#> 1 北市区工业路25号 河北 保定 <NA> 13 1306 NA
df[df$region == "北市区", ]
#> region geocode region_type
#> 3238 北市区 130603 county_2015
However, if there was a province match, but the function uses the county_2015
substrings to try to fill in missing city output data, there are no checks to ensure the output geocodes align (first two digits of the city geocode must match the provincial geocode):
x <- paste0("浙江省", "北市区", base_str)
geolocChina::geo_locate(x)
#> location province city county province_code city_code county_code
#> 1 浙江省北市区工业路25号 浙江 保定 <NA> 33 1306 NA
The expected output should be this:
#> location province city county province_code city_code county_code
#> 1 浙江省工业路25号 浙江 <NA> <NA> 33 NA NA
I believe the fix is easy, currently cpp function substring_lookup_cnty_2015()
handles substring lookups for the county_2015
substrings; I think I just need a version of this that takes in a parent code and validates any substring matches against it, similar to the cpp function substring_lookup_city_w_code()
.
On this setup
> sessionInfo()
R version 4.0.5 (2021-03-31)
Platform: x86_64-apple-darwin17.0 (64-bit)
Running under: macOS High Sierra 10.13.6
I get the following error: ERROR: hard-coded installation path: please report to the package maintainer and use ‘--no-staged-install’
. So geolocChina
has to be installed through devtools::install_github("ChrisMuir/geolocChina", INSTALL_opts ="--no-staged-install")
.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.