This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| def set_alias(layer): | |
| ''' | |
| Configure the alias for all fields of a vector layer | |
| Use the field name replacing the underscore by spaces and set it to Title Case | |
| ''' | |
| if layer.type() != QgsMapLayer.VectorLayer: | |
| return | |
| layer_fields = layer.fields() | |
| for f in layer_fields: |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| def field_readonly(layer, fieldname, option = True): | |
| ''' | |
| Tornar o campo de uma camada vectorial nao editavel | |
| ''' | |
| if layer.type() != QgsMapLayer.VectorLayer: | |
| return | |
| fields = layer.fields() | |
| field_idx = fields.indexOf(fieldname) | |
| if field_idx >= 0: | |
| form_config = layer.editFormConfig() |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # List GDAL commands names and algorithms in QGIS | |
| algorithms = QgsApplication.processingRegistry().algorithms() | |
| gdal_alg = [alg for alg in algorithms if alg.provider().name() == 'GDAL'] | |
| gdal_commands = {} | |
| for alg in gdal_alg: | |
| if not alg.commandName() in gdal_commands: | |
| gdal_commands[alg.commandName()] = [] | |
| gdal_commands[alg.commandName()].append(alg.displayName()) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| n = 12 | |
| n2 = 5 | |
| print(n, n2) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| p_reg = QgsApplication.processingRegistry() | |
| algorithms = p_reg.algorithms() | |
| providers = p_reg.providers() | |
| print('N. providers = {}'.format(len(providers))) | |
| for provider in providers: | |
| p_algorithms = provider.algorithms() | |
| print('{} --> {}'.format(provider.name(),len(p_algorithms))) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!/env/python | |
| # coding=utf8 | |
| """ | |
| Converting Degrees, Minutes, Seconds formatted coordinate strings to decimal. | |
| Formula: | |
| DEC = (DEG + (MIN * 1/60) + (SEC * 1/60 * 1/60)) | |
| Assumes S/W are negative. |