Python Forum
How get attributes of maps from loop statement
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
How get attributes of maps from loop statement
#1
Hi! So I am working on a model which will locate irrigation areas to its nearest water source on a global level.
This is a piece of my script of the river areas all over the world, categorized for each continent;

landmask_regions= { \
		'Africa': ['mask_M01.map', 'mask_M02.map', 'mask_M03.map', \
			'mask_M05.map', 'mask_M06.map', 'mask_M07.map', 'mask_M08.map', \
			'mask_M09.map'], \
		'Asia': ['mask_M04.map', 'mask_M05.map', 'mask_M10.map', 'mask_M11.map', \
			'mask_M12.map', 'mask_M13.map', 'mask_M14.map', 'mask_M15.map', \
			'mask_M16.map', 'mask_M17.map', 'mask_M18.map', 'mask_M19.map', \
			'mask_M20.map', 'mask_M21.map', 'mask_M22.map', 'mask_M23.map'], \
		'Europe': ['mask_M26.map', 'mask_M28.map', 'mask_M32.map', 'mask_M33.map', \
			'mask_M34.map'], \
		'N-America': ['mask_M25.map', 'mask_M35.map', 'mask_M36.map', 'mask_M37.map', \
			'mask_M38.map', 'mask_M39.map', 'mask_M40.map', 'mask_M41.map', \
			'mask_M42.map', 'mask_M43.map', 'mask_M44.map', 'mask_M45.map', 'mask_M46.map'], \
		'Australia': ['mask_M47.map', 'mask_M48.map', 'mask_M49.map'], \
		'S-America': ['mask_M24.map', 'mask_M50.map', 'mask_M51.map', \
			'mask_M52.map', 'mask_M53.map']}

    choice = 'Europe'
	if choice == 'whole_world':
			maps = sum(landmask_regions.values(), [])
			print "processing world maps"
			for region in maps:
				print region
	elif choice in landmask_regions:
			maps = landmask_regions[choice]
			print "processing continent"
			for region in maps:
				print region
	elif choice.endswith('.map'):
			maps = [choice]
			print "processing river area"
			for region in maps:
				print region	
So in my script, I have created methods that call one another to complete the following tasks:
- Read all the maps together (for a global map)
- Read all the maps of one region (for each continent)
- Read one specific region within a continent (for one river area)

Now I would like to get those maps (in this case from Europe), and to be able to 'read' them; this implies getting the attributes (such as location, x/y coordinates etc.) I was thinking of just using the 'getattr' function, but I'm not sure how to do that here.
Can someone maybe provide me with tips on how to adjust my script in order to do that? I hope my question is clear!
Thank you!
Reply


Messages In This Thread
How get attributes of maps from loop statement - by LB_994 - Aug-21-2018, 02:00 PM

Possibly Related Threads…
Thread Author Replies Views Last Post
  Help with nested maps Unkovic 10 1,419 Nov-01-2023, 03:45 PM
Last Post: Unkovic
Photo Python code: While loop with if statement HAMOUDA 1 585 Sep-18-2023, 11:18 AM
Last Post: deanhystad
  Multiply and Addition in the same loop statement with logic. joelraj 2 1,050 Feb-02-2023, 04:33 AM
Last Post: deanhystad
  Compare each element of an array in a logic statement without using a for loop leocsmith 3 5,886 Apr-01-2021, 07:57 PM
Last Post: deanhystad
  how to create pythonic codes including for loop and if statement? aupres 1 1,931 Jan-02-2021, 06:10 AM
Last Post: Gribouillis
  if statement in for loop researcher123 6 2,593 Oct-01-2020, 05:07 PM
Last Post: deanhystad
  Help: list comprehension for loop with double if statement mart79 3 2,449 May-04-2020, 06:34 AM
Last Post: buran
  Best way to map trajectory data on Google Maps Gduffley 1 2,684 Feb-05-2020, 12:36 AM
Last Post: scidam
  Can't visualize maps using Gmaps mPlummers 0 3,562 Sep-11-2019, 02:38 PM
Last Post: mPlummers
  Why doesn't my loop work correctly? (problem with a break statement) steckinreinhart619 2 3,230 Jun-11-2019, 10:02 AM
Last Post: steckinreinhart619

Forum Jump:

User Panel Messages

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