New answers tagged

1

The loading of a .json file from hard disk is an asynchronous operation and thus it needs to specify a callback function to execute after the file is loaded. You could find more info in the following links: read local JSON file into variable, Loading local JSON file


6

You can achieve this combining arrays with maps (key:value pairs, see help Maps Functions) and the following expression, where in line 4 you list the elements you want to replace, using the pattern 'value_old','value_new'. Explanation: The expression creates an array of all inputs in fieldA (line 6) and for each element (line 5) looks in the map (the one ...


4

You can use PyQGIS (I don't have all numbers in my sample data, so the numbering isn't correct): lyr = QgsProject.instance().mapLayersByName('New scratch layer')[0] sourcefield = 'data1' targetfield = 'data2' allvals = [f[sourcefield] for f in lyr.getFeatures()] #List all values allvals = [f.split(',') for f in allvals] #Split them into individual elements ...


4

This seems to me a good task to be solved with Python and Function Editor. I have tried to build a minimum code fragment that uses the data provided in your example: Start from a memory layer that has 2 attributes "StringSource" and "StringDest" and six features that have the "StringSource" attribute set as in your example: 2....


4

You can use a regex expression to find the text to be replaced. It should be '(^|,)15.1(,|$)' The first (^|,) is a capture group, which means to find either the beginning of the string (^) or a ,. Then there is your text of interest and at last another capture group (,|$) which finds either a , or the end of the string ($) With this expression, it will find ...


0

This isn't a complete match, but your NETCDF4 code needs some changes to be functional: from netCDF4 import Dataset # Note: python is case-sensitive! import numpy as np ncfile = Dataset('precip.nc',mode='w',format='NETCDF4') #create dimensions y_dim = ncfile.createDimension('y', 512) # y axis x_dim = ncfile.createDimension('x', 512) # x axis n2 =...


Top 50 recent answers are included