GeoPython Workshop Plan: Unterschied zwischen den Versionen

Aus Geoinformation HSR
Wechseln zu: Navigation, Suche
(Custom Python Expression Functions Use Cases)
Zeile 1: Zeile 1:
 
=== Getting the Data ===
 
=== Getting the Data ===
  
We will be using two vector files from [http://www.naturalearthdata.com/downloads/50m-cultural-vectors/ Natural Earth].
+
* Admin 0 - Countries from [http://www.naturalearthdata.com/downloads/50m-cultural-vectors/ Natural Earth].
* Admin 0 - Countries
+
* Populated Places (Simple) from [http://www.naturalearthdata.com/downloads/50m-cultural-vectors/ Natural Earth].
* Populated Places (Simple)
+
* Rapperswil from [https://osmaxx.hsr.ch/pages/downloads/ OSMaxx]? (for selecting and labelling features based on OSM tags using the hstore functions)
  
 
=== Custom Python Expression Functions Use Cases ===
 
=== Custom Python Expression Functions Use Cases ===
 +
 +
Following are some example ideas to implement the use cases defined in the [https://giswiki.hsr.ch/Diskussion:Workshop_QGIS_Python_GeoPython_2017 Discussion]
  
 
* '''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 the average population (or user-defined number). Find out the average population first.
: - Select points based on their UTM Zone?
+
: - Select points based on their UTM Zone (maybe not, since the QGIS tutorial already covers it)?
: - Select the country in the country layer that has the maximum number of populated places in the populated places layer.
+
: - 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'?  
+
: - 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
 
: (a) In the Populated Places attribute table, create a new field, 'hemisphere' which can be ''North'' or ''South'' depending on the latitude value. OR
: (b) Use Nominatim's reverse geocoder to find the full address for that latitude longitude. Write a Python function 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
+
: (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'''
: - Get the layer_name or layer_id of the Countries layer using get_env(). (Write function to set a new variable, layer_colour, according to the user defined colour. Usage: set_env()) ?
+
: - 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 using Expression functions'''
: Label all the points in the populated places dataset using 'name | population surge in percentage | , | three letter country code'
+
: 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.

Version vom 13. April 2017, 16:48 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 the average population (or user-defined number). Find out the average population first.
- Select points based on their UTM Zone (maybe not, since the QGIS tutorial already covers it)?
- 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' ?
  • 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
(b) 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 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 using 'name | population surge in percentage | , | three letter country code'. Where population_surge = pop_max - pop_min.