{"action":"created","comment":{"url":"https://api.github.com/repos/Geospatial-Python/assignment_06/pulls/comments/59121092","id":59121092,"diff_hunk":"@@ -0,0 +1,289 @@\n+import math\n+import sys\n+import os\n+import random\n+#from utils import euclidean_distance, n_random_Points\n+#sys.path.insert(0, os.path.abspath('..'))\n+\n+def find_largest_city(gj):\n+    \"\"\"\n+    Iterate through a geojson feature collection and\n+    find the largest city.  Assume that the key\n+    to access the maximum population is 'pop_max'.\n+\n+    Parameters\n+    ----------\n+    gj : dict\n+         A GeoJSON file read in as a Python dictionary\n+\n+    Returns\n+    -------\n+    city : str\n+           The largest city\n+\n+    population : int\n+                 The population of the largest city\n+    \"\"\"\n+    #features is a list, so iteration is by position\n+    #if you want to iterate over the features you need to first grab the list out of the dictionary.\n+\n+    featureList = gj['features']\n+    # now that you have the features, compare the pop_max fields to find the largest one\n+    max_population = 0\n+    for featureEntry in featureList:\n+        if featureEntry[\"properties\"][\"pop_max\"] > max_population:\n+            max_population = featureEntry[\"properties\"][\"pop_max\"]\n+            city = featureEntry[\"properties\"][\"nameascii\"]\n+\n+\n+    return city, max_population\n+\n+def write_your_own(gj):\n+    \"\"\"\n+    This function finds the least populated city, pop_min\n+    \"\"\"\n+    featureList = gj[\"features\"]\n+    minPop = math.inf\n+    for featureEntry in featureList:\n+        #feature[\"properties\"][\"pop_min\"] for feature in self.gj[\"features\"]\n+        if featureEntry[\"properties\"][\"pop_min\"] < minPop:\n+            minPop = featureEntry[\"properties\"][\"pop_min\"]\n+            city = featureEntry[\"properties\"][\"nameascii\"]\n+  #  minn = min(featureEntry[\"properties\"][\"pop_min\"])\n+#    print(minn)\n+    return city, minPop\n+\n+def mean_center(points):\n+    \"\"\"\n+    Given a set of points, compute the mean center\n+\n+    Parameters\n+    ----------\n+    points : list\n+         A list of points in the form (x,y)\n+\n+    Returns\n+    -------\n+    x : float\n+        Mean x coordinate\n+\n+    y : float\n+        Mean y coordinate\n+    \"\"\"\n+\n+    #find the average of all the X points in the list\n+\n+  #  x_sum = sum(points[0])\n+    #points_length = len(points)\n+\n+    sums = map(sum,zip(*points)) # returns iterable object of type map\n+    sumsL = list(sums)\n+    avgs = map(lambda xy: xy/len(points),sumsL)\n+    avgsL = list(avgs)\n+    x = avgsL[0]\n+    y = avgsL[1]\n+\n+    return x,y\n+\n+def average_nearest_neighbor_distance(points,mark=None):\n+    \"\"\"\n+    Given a set of points, compute the average nearest neighbor.\n+\n+    Parameters\n+    ----------\n+    points : list\n+             A list of Points in the form of (x,y,mark) or points with (x,y)\n+\n+    Returns\n+    -------\n+    mean_d : float\n+             Average nearest neighbor distance\n+\n+    References\n+    ----------\n+    Clark and Evan (1954 Distance to Nearest Neighbor as a\n+     Measure of Spatial Relationships in Populations. Ecology. 35(4)\n+     p. 445-453.\n+    \"\"\"\n+    markList = []\n+    if not mark: #If mark is empty, then you're computing the distance of all the points\n+        shDistL =[]       #list of shortest distances\n+\n+        #now the points are numbered... so if the points\n+        #have the same counter number attached also, then they\n+        #are self-neighbors, but if num1 != num2, then they are\n+        # coincident points, with distance = 0\n+        printXonce = False\n+        for num1, point in enumerate(points):\n+            shortestDistance = math.inf\n+            for num2, dpoint in enumerate(points):\n+                if num1 != num2:\n+                    if printXonce == False:\n+                        print(point.x)\n+                    epoint1 = (point.x,point.y)\n+                    epoint2 = (dpoint.x,dpoint.y)\n+                    dist = utils.euclidean_distance(epoint1, epoint2)  #changed input parameters because cannot pass in Point\n+                    if(shortestDistance > dist):\n+                        shortestDistance = dist\n+                printXonce = True\n+            #now add the shortest distance of that point before it moves on to a new point\n+            shDistL.append(shortestDistance)\n+       # print(shDistL)\n+        sums = sum(shDistL)\n+        mean_d = sums/len(shDistL)\n+    #compute the average nearest neighbor distance of only those that share the mark\n+    else:\n+        for p in points:\n+            if p.mark in mark:  #passed in a list of possible marks\n+                markList.append(p)\n+        shDistL =[]       #list of shortest distances\n+\n+        #now the points are numbered... so if the points\n+        #have the same counter number attached also, then they\n+        #are self-neighbors, but if num1 != num2, then they are\n+        # coincident points, with distance = 0\n+        for num1, point in enumerate(markList):\n+            shortestDistance = math.inf\n+            for num2, dpoint in enumerate(markList):\n+                if num1 != num2:\n+                    dist = utils.euclidean_distance((point.x,point.y), (dpoint.x,dpoint.y))\n+                    if(shortestDistance > dist):\n+                        shortestDistance = dist\n+            #now add the shortest distance of that point before it moves on to a new point\n+            shDistL.append(shortestDistance)\n+        #print(shDistL)\n+        sums = sum(shDistL)\n+        mean_d = sums/len(shDistL)\n+        print(mean_d)\n+    return mean_d\n+\n+\n+def minimum_bounding_rectangle(points):\n+    \"\"\"\n+    Given a set of points, compute the minimum bounding rectangle.\n+\n+    Parameters\n+    ----------\n+    points : list\n+             A list of points in the form (x,y)\n+\n+    Returns\n+    -------\n+     : list\n+       Corners of the MBR in the form [xmin, ymin, xmax, ymax]\n+    \"\"\"\n+    # a minimum bounding rectangle would be on the extremes of x/y\n+\n+    xmin = math.inf\n+    ymin = math.inf\n+    xmax = -9999999999\n+    ymax = -9999999999\n+    for point in points:\n+        if point[0] < xmin:\n+            xmin = point[0]\n+        if point[1] < ymin:\n+            ymin = point[1]\n+        if point[0] > xmax:\n+            xmax = point[0]\n+        if point[1] > ymax:\n+            ymax = point[1]\n+    mbr = [xmin,ymin,xmax,ymax]\n+    print(\"This is the mbr:\")\n+    print(mbr)","path":"analytics.py","position":192,"original_position":192,"commit_id":"7e239b34917ad2040453163df67ae919e2e27a1d","original_commit_id":"7e239b34917ad2040453163df67ae919e2e27a1d","user":{"login":"jlaura","id":2105468,"avatar_url":"https://avatars.githubusercontent.com/u/2105468?v=3","gravatar_id":"","url":"https://api.github.com/users/jlaura","html_url":"https://github.com/jlaura","followers_url":"https://api.github.com/users/jlaura/followers","following_url":"https://api.github.com/users/jlaura/following{/other_user}","gists_url":"https://api.github.com/users/jlaura/gists{/gist_id}","starred_url":"https://api.github.com/users/jlaura/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/jlaura/subscriptions","organizations_url":"https://api.github.com/users/jlaura/orgs","repos_url":"https://api.github.com/users/jlaura/repos","events_url":"https://api.github.com/users/jlaura/events{/privacy}","received_events_url":"https://api.github.com/users/jlaura/received_events","type":"User","site_admin":false},"body":"What about using `format` here?  ","created_at":"2016-04-09T20:40:20Z","updated_at":"2016-04-09T20:40:20Z","html_url":"https://github.com/Geospatial-Python/assignment_06/pull/4#discussion_r59121092","pull_request_url":"https://api.github.com/repos/Geospatial-Python/assignment_06/pulls/4","_links":{"self":{"href":"https://api.github.com/repos/Geospatial-Python/assignment_06/pulls/comments/59121092"},"html":{"href":"https://github.com/Geospatial-Python/assignment_06/pull/4#discussion_r59121092"},"pull_request":{"href":"https://api.github.com/repos/Geospatial-Python/assignment_06/pulls/4"}}},"pull_request":{"url":"https://api.github.com/repos/Geospatial-Python/assignment_06/pulls/4","id":62818498,"html_url":"https://github.com/Geospatial-Python/assignment_06/pull/4","diff_url":"https://github.com/Geospatial-Python/assignment_06/pull/4.diff","patch_url":"https://github.com/Geospatial-Python/assignment_06/pull/4.patch","issue_url":"https://api.github.com/repos/Geospatial-Python/assignment_06/issues/4","number":4,"state":"open","locked":false,"title":"initial commit with import error","user":{"login":"sskadamb","id":16727317,"avatar_url":"https://avatars.githubusercontent.com/u/16727317?v=3","gravatar_id":"","url":"https://api.github.com/users/sskadamb","html_url":"https://github.com/sskadamb","followers_url":"https://api.github.com/users/sskadamb/followers","following_url":"https://api.github.com/users/sskadamb/following{/other_user}","gists_url":"https://api.github.com/users/sskadamb/gists{/gist_id}","starred_url":"https://api.github.com/users/sskadamb/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/sskadamb/subscriptions","organizations_url":"https://api.github.com/users/sskadamb/orgs","repos_url":"https://api.github.com/users/sskadamb/repos","events_url":"https://api.github.com/users/sskadamb/events{/privacy}","received_events_url":"https://api.github.com/users/sskadamb/received_events","type":"User","site_admin":false},"body":"","created_at":"2016-03-14T21:14:32Z","updated_at":"2016-04-09T20:40:20Z","closed_at":null,"merged_at":null,"merge_commit_sha":"06d124a3acbcbfed7aa3d47b822da1c2338228cd","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/Geospatial-Python/assignment_06/pulls/4/commits","review_comments_url":"https://api.github.com/repos/Geospatial-Python/assignment_06/pulls/4/comments","review_comment_url":"https://api.github.com/repos/Geospatial-Python/assignment_06/pulls/comments{/number}","comments_url":"https://api.github.com/repos/Geospatial-Python/assignment_06/issues/4/comments","statuses_url":"https://api.github.com/repos/Geospatial-Python/assignment_06/statuses/7e239b34917ad2040453163df67ae919e2e27a1d","head":{"label":"sskadamb:master","ref":"master","sha":"7e239b34917ad2040453163df67ae919e2e27a1d","user":{"login":"sskadamb","id":16727317,"avatar_url":"https://avatars.githubusercontent.com/u/16727317?v=3","gravatar_id":"","url":"https://api.github.com/users/sskadamb","html_url":"https://github.com/sskadamb","followers_url":"https://api.github.com/users/sskadamb/followers","following_url":"https://api.github.com/users/sskadamb/following{/other_user}","gists_url":"https://api.github.com/users/sskadamb/gists{/gist_id}","starred_url":"https://api.github.com/users/sskadamb/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/sskadamb/subscriptions","organizations_url":"https://api.github.com/users/sskadamb/orgs","repos_url":"https://api.github.com/users/sskadamb/repos","events_url":"https://api.github.com/users/sskadamb/events{/privacy}","received_events_url":"https://api.github.com/users/sskadamb/received_events","type":"User","site_admin":false},"repo":{"id":52763147,"name":"assignment_06","full_name":"sskadamb/assignment_06","owner":{"login":"sskadamb","id":16727317,"avatar_url":"https://avatars.githubusercontent.com/u/16727317?v=3","gravatar_id":"","url":"https://api.github.com/users/sskadamb","html_url":"https://github.com/sskadamb","followers_url":"https://api.github.com/users/sskadamb/followers","following_url":"https://api.github.com/users/sskadamb/following{/other_user}","gists_url":"https://api.github.com/users/sskadamb/gists{/gist_id}","starred_url":"https://api.github.com/users/sskadamb/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/sskadamb/subscriptions","organizations_url":"https://api.github.com/users/sskadamb/orgs","repos_url":"https://api.github.com/users/sskadamb/repos","events_url":"https://api.github.com/users/sskadamb/events{/privacy}","received_events_url":"https://api.github.com/users/sskadamb/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/sskadamb/assignment_06","description":"","fork":true,"url":"https://api.github.com/repos/sskadamb/assignment_06","forks_url":"https://api.github.com/repos/sskadamb/assignment_06/forks","keys_url":"https://api.github.com/repos/sskadamb/assignment_06/keys{/key_id}","collaborators_url":"https://api.github.com/repos/sskadamb/assignment_06/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/sskadamb/assignment_06/teams","hooks_url":"https://api.github.com/repos/sskadamb/assignment_06/hooks","issue_events_url":"https://api.github.com/repos/sskadamb/assignment_06/issues/events{/number}","events_url":"https://api.github.com/repos/sskadamb/assignment_06/events","assignees_url":"https://api.github.com/repos/sskadamb/assignment_06/assignees{/user}","branches_url":"https://api.github.com/repos/sskadamb/assignment_06/branches{/branch}","tags_url":"https://api.github.com/repos/sskadamb/assignment_06/tags","blobs_url":"https://api.github.com/repos/sskadamb/assignment_06/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/sskadamb/assignment_06/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/sskadamb/assignment_06/git/refs{/sha}","trees_url":"https://api.github.com/repos/sskadamb/assignment_06/git/trees{/sha}","statuses_url":"https://api.github.com/repos/sskadamb/assignment_06/statuses/{sha}","languages_url":"https://api.github.com/repos/sskadamb/assignment_06/languages","stargazers_url":"https://api.github.com/repos/sskadamb/assignment_06/stargazers","contributors_url":"https://api.github.com/repos/sskadamb/assignment_06/contributors","subscribers_url":"https://api.github.com/repos/sskadamb/assignment_06/subscribers","subscription_url":"https://api.github.com/repos/sskadamb/assignment_06/subscription","commits_url":"https://api.github.com/repos/sskadamb/assignment_06/commits{/sha}","git_commits_url":"https://api.github.com/repos/sskadamb/assignment_06/git/commits{/sha}","comments_url":"https://api.github.com/repos/sskadamb/assignment_06/comments{/number}","issue_comment_url":"https://api.github.com/repos/sskadamb/assignment_06/issues/comments{/number}","contents_url":"https://api.github.com/repos/sskadamb/assignment_06/contents/{+path}","compare_url":"https://api.github.com/repos/sskadamb/assignment_06/compare/{base}...{head}","merges_url":"https://api.github.com/repos/sskadamb/assignment_06/merges","archive_url":"https://api.github.com/repos/sskadamb/assignment_06/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/sskadamb/assignment_06/downloads","issues_url":"https://api.github.com/repos/sskadamb/assignment_06/issues{/number}","pulls_url":"https://api.github.com/repos/sskadamb/assignment_06/pulls{/number}","milestones_url":"https://api.github.com/repos/sskadamb/assignment_06/milestones{/number}","notifications_url":"https://api.github.com/repos/sskadamb/assignment_06/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/sskadamb/assignment_06/labels{/name}","releases_url":"https://api.github.com/repos/sskadamb/assignment_06/releases{/id}","deployments_url":"https://api.github.com/repos/sskadamb/assignment_06/deployments","created_at":"2016-02-29T04:07:01Z","updated_at":"2016-02-29T04:07:03Z","pushed_at":"2016-03-28T07:08:03Z","git_url":"git://github.com/sskadamb/assignment_06.git","ssh_url":"git@github.com:sskadamb/assignment_06.git","clone_url":"https://github.com/sskadamb/assignment_06.git","svn_url":"https://github.com/sskadamb/assignment_06","homepage":null,"size":15,"stargazers_count":0,"watchers_count":0,"language":"Python","has_issues":false,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":0,"mirror_url":null,"open_issues_count":0,"forks":0,"open_issues":0,"watchers":0,"default_branch":"master"}},"base":{"label":"Geospatial-Python:master","ref":"master","sha":"9585962f8adea8a759269e3c4b9236fc74c91fc3","user":{"login":"Geospatial-Python","id":15664595,"avatar_url":"https://avatars.githubusercontent.com/u/15664595?v=3","gravatar_id":"","url":"https://api.github.com/users/Geospatial-Python","html_url":"https://github.com/Geospatial-Python","followers_url":"https://api.github.com/users/Geospatial-Python/followers","following_url":"https://api.github.com/users/Geospatial-Python/following{/other_user}","gists_url":"https://api.github.com/users/Geospatial-Python/gists{/gist_id}","starred_url":"https://api.github.com/users/Geospatial-Python/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Geospatial-Python/subscriptions","organizations_url":"https://api.github.com/users/Geospatial-Python/orgs","repos_url":"https://api.github.com/users/Geospatial-Python/repos","events_url":"https://api.github.com/users/Geospatial-Python/events{/privacy}","received_events_url":"https://api.github.com/users/Geospatial-Python/received_events","type":"Organization","site_admin":false},"repo":{"id":52689079,"name":"assignment_06","full_name":"Geospatial-Python/assignment_06","owner":{"login":"Geospatial-Python","id":15664595,"avatar_url":"https://avatars.githubusercontent.com/u/15664595?v=3","gravatar_id":"","url":"https://api.github.com/users/Geospatial-Python","html_url":"https://github.com/Geospatial-Python","followers_url":"https://api.github.com/users/Geospatial-Python/followers","following_url":"https://api.github.com/users/Geospatial-Python/following{/other_user}","gists_url":"https://api.github.com/users/Geospatial-Python/gists{/gist_id}","starred_url":"https://api.github.com/users/Geospatial-Python/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Geospatial-Python/subscriptions","organizations_url":"https://api.github.com/users/Geospatial-Python/orgs","repos_url":"https://api.github.com/users/Geospatial-Python/repos","events_url":"https://api.github.com/users/Geospatial-Python/events{/privacy}","received_events_url":"https://api.github.com/users/Geospatial-Python/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/Geospatial-Python/assignment_06","description":"","fork":false,"url":"https://api.github.com/repos/Geospatial-Python/assignment_06","forks_url":"https://api.github.com/repos/Geospatial-Python/assignment_06/forks","keys_url":"https://api.github.com/repos/Geospatial-Python/assignment_06/keys{/key_id}","collaborators_url":"https://api.github.com/repos/Geospatial-Python/assignment_06/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/Geospatial-Python/assignment_06/teams","hooks_url":"https://api.github.com/repos/Geospatial-Python/assignment_06/hooks","issue_events_url":"https://api.github.com/repos/Geospatial-Python/assignment_06/issues/events{/number}","events_url":"https://api.github.com/repos/Geospatial-Python/assignment_06/events","assignees_url":"https://api.github.com/repos/Geospatial-Python/assignment_06/assignees{/user}","branches_url":"https://api.github.com/repos/Geospatial-Python/assignment_06/branches{/branch}","tags_url":"https://api.github.com/repos/Geospatial-Python/assignment_06/tags","blobs_url":"https://api.github.com/repos/Geospatial-Python/assignment_06/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/Geospatial-Python/assignment_06/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/Geospatial-Python/assignment_06/git/refs{/sha}","trees_url":"https://api.github.com/repos/Geospatial-Python/assignment_06/git/trees{/sha}","statuses_url":"https://api.github.com/repos/Geospatial-Python/assignment_06/statuses/{sha}","languages_url":"https://api.github.com/repos/Geospatial-Python/assignment_06/languages","stargazers_url":"https://api.github.com/repos/Geospatial-Python/assignment_06/stargazers","contributors_url":"https://api.github.com/repos/Geospatial-Python/assignment_06/contributors","subscribers_url":"https://api.github.com/repos/Geospatial-Python/assignment_06/subscribers","subscription_url":"https://api.github.com/repos/Geospatial-Python/assignment_06/subscription","commits_url":"https://api.github.com/repos/Geospatial-Python/assignment_06/commits{/sha}","git_commits_url":"https://api.github.com/repos/Geospatial-Python/assignment_06/git/commits{/sha}","comments_url":"https://api.github.com/repos/Geospatial-Python/assignment_06/comments{/number}","issue_comment_url":"https://api.github.com/repos/Geospatial-Python/assignment_06/issues/comments{/number}","contents_url":"https://api.github.com/repos/Geospatial-Python/assignment_06/contents/{+path}","compare_url":"https://api.github.com/repos/Geospatial-Python/assignment_06/compare/{base}...{head}","merges_url":"https://api.github.com/repos/Geospatial-Python/assignment_06/merges","archive_url":"https://api.github.com/repos/Geospatial-Python/assignment_06/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/Geospatial-Python/assignment_06/downloads","issues_url":"https://api.github.com/repos/Geospatial-Python/assignment_06/issues{/number}","pulls_url":"https://api.github.com/repos/Geospatial-Python/assignment_06/pulls{/number}","milestones_url":"https://api.github.com/repos/Geospatial-Python/assignment_06/milestones{/number}","notifications_url":"https://api.github.com/repos/Geospatial-Python/assignment_06/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/Geospatial-Python/assignment_06/labels{/name}","releases_url":"https://api.github.com/repos/Geospatial-Python/assignment_06/releases{/id}","deployments_url":"https://api.github.com/repos/Geospatial-Python/assignment_06/deployments","created_at":"2016-02-27T21:13:41Z","updated_at":"2016-02-28T21:56:04Z","pushed_at":"2016-03-30T04:45:16Z","git_url":"git://github.com/Geospatial-Python/assignment_06.git","ssh_url":"git@github.com:Geospatial-Python/assignment_06.git","clone_url":"https://github.com/Geospatial-Python/assignment_06.git","svn_url":"https://github.com/Geospatial-Python/assignment_06","homepage":null,"size":45,"stargazers_count":0,"watchers_count":0,"language":"Python","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":17,"mirror_url":null,"open_issues_count":13,"forks":17,"open_issues":13,"watchers":0,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/Geospatial-Python/assignment_06/pulls/4"},"html":{"href":"https://github.com/Geospatial-Python/assignment_06/pull/4"},"issue":{"href":"https://api.github.com/repos/Geospatial-Python/assignment_06/issues/4"},"comments":{"href":"https://api.github.com/repos/Geospatial-Python/assignment_06/issues/4/comments"},"review_comments":{"href":"https://api.github.com/repos/Geospatial-Python/assignment_06/pulls/4/comments"},"review_comment":{"href":"https://api.github.com/repos/Geospatial-Python/assignment_06/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/Geospatial-Python/assignment_06/pulls/4/commits"},"statuses":{"href":"https://api.github.com/repos/Geospatial-Python/assignment_06/statuses/7e239b34917ad2040453163df67ae919e2e27a1d"}}}}