Aug-21-2018, 02:00 PM
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;
- 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!
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 regionSo 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!