6

I had the same problem. I solved it removing any reference to the layer creation options (-lco): include them only in the first call. The following calls should look like this: command = r'ogr2ogr -f "PostgreSQL" PG:"host=url port=5432 dbname=db1 user=username password=password" -append -update -nln schemaname.tablename "D:\path\shapefile(1,2,3...).shp" -...


5

You're probably getting some sort of exception being raised. Perhaps use a Queue to pass messages back to the parent process. Tested working code: import os, arcpy, arcgisscripting, time, sys from multiprocessing import Process from multiprocessing.queues import SimpleQueue def ConvertCADtoGDB(msgs,in_dgn,out_gdb): try: gp = arcgisscripting....


3

Subprocess can be used to start new processes - i.e. you use it to execute command line tools from within python. Gdalwarp is a command line tool - processing.runalg is not - hence your Windows error that it can't find it. What you are trying to launch is not a command line tool but a method of the QGIS python module. If you want to use that inside a ...


2

I think this may be an example of what you are looking for...check out this Esri article on multiprocess geocoding. It says, "Download the tool even if you’re not a geocoder, you may be able to leverage the logic to parallelize other geoprocessing jobs – and if you do, don’t forget to share your own tools!" "... lets you leverage all available CPU cores on ...


2

Unfortunately, your problem description leaves some desires. You really should specify more clearly what does not work and which error messages you receive and so forth. And usually it is best in case of errors to try one step after the other. In your case I see some problems that may cause your script to "not work". First, you should specify the correct ...


2

I suppose you use Python 2.7. You can change to check_call method of subprocess and you can redirect stdin, stdout and stderr, see: https://docs.python.org/2.7/library/subprocess.html Using Python 3.5+ you have more control.


2

Now that your question is open again I can provide some code. In your linked answer I wrote a batch file then called the batch file, that works, but to call directly from python: lasheight = r"c:\lastools\bin\lasheight.exe" # earlier in the script for ThisXStep in XStep: for ThisYStep in YStep: # for each sub block identify the matching list ...


2

The symptoms you describe are to me typical of running a script/tool with insufficient RAM available for the size of input datasets, in conjunction with anything else you are doing on your PC/laptop. I recommend: Close everything and reboot your machine Run your script/tool without anything else running (if you wish, watch your memory usage via Task ...


2

you could also try subprocess.call subprocess.call(["TeighaFileConverter"]) and make sure that you have the path to your TeighaFileConverter installation in you path variable EDIT: I tested the code above again in the python console in qgis and it didn't work, sorry for posting a wrong code, you have to mention the whole path in order to call it ...


2

The approach I would suggest would be using custom PyQt signals. The example below is based on the example for extending QgsTask in the PyQGIS Developer Cookbook, modified to emit custom signals from the background task and listen for them from the main thread. You can then connect to a slot which pushes a message to the message bar or otherwise interacts ...


1

Expanding on Antonia's answer where yes: removing -lco SCHEMA=schema1 and instead refer to the schema in the -nln tag, ie: -nln schema.table works... We can improve on the whole process by iterating through a list of shapefiles in a directory and upload them all into the same new table in PostgreSQL like so: import os from subprocess import call dir = r'C:/...


1

I have had this sort of problem before, but with raster2pgsql, although from some light reading of the documentation, it seems like the similarities are numerous. I hope my solution also works with shp2pgsql, with some argument changes : from subprocess import Popen, PIPE # Specify the paths to the programs you want to use. r'string' means the path is ...


1

I did not tried with gdaldem but with gdal_translate and gdalwarp. Depending of your goal: Single call on the os Multiprocessing Single call : os.system should be also used. Single call or multiprocessing: I'm using a function to call my gdal subprocess. from subprocess import STARTUPINFO, STARTF_USESHOWWINDOW, call def execute_gdal(cmd): si = ...


1

Using the QGIS GUI, it works for me with this command line: gdal_polygonize.bat F:/path/to/MyRast/MyRast.tif -f "ESRI Shapefile" G:/test.shp test DN Your codes misses the output field name which defaults to DN in the GUI.


1

The problem is you are passing a list to subprocess then specifying shell=True (which expects a string as input) so it is only taking the first item in the list, which is gdal_merge, and running this. Just running gdal_merge.py gives the same error. The same code but without shell=True should work: import subprocess filea = 'C:/Users/claudio/workspace/test/...


1

If you do not really need to print all those messages, then consider that printing messages are using a lot of RAM and I think disabling/reducing the amount of print commands will let you run the script. So what you need to do is to comment all the print commands and run it again.


Only top voted, non community-wiki answers of a minimum length are eligible