Hi everyone, I want to extract "likely home country" information from the colomns I demostrated in the screenshot below.
This table has approximately 7k unique users, 4.8M rows. Each user has more than one post on different dates and times.
How can I do this using only ArcGIS Pro? What if I can't do this using just ArcGIS Pro?
I would really appreciate if you can help.
Solved! Go to Solution.
// get all rows of the current user
var user = $feature.TextField1
var fs_user = Filter($featureset, "author_name = @user")
// get the total post count
var total = Sum(fs_user, "FREQUENCY")
// order by frequency and country name
var fs_user_ordered = OrderBy(fs_user, "FREQUENCY DESC, country_en")
// if you're only interested in the most likely country, uncomment this line and delete everything after
//return First(fs_user_ordered).country_en
// get the percentages of posts from each country
var percentages = []
for(var f in fs_user_ordered) {
var p = Round(f.FREQUENCY / total * 100)
Push(percentages, `${f.country_en} (${p}%)`)
}
return Concatenate(percentages, " / ")
Are you looking at using the coordinates or the country_en attribute to extract the likely home country?
Thanks for responding @AndreasHall
I am looking at "country_en" attribute to identify likely home country. I've assigned the post's coordinates to the country polygons.
Now, I am curious how to detect if a user posts in a different country than likely home country more than a few months or a year using post date field. Probably I need to do moving-window analysis of time-series models. I should do more research how to achive this approach. I didn't do time series analysis before.
// get all rows of the current user
var user = $feature.TextField1
var fs_user = Filter($featureset, "author_name = @user")
// get the total post count
var total = Sum(fs_user, "FREQUENCY")
// order by frequency and country name
var fs_user_ordered = OrderBy(fs_user, "FREQUENCY DESC, country_en")
// if you're only interested in the most likely country, uncomment this line and delete everything after
//return First(fs_user_ordered).country_en
// get the percentages of posts from each country
var percentages = []
for(var f in fs_user_ordered) {
var p = Round(f.FREQUENCY / total * 100)
Push(percentages, `${f.country_en} (${p}%)`)
}
return Concatenate(percentages, " / ")
Thank you @JohannesLindner, I tried your solution and it worked great. I appreciate your help. I got this result table below.