GeoPython Workshop Plan: Unterschied zwischen den Versionen

Aus Geoinformation HSR
Wechseln zu: Navigation, Suche
 
Zeile 10: Zeile 10:
  
 
* '''Select by Expression'''
 
* '''Select by Expression'''
: - Select all the capital cities with population greater than the average population (or user-defined number). Find out the average population first.
+
: - Select all the capital cities with population greater than a user-defined number. ''select_populated_capitals(input_pop)''
: - Select points based on their UTM Zone (maybe not, since the QGIS tutorial already covers it)?
+
: - Select points based on their UTM Zone (maybe not, since the QGIS tutorial already covers it)? ''get_utm_zone()''  
: - Select the country in the 'Countries' layer that has the maximum number of populated places in the 'Populated Places' layer.
 
 
: - Use the hstore functions to select all points with the tags amenity=restaurant or amenity=schools etc. from the Rapperswil data. Similarly, label the points as 'name | restaurant' or 'name | school' ?  
 
: - Use the hstore functions to select all points with the tags amenity=restaurant or amenity=schools etc. from the Rapperswil data. Similarly, label the points as 'name | restaurant' or 'name | school' ?  
  
 
* '''Field Calculator'''
 
* '''Field Calculator'''
: (a) In the Populated Places attribute table, create a new field, 'hemisphere' which can be ''North'' or ''South'' depending on the latitude value. OR
+
: Use Nominatim's reverse geocoder to find the full address for that latitude longitude. Write a Python function that uses the API. See [http://wiki.openstreetmap.org/wiki/Nominatim Nominatim wiki] and the example:  http://nominatim.openstreetmap.org/reverse?format=xml&lat=52.5487429714954&lon=-1.81602098644987&zoom=18&addressdetails=1. ''get_address()''
: (b) Use Nominatim's reverse geocoder to find the full address for that latitude longitude. Write a Python function that uses the API. See [http://wiki.openstreetmap.org/wiki/Nominatim Nominatim wiki] and the example:  http://nominatim.openstreetmap.org/reverse?format=xml&lat=52.5487429714954&lon=-1.81602098644987&zoom=18&addressdetails=1
 
  
 
* '''Get the value of the env variable and do something with it'''
 
* '''Get the value of the env variable and do something with it'''
Zeile 24: Zeile 22:
  
 
* '''Label using Expression functions'''
 
* '''Label using Expression functions'''
: Label all the points in the 'Populated Places' layer using 'name | population surge in percentage | , | three letter country code'. Where population_surge = pop_max - pop_min.
+
: - Label all the points in the 'Populated Places' layer as 'name, ISO country code, population_growth', where population_growth = pop_max/pop_min.
 +
: - Label all the points in the 'Populated Places' layer as 'name, ISO country code, hemisphere' where 'hemisphere' which can be ''North'' or ''South'' depending on the latitude value.

Aktuelle Version vom 18. April 2017, 16:19 Uhr

Getting the Data

  • Admin 0 - Countries from Natural Earth.
  • Populated Places (Simple) from Natural Earth.
  • Rapperswil from OSMaxx? (for selecting and labelling features based on OSM tags using the hstore functions)

Custom Python Expression Functions Use Cases

Following are some example ideas to implement the use cases defined in the Discussion

  • Select by Expression
- Select all the capital cities with population greater than a user-defined number. select_populated_capitals(input_pop)
- Select points based on their UTM Zone (maybe not, since the QGIS tutorial already covers it)? get_utm_zone()
- Use the hstore functions to select all points with the tags amenity=restaurant or amenity=schools etc. from the Rapperswil data. Similarly, label the points as 'name | restaurant' or 'name | school' ?
  • Field Calculator
Use Nominatim's reverse geocoder to find the full address for that latitude longitude. Write a Python function that uses the API. See Nominatim wiki and the example: http://nominatim.openstreetmap.org/reverse?format=xml&lat=52.5487429714954&lon=-1.81602098644987&zoom=18&addressdetails=1. get_address()
  • Get the value of the env variable and do something with it
- Get the layer_name or layer_id of the Countries layer using get_env().
- Set a new variable (eg. layer_colour) using the set_env() function.
  • Label using Expression functions
- Label all the points in the 'Populated Places' layer as 'name, ISO country code, population_growth', where population_growth = pop_max/pop_min.
- Label all the points in the 'Populated Places' layer as 'name, ISO country code, hemisphere' where 'hemisphere' which can be North or South depending on the latitude value.