Python Forum
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
SimplyGIS query point-value
#1
Hello,

I have a question regarding a attribute query I teach myself.

I have three cities:

NAME = 0
POINTS = 1
POP = 2

cities = []
cities.append(["DENVER", [-104.98, 39.74], 634265])
cities.append(["BOULDER", [-105.27, 40.02], 98889])
cities.append(["DURANGO", [-107.88, 37.28], 17069])
As you can see I gave em a name, coordinates(points= longitudinal values, latitude values) and a population-number

Now, I did a attribute query, wanting to know, which is the biggest and western most city:

biggest_city = max(cities, key=lambda city: city[POP])

western_city = min(cities, key=lambda city: city[POINTS])
Now to the problem:


I wanted to know how I can do a query, where I can get the info, what is the most northern city? since I don't know how I can specifically target values inside the POINTS attribute, I wanted to get some help. I thought about making a seperate attribute (POINT1, POINT2) and then perform a query, but since I already have a code which is several hundred lines and has more then a hundred cities in it...yeah.

Secondly, how the hell did my code then work? How did python know, that Durango is the western most city, since the POINT attribute in the city consists of two values.

I hope this is understandably enough, and I'm grateful for any kind of help.
Reply


Messages In This Thread
SimplyGIS query point-value - by stampy - Feb-10-2021, 09:52 AM
RE: SimplyGIS query point-value - by buran - Feb-10-2021, 10:08 AM
RE: SimplyGIS query point-value - by stampy - Feb-10-2021, 10:10 AM

Possibly Related Threads…
Thread Author Replies Views Last Post
  connecting the first point to the last point Matplotlib omar_mohsen 0 4,659 Jan-15-2020, 01:23 PM
Last Post: omar_mohsen

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020