django-raster rendering raster url
i want to add raster functionality in django using postgis database using django-raster package and this docs http://django-raster.readthedocs.io/en/latest/tms.html here my code : models.py from django.contrib.gis.db import models class RasterWithName(models.Model): raster = models.RasterField() name = models.TextField() add raster using console : from django.contrib.gis.gdal import GDALRaster from myapp.models import RasterWithName gdal_raster = GDALRaster('C:/Users/username/Desktop/image.tif') rast = RasterWithName(name='one', raster=gdal_raster) rast.save() but i am very confused with Rendering tiles and urls. docs say : /raster/tiles/layer_id/{z}/{x}/{y}.png where the layer_id is the primary key of a raster layer. This structure can be used directly in online mapping software such as OpenLayers or Leaflet. An example request could look like this: /raster/tiles/23/8/536/143.png, returning a tile in png format of the layer with ID pk=23 at zoom level z=8 and indexes x=536 and y=143 but indexes x,y mean some random x,y coordinate in image ?anyway i using this url http://127.0.0.1:8000/raster/tiles/1/8/536/143.png or http://127.0.0.1:8000/raster/tiles/1/8/20/40.png(origin x,y in my image) and i take a black window in my browser,any idea where i have wrong in my url rendering ? -- https://mail.python.org/mailman/listinfo/python-list
file download using django and javascript
i have create a django app with REST JSON API and i fill html table in web page from my JSON. here some examples javascript snippets : var field22=document.getElementById('f22'); field22.innerHTML=e.target.feature.properties.id; var field23=document.getElementById('f23'); field23.innerHTML=e.target.feature.properties.file_1; html : id : file : i have parse my JSON in table with success but in the file field now i have a simple text from image path. Now i want in this path to have some hyperlink(or button) for download this file. any idea how to do this because i stack ?i dont know how to connection javasscript with my download or how to download this file using javascript django app code models.py: class MyModel(models.Model): file_1 = models.FileField(upload_to='documents/',blank=True, null=True) simple test django donwload : def download(request, id): product_file=MyModel.objects.get(pk=id) f = StringIO() zip = zipfile.ZipFile(f, 'w') product_file_url = product_file.file_1.url file_url = settings.MEDIA_ROOT + product_file_url[6:] filename = product_file_url[6:].split('/')[-1] zip.write(file_url,filename) zip.close() response = HttpResponse(f.getvalue(), content_type="application/zip") response['Content-Disposition'] = 'attachment; filename=file-download.zip' return response -- https://mail.python.org/mailman/listinfo/python-list
Re: PyQt4 QWebView cant load google maps markers
tell some solution ?yes you are correct for some seconds show me the mark but only for some seconds.can i update my pyqt4 to show me the mark ? -- https://mail.python.org/mailman/listinfo/python-list
PyQt4 QWebView cant load google maps markers
I want to create a simple python app using pyqt,QWebView and google maps with markers. The problem is that,the markers does not load inside the QWebView, as you can see they load just fine in the browser. here the simple code : import sys from PyQt4.QtCore import * from PyQt4.QtGui import * from PyQt4.QtWebKit import * import os app = QApplication(sys.argv) web_view= dialog.findChild(QWebView,"webView") google='https://www.google.gr/maps/place/Granite+Mountain+Hotshots+Memorial+State+Park/@34.1749572,-112.850308,12.78z/data=!4m13!1m7!3m6!1s0x872b08ebcb4c186b:0x423927b17fc1cd71!2zzpHPgc65zrbPjM69zrEsIM6Xzr3Pic68zq3Ovc61z4IgzqDOv867zrnPhM61zq_Otc-C!3b1!8m2!3d34.0489281!4d-111.0937311!3m4!1s0x80d330577faee965:0x66d75aef24890ae1!8m2!3d34.2032843!4d-112.7746582?hl=el' web_view2.load(QUrl(google)) web_view2.show() sys.exit(app.exec_()) error message : right click and select Inspect, then go to console and observe the messages console I take this error : TypeError: 'undefined' is not a function (evaluating 'this.D.bind(this)') marker.js:58 Any idea how to can fix that ? I need to add more settings to QWebView to work google maps with markers ? -- https://mail.python.org/mailman/listinfo/python-list
PyQt4 QWebView cant load google maps markers
I want to create a simple python app using pyqt,QWebView and google maps with markers. The problem is that,the markers does not load inside the QWebView, as you can see they load just fine in the browser. here the simple code : import sys from PyQt4.QtCore import * from PyQt4.QtGui import * from PyQt4.QtWebKit import * import os app = QApplication(sys.argv) web_view= dialog.findChild(QWebView,"webView") google='https://www.google.gr/maps/place/Granite+Mountain+Hotshots+Memorial+State+Park/@34.1749572,-112.850308,12.78z/data=!4m13!1m7!3m6!1s0x872b08ebcb4c186b:0x423927b17fc1cd71!2zzpHPgc65zrbPjM69zrEsIM6Xzr3Pic68zq3Ovc61z4IgzqDOv867zrnPhM61zq_Otc-C!3b1!8m2!3d34.0489281!4d-111.0937311!3m4!1s0x80d330577faee965:0x66d75aef24890ae1!8m2!3d34.2032843!4d-112.7746582?hl=el' web_view2.load(QUrl(google)) web_view2.show() sys.exit(app.exec_()) error message : right click and select Inspect, then go to console and observe the messages console I take this error : TypeError: 'undefined' is not a function (evaluating 'this.D.bind(this)') marker.js:58 Any idea how to can fix that ? I need to add more settings to QWebView to work google maps with markers ? -- https://mail.python.org/mailman/listinfo/python-list
DJANGO app loose path from batch file
I try to learn more about Django celery and rabbitmq to create some async tasks and I have some question. Some programs can provide PYTHON API to can some development to use modules from this program in python. one most way to take that PYTHON API from this program is to use batch file like this : @echo off SET PROGRAM_ROOT=C:\main-folder call "%PROGRAM_ROOT%"\bin\some-batch-file.bat SET PYCHARM="C:\Program Files\JetBrains\PyCharm 2017.1.5\bin\pycharm64.exe" set PYTHONPATH=%PYTHONPATH%;%PROGRAM_ROOT%\python; set PYTHONPATH=%PYTHONPATH%;%PROGRAM_ROOT%\site-packages; start "PyCharm aware of PROGRAM" /B %PYCHARM% %* if I run this batch file can I use all imports and modules from this program. that to release if add celery in my app and broker url rabbitmq server then if i use some module or some import from this python api then I take error message : no module name some_module_from_program (for all other modules celery and rabbitmq app work fine). that mean in celery and rabbitmq server loose that paths from batch file and I take this error. my question how to can define rabbitmq server to start server with that paths like batch file before to avoid this error? -- https://mail.python.org/mailman/listinfo/python-list
django celery delay function dont exetute
hello I want to use celery tasks in my Django project and I try to follow this very good tutorial from Mr.Vitor Freitas. but in my case and if try to run it that tutorial project i don't get results back the functions don't execute and in my case and in tutorial(i take message to wait and refresh and nothing after refresh). Any idea Why ? I think so the problem maybe is in RABBITQM server ?some configuration ? Just install Erlang(otp_win64_20.1.exe) and after RabbitMQ(rabbitmq-server-3.6.12.exe) here example code : settings.py CELERY_BROKER_URL = 'amqp://localhost' celery.py from __future__ import absolute_import import os from celery import Celery os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'mysite.settings') app = Celery('mysite') app.config_from_object('django.conf:settings', namespace='CELERY') app.autodiscover_tasks() tasks.py import string from django.contrib.auth.models import User from django.utils.crypto import get_random_string from celery import shared_task @shared_task def create_random_user_accounts(total): for i in range(total): username = 'user_{}'.format(get_random_string(10, string.ascii_letters)) email = '{}@example.com'.format(username) password = get_random_string(50) User.objects.create_user(username=username, email=email, password=password) return '{} random users created with success!'.format(total) _ _init_ _.py from .celery import app as celery_app __all__ = ['celery_app'] views.py from django.contrib.auth.models import User from django.contrib import messages from django.views.generic import TemplateView from django.views.generic.list import ListView from django.views.generic.edit import FormView from django.shortcuts import redirect from .forms import GenerateRandomUserForm from .tasks import create_random_user_accounts class UsersListView(ListView): template_name = 'core/users_list.html' model = User class GenerateRandomUserView(FormView): template_name = 'core/generate_random_users.html' form_class = GenerateRandomUserForm def form_valid(self, form): total = form.cleaned_data.get('total') create_random_user_accounts.delay(total) messages.success(self.request, 'We are generating your random users! Wait a moment and refresh this page.') return redirect('users_list') here details after cd my project path > celery -A mysite worker -l info : C:\Windows\System32>cd C:\Users\username\Desktop\django-celery-example-master C:\Users\username\Desktop\django-celery-example-master>celery -A mysite worker -l info -- celery@pc name v4.1.0 (latentcall) - --- * *** * -- Windows-8-6.2.9200 2017-10-29 18:10:24 -- * - --- - ** -- [config] - ** -- .> app: mysite:0x404e5c0 - ** -- .> transport: amqp://guest:**@localhost:5672// - ** -- .> results: disabled:// - *** --- * --- .> concurrency: 4 (prefork) -- *** .> task events: OFF (enable -E to monitor tasks in this worker) --- * - -- [queues] .> celery exchange=celery(direct) key=celery [tasks] . mysite.core.tasks.create_random_user_accounts [2017-10-29 18:10:24,596: CRITICAL/MainProcess] Unrecoverable error: TypeError('must be integer, not _subprocess_handle',) Traceback (most recent call last): File "C:\Python27\lib\site-packages\celery\worker\worker.py", line 203, in start self.blueprint.start(self) File "C:\Python27\lib\site-packages\celery\bootsteps.py", line 119, in start step.start(parent) File "C:\Python27\lib\site-packages\celery\bootsteps.py", line 370, in start return self.obj.start() File "C:\Python27\lib\site-packages\celery\concurrency\base.py", line 131, in start self.on_start() File "C:\Python27\lib\site-packages\celery\concurrency\prefork.py", line 112, in on_start **self.options) File "C:\Python27\lib\site-packages\billiard\pool.py", line 1007, in __init__ self._create_worker_process(i) File "C:\Python27\lib\site-packages\billiard\pool.py", line 1116, in _create_worker_process w.start() File "C:\Python27\lib\site-packages\billiard\process.py", line 124, in start self._popen = self._Popen(self) File "C:\Python27\lib\site-packages\billiard\context.py", line 383, in _Popen return Popen(process_obj) File "C:\Python27\lib\site-packages\billiard\popen_spawn_win32.py", line 64, in __init__ _winapi.CloseHandle(ht) TypeError: must be integer, not _subprocess_handle Traceback (most recent call last): File "", line 1, in File "C:\Python27\lib\site-packages\billiard\spawn.py", line 159, in spawn_main new_handle = steal_handle(parent_pid, pipe_handle) File "C:\Python27\lib\site-packages\billiard\reduction.py", line 126, in steal_handle _winapi.DUPLICATE_SAME_ACCESS | _winapi.DUPLICATE_CLOSE_SOURCE) WindowsError: [Error 6] -- https://mail.python.org/mailman/listinfo/python-list
Re: django project avoid reload page where work algorithm
Τη Κυριακή, 8 Οκτωβρίου 2017 - 10:48:38 μ.μ. UTC+3, ο χρήστης Richard Damon έγραψε: > On 10/8/17 11:58 AM, Xristos Xristoou wrote: > > Τη Κυριακή, 8 Οκτωβρίου 2017 - 6:35:28 μ.μ. UTC+3, ο χρήστης MRAB έγραψε: > >> On 2017-10-08 15:27, Xristos Xristoou wrote: > > > >> Do you mean "long reload"? > > > > user can put some numbers in my html template and i take that numbers and i > > sue it in specific mathematical algorithm that algorithm to create result > > need time between 5-10 minutes in that time browser stay on reload...that > > i mean > > > > It sounds like the fundamental problem is that you are doing the > calculation in the web page handler. This means that the browser will be > stuck in the page load until the calculation finishes, and that if the > user aborts the access (or loses connection) then the web page handler > is aborted. > > What you need to do is rather than doing the calculation in the page > handler, you need to kick off an independent process to do the > calculation, and then immediately finish the page (maybe giving the use > a link to a page they can check to see if a result is available). yes this is nice can you help me to do that? -- https://mail.python.org/mailman/listinfo/python-list
Re: django project avoid reload page where work algorithm
Τη Κυριακή, 8 Οκτωβρίου 2017 - 6:35:28 μ.μ. UTC+3, ο χρήστης MRAB έγραψε: > On 2017-10-08 15:27, Xristos Xristoou wrote: > Do you mean "long reload"? user can put some numbers in my html template and i take that numbers and i sue it in specific mathematical algorithm that algorithm to create result need time between 5-10 minutes in that time browser stay on reload...that i mean -- https://mail.python.org/mailman/listinfo/python-list
Re: django project avoid reload page where work algorithm
> You can use the smtplib module to send an email. ok but how to avoid pong reload on page ?can you help me ? -- https://mail.python.org/mailman/listinfo/python-list
Re: django project avoid reload page where work algorithm
> You mentioned email, so why not just ask for an email address to which > you will send the result? i have user email from register i need to do all automate,how to use celery for this ? -- https://mail.python.org/mailman/listinfo/python-list
django project avoid reload page where work algorithm
I have a website where the user can be put three numbers on my html template and get some results from my personal mathematical algorithm. the result save at user personal table on my database and can see in specific tab in my website. my problem is where the algorithm to calculate result maybe take time between 5-10 minutes in this time the browser stay on reload. if user change tab or close browser or maybe have problem with internet connection then loose that request and need again to put the numbers and again wait for results. I want after the user request from my form in html to keep this request and work my algorithm without reload the page and where the algorithm finish then to send the user some email or message or just need the user visit the tab of results to see new results. that I want to avoid the problems where the algorithm is in running and user loose data or request or time. is easy to do that using suproccess,celery or RabbitMQ ? any idea ? here the code views.py def math_alg(request): if request.method == "POST": test = request.POST.get('no1') test = request.POST.get('no3') test = request.POST.get('no3') #start algorith calc_math(no1,no1,no3,result) instance = rmodel.objects.create(user=request.user,rfield=result) instance.save return render(request, 'page.html', {'result': result}) html : {% csrf_token %} op math calculate: {{result }} -- https://mail.python.org/mailman/listinfo/python-list
python multiprocessing
I have three functions in the python that each one puts an image (image path) as input and makes a simple image processing and creates a new image (image path) as output. in the example below, one function depends on the other, ie: the function of alg2 takes as input the image that generates the function of alg and the function of alg3 assign as input the image that generates the function of alg2 which depends on the function of alg1. (I hope you do not mind basically) because of their relatively high execution time (image processing is that) I would like to ask if I can to parallelize them using python multiprocessing. I have read about multiprocessing map and pool but I was pretty confused . whenever I summarize I have three interdependent functions and I would like to run them together if done. I would also like to know how I would perform these three functions in a contemporary way if they were not interdependent, ie each was autonomous. def alg1(input_path_image,output_path_image): start = timeit.default_timer() ###processing###) stop = timeit.default_timer() print stop - start return output_path_image def alg1(output_path_image,output_path_image1): start = timeit.default_timer() ###processing### stop = timeit.default_timer() print stop - start return output_path_image1 def alg3(output_path_image1,output_path_image2): start = timeit.default_timer() ###processing### stop = timeit.default_timer() print stop - start return output_path_image2 if __name__ == '__main__': alg1(output_path_image,output_path_image) alg2(output_path_image1,output_path_image1) alg3(output_path_image2,output_path_image2) -- https://mail.python.org/mailman/listinfo/python-list
python multiprocessing question
hello i have create a 4 function using python(f1,f2,f3,f4) and i have 4 cores in my system. def f1() ... ... def f2() ... ... def f3() ... ... def f4() ... ... that functions operate independently of each other but how to use multiprocessing to define the cores to work that functions parallel to win some time ? sorry i am very new and i need some help or some example. -- https://mail.python.org/mailman/listinfo/python-list
automatically set field values in django using function
I need t define some values of fields automatically in my model using function. my function get input image path and calculate and I need that calculation results to define my database fields in Django. but first the upload image need to get the path in server and after i can to define the values.. i will test this but myfunc cant understand the image path from upload image. here the code : def myview(request): uploadimages = UploadImagesForm(request.POST or None, request.FILES or None) if uploadimages.is_valid(): # Get the images that have been browsed if request.FILES.get('multipleimages', None) is not None: images = request.FILES.getlist('multipleimages') for image in images: instance = MyModel.objects.create(field1=request.user, field2=image) instance.field3 = myfunc(image) instance.field4 = myfunc(image) instance.save() -- https://mail.python.org/mailman/listinfo/python-list
Re: python script is slowly after use multiprocessing
@MRAB tell me your proposal for this ? @Ben Bacarisse i dont get some error,i have wrong map ? -- https://mail.python.org/mailman/listinfo/python-list
python script is slowly after use multiprocessing
i have create an image processing python function. my system have 4 cores + 4 threads. i want to use multiprocessing to speed up my function,but anytime to use multiprocessing packages my function is not faster and is 1 minute slowly. any idea why ?first time use multiprocessing packages. main function : if __name__ == '__main__': in_path="C:/Users/username/Desktop/in.tif" out_path="C:/Users/username/Desktop/out.tif" myfun(in_path, out_path) time=3.4 minutes with multiprocessing map : if __name__ == '__main__': p = Pool(processes=4) in_path="C:/Users/username/Desktop/in.tif" out_path="C:/Users/username/Desktop/out.tif" result = p.map(myfun(in_path,out_path)) time=4.4 minutes if __name__ == '__main__': pool = multiprocessing.Pool(4) in_path="C:/Users/username/Desktop/in.tif" out_path="C:/Users/username/Desktop/out.tif" pool.apply_async(myfun, args=(in_path,out_path,)) pool.close() pool.join() time=4.5 minutes -- https://mail.python.org/mailman/listinfo/python-list
Re: DJANGO cannot import name _compare_digest
i dont have 'operator.py' in my system only 'test_operator.py' and 'fix_operator.py' if : import sys print sys.modules['operator'] i get this : that say me how to rename it? -- https://mail.python.org/mailman/listinfo/python-list
DJANGO cannot import name _compare_digest
hello i have python 7.13 DJANGO 1.11.2 version django-crypto 0.20 version on windows 10. i want to create a DJANGO app but anytime to try to migrate i take that error : from django.utils.crypto import get_random_string File "C:\Python27\lib\site-packages\django\utils\crypto.py", line 8, in import hmac File "C:\Python27\Lib\hmac.py", line 8, in from operator import _compare_digest as compare_digest ImportError: cannot import name _compare_digest how to fix it ? -- https://mail.python.org/mailman/listinfo/python-list
json to access using python
hello I have a json url and i want from this url to update my table in microsoft access,how to do that using python or some tool of microsoft access ? -- https://mail.python.org/mailman/listinfo/python-list
Re: python and post gis question
Τη Παρασκευή, 16 Ιουνίου 2017 - 10:59:10 μ.μ. UTC+3, ο χρήστης Xristos Xristoou έγραψε: > I have create a python script where use post gis queries to automate some > intersection tasks using postgis database. > > in my database I have polygons,points and lines. > > here my snippet code of my script : > > try: > if str(geomtype) == 'point': > geomtype = 1 > elif str(geomtype) == 'linestring': > geomtype = 2 > elif str(geomtype) == 'polygon': > geomtype = 3 > else: > raise TypeError() > sql = "\nDROP TABLE IF EXISTS {0}.{1};\nCREATE TABLE {0}.{1} AS (SELECT > {4},\n(st_dump(ST_CollectionExtract(st_intersection(dbgis.{2}.shape,dbgis.{3}.shape)::GEOMETRY(GEOMETRY,2345),{5}))).geom > AS shape\nFROM dbgis.{2}, dbgis.{3} WHERE > st_intersects(dbgis.{2}.shape,dbgis.{3}.shape) AND {5}=3);\nCREATE INDEX > idx_{2}_{3}_{6} ON {0}.{1} USING GIST (shape);\nALTER TABLE {0}.{1} ADD > COLUMN id SERIAL;\nALTER TABLE {0}.{1} ADD COLUMN my_area double > precision;\nUPDATE {0}.{1} SET my_area = ST_AREA(shape::GEOMETRY);\nALTER > TABLE {0}.{1} ADD PRIMARY KEY (id);\nSELECT > pop_g_col('{0}.{1}'::REGCLASS);\nGRANT ALL ON {0}.{1} TO GROUP u_cl;\nGRANT > ALL ON {0}.{1} TO GROUP my_user;\n-- VACUUM ANALYZE > {0}.{1};\n".format(schema, table, tablea, tableb, selects, geomtype, id_gen()) > return sql > this post gis sql query work nice but I need the new field where I want to > add my_area to create only for polygons layers. > > that code create for all layers (lines,points,polygons) that field my_area if > layer is point or line then take value 0 I don't like that I don't need it. > > how to change this code to create my_area only in polygons ? i wabt to ccreate a new field only in polygons layera -- https://mail.python.org/mailman/listinfo/python-list
Re: python and post gis question
Τη Παρασκευή, 16 Ιουνίου 2017 - 10:59:10 μ.μ. UTC+3, ο χρήστης Xristos Xristoou έγραψε: > I have create a python script where use post gis queries to automate some > intersection tasks using postgis database. > > in my database I have polygons,points and lines. > > here my snippet code of my script : > > try: > if str(geomtype) == 'point': > geomtype = 1 > elif str(geomtype) == 'linestring': > geomtype = 2 > elif str(geomtype) == 'polygon': > geomtype = 3 > else: > raise TypeError() > sql = "\nDROP TABLE IF EXISTS {0}.{1};\nCREATE TABLE {0}.{1} AS (SELECT > {4},\n(st_dump(ST_CollectionExtract(st_intersection(dbgis.{2}.shape,dbgis.{3}.shape)::GEOMETRY(GEOMETRY,2345),{5}))).geom > AS shape\nFROM dbgis.{2}, dbgis.{3} WHERE > st_intersects(dbgis.{2}.shape,dbgis.{3}.shape) AND {5}=3);\nCREATE INDEX > idx_{2}_{3}_{6} ON {0}.{1} USING GIST (shape);\nALTER TABLE {0}.{1} ADD > COLUMN id SERIAL;\nALTER TABLE {0}.{1} ADD COLUMN my_area double > precision;\nUPDATE {0}.{1} SET my_area = ST_AREA(shape::GEOMETRY);\nALTER > TABLE {0}.{1} ADD PRIMARY KEY (id);\nSELECT > pop_g_col('{0}.{1}'::REGCLASS);\nGRANT ALL ON {0}.{1} TO GROUP u_cl;\nGRANT > ALL ON {0}.{1} TO GROUP my_user;\n-- VACUUM ANALYZE > {0}.{1};\n".format(schema, table, tablea, tableb, selects, geomtype, id_gen()) > return sql > this post gis sql query work nice but I need the new field where I want to > add my_area to create only for polygons layers. > > that code create for all layers (lines,points,polygons) that field my_area if > layer is point or line then take value 0 I don't like that I don't need it. > > how to change this code to create my_area only in polygons ? what you mean where? -- https://mail.python.org/mailman/listinfo/python-list
python and post gis question
I have create a python script where use post gis queries to automate some intersection tasks using postgis database. in my database I have polygons,points and lines. here my snippet code of my script : try: if str(geomtype) == 'point': geomtype = 1 elif str(geomtype) == 'linestring': geomtype = 2 elif str(geomtype) == 'polygon': geomtype = 3 else: raise TypeError() sql = "\nDROP TABLE IF EXISTS {0}.{1};\nCREATE TABLE {0}.{1} AS (SELECT {4},\n(st_dump(ST_CollectionExtract(st_intersection(dbgis.{2}.shape,dbgis.{3}.shape)::GEOMETRY(GEOMETRY,2345),{5}))).geom AS shape\nFROM dbgis.{2}, dbgis.{3} WHERE st_intersects(dbgis.{2}.shape,dbgis.{3}.shape) AND {5}=3);\nCREATE INDEX idx_{2}_{3}_{6} ON {0}.{1} USING GIST (shape);\nALTER TABLE {0}.{1} ADD COLUMN id SERIAL;\nALTER TABLE {0}.{1} ADD COLUMN my_area double precision;\nUPDATE {0}.{1} SET my_area = ST_AREA(shape::GEOMETRY);\nALTER TABLE {0}.{1} ADD PRIMARY KEY (id);\nSELECT pop_g_col('{0}.{1}'::REGCLASS);\nGRANT ALL ON {0}.{1} TO GROUP u_cl;\nGRANT ALL ON {0}.{1} TO GROUP my_user;\n-- VACUUM ANALYZE {0}.{1};\n".format(schema, table, tablea, tableb, selects, geomtype, id_gen()) return sql this post gis sql query work nice but I need the new field where I want to add my_area to create only for polygons layers. that code create for all layers (lines,points,polygons) that field my_area if layer is point or line then take value 0 I don't like that I don't need it. how to change this code to create my_area only in polygons ? -- https://mail.python.org/mailman/listinfo/python-list
dont exetute my exe after decompile and change code
i have an .exe file where file compiled by py2exe in my .exe folder i have some .dll files one .exe file and library.zip file and inside this zip i have to many .pyccombile files. i have decompile this files from library.zip using this program and that program create me new file where i can see and change my code. i have open this file where i need and i change my code using python editor and finaly i save as new script code with the some name and extension .pyc with purpose to replace first .pyc. zip again library folder and i try to run .exe prgram but after the changes the program dont exetute. where step i have wrong in my task ?i need with the some way to re-compile again ? -- https://mail.python.org/mailman/listinfo/python-list
How to decompile an exe file compiled by py2exe?
hello How to decompile an exe file compiled by py2exe? in my file i have a library.zip file i dont if that help this work. i need some easy because i am very new i try some programs but without results. -- https://mail.python.org/mailman/listinfo/python-list
take select request from django from
hello i have create a select django form with list of images for per user. How to take that select request in my views.py ? i have success only to create correct that select list but i need take that select request but i dont know how. models.py class MyModel(models.Model): user = models.ForeignKey(User, unique=True) upload = models.ImageField(upload_to='upload') views.py @login_required(login_url="login/") def carlist(request): Myform = MyModelForm(user=request.user) return render(request,'about.html',{'Myform':Myform}) select django form : class MyModelForm(ModelForm): def __init__(self, *args, **kwargs): # extract "user" from kwrags (passed upon form init) if 'user' in kwargs: self.user = kwargs.pop('user') super(MyModelForm, self).__init__(*args, **kwargs) # generate the choices as (display, value). # Display is the one that'll be shown to user, value is # the one that'll be sent upon submitting # (the "value" attribute of ) choices = MyModel.objects.filter(user=self.user).values_list('upload', 'id') self.fields['upload'].widget = Select(choices=choices) class Meta: model = MyModel fields = ('upload',) html : {% csrf_token %} {{ Myform}} for example Myform now have a list of user images that is correct but after from that i need the select images from the form. can do it that with my code or not ? -- https://mail.python.org/mailman/listinfo/python-list
how to get image url from django form
i have create a simple django form where the authentication user can select one of personal images where have upload before and i want do something with that request in my views.py. but i dont know how to take the image url from that request in my view because first i using request.user in the form to take only self user images and i dont know how to continue and finaly i take that images url. the form work great show me only the self user images any idea ? here the code views.py @login_required(login_url="login/") def carlist(request): Myform = MyModelForm(user=request.user) return render(request,'about.html',{'Myform':Myform}) select django form : class MyModelForm(ModelForm): def __init__(self, *args, **kwargs): # extract "user" from kwrags (passed upon form init) if 'user' in kwargs: self.user = kwargs.pop('user') super(MyModelForm, self).__init__(*args, **kwargs) # generate the choices as (display, value). Display is the one that'll be shown to user, value is the one that'll be sent upon submitting (the "value" attribute of ) choices = MyModel.objects.filter(user=self.user).values_list('upload', 'id') self.fields['upload'].widget = Select(choices=choices) class Meta: model = MyModel fields = ('upload',) html : {% csrf_token %} {{ Myform}} -- https://mail.python.org/mailman/listinfo/python-list
django user images
hello if i want to create a query in django with to take all images and preview that list in html like easy work. but if want in html page preview only the personal images where login user what changes i need in my code ? model.py class MyModel(models.Model): user = models.ForeignKey(User, unique=True) photo = models.ImageField(upload_to='images') views.py class BasicUploadView(request): photos_list = Photo.objects.all() return render(request, 'photos/basic_upload/index.html', {'photos': photos_list}) html page : {% for photo in photos %} {{ photo.file.name }} {% endfor %} -- https://mail.python.org/mailman/listinfo/python-list
auth select chooses in forms.py
I have read this code in this question and look nice. but if I have user auth and I want user select only your odjects how to change that code ?for ex chooses your personal upload images. from django.forms.widgets import Select class ProvinceForm(ModelForm): class Meta: CHOICES = Province.objects.all() model = Province fields = ('name',) widgets = { 'name': Select(choices=( (x.id, x.name) for x in CHOICES )), } my model : class MyModel(models.Model): user = models.ForeignKey(User, unique=True) upload = models.ImageField(upload_to='images') -- https://mail.python.org/mailman/listinfo/python-list
django add images to models.py from views.py
I create a simple Django authentication app and work fine. now I want to add a python script where to can do some simple image processing. my python script for processing work fine and I put in the views.py. my question is the new image created from the script how to can add back to image from mymodel ?first must be save temporarily ? can I do this ? sorry I am new. class MyModel(models.Model): user = models.ForeignKey(to=settings.AUTH_USER_MODEL) image = models.ImageField(upload_to=generate_path(self.user)) forms.py @login_required class CronForm(forms.Form): days = forms.ModelChoiceField(queryset=MyModel.objects.all) views.py @login_required def show_something(request,user_id): user = UserProfile.objects.get(user__id=user_id) form = CronForm() if request.method == "POST": form = CronForm(request.POST) if form.is_valid: # do image processing # do image processing # and finaly ta ke new image from the image processing like newim='newim.tif' return HttpResponseRedirect(...) errors = form.errors or None return render(request, 'path/to/template.html',{ 'form': form, 'errors': errors, }) -- https://mail.python.org/mailman/listinfo/python-list
django authentication multi upload files
I have create I simple Django auth project and I need to add the user to can upload some images. multi upload images from internet views.py from django.shortcuts import render from django.http import HttpResponse def Form(request): return render(request, "index/form.html", {}) def Upload(request): for count, x in enumerate(request.FILES.getlist("files")): def process(f): with open('/Users/Michel/django_1.8/projects/upload/media/file_' + str(count), 'wb+') as destination: for chunk in f.chunks(): destination.write(chunk) process(x) return HttpResponse("File(s) uploaded!") but how to define that to multi upload images in specific unique folder for any user. first I use login_required and in destination I use user_directory_path. But how to define the code in the views.py to work with authentication per user. for example for user_1 upload images in your folder for user_1 in folder for user_2. medels.py def user_directory_path(instance, filename): return 'user_{0}/{1}'.format(instance.user.id, filename) class MyModel(models.Model): user = models.ForeignKey(User, unique=True) upload = models.ImageField(upload_to=user_directory_path) -- https://mail.python.org/mailman/listinfo/python-list
add processing images in the model.py using django
want to create a simple image processing using Django. my tasks is easy I have some user a simple model and that user can upload images in my project using html form or django form and then that images saves to upload_to='mypath' in upload from my model. but I have some questions : I have a simple image processing in my views.py if the processing complete success then create new image and I want that image to add in the upload from my model . how to do that in Django ? models.py class MyModel(models.Model): user = models.ForeignKey(User) upload = models.ImageField(upload_to='mypath/personal/folder/per/user') views.py def index(request): form = ImageUploadForm(request.POST or None, request.FILES or None) if request.method == "POST" and form.is_valid(): image_file = request.FILES['image'].read() ''' image processing new image ''' return render_to_response("blog/success.html", {"new image":new image}) return render_to_response('blog/images.html', {'form': form}, RequestContext(request)) -- https://mail.python.org/mailman/listinfo/python-list
Re: relative paths connect using python
Τη Δευτέρα, 20 Μαρτίου 2017 - 7:05:33 μ.μ. UTC+2, ο χρήστης Xristos Xristoou έγραψε: > i have a little confused problem. i want to store some paths from images > using python 2.7 in windows 10. > i have some relative path like this var1='C:/my/store/path' and in the final > folder where in my example is the name 'path' inside that folder i have some > images like this : > -path >-myimage_1010_im.png >-myimage_1010_im1.png >-myimage_1010_im3.png >-myimage_1020_im.png >-myimage_1020_im1.png > can i connect my relative path like var1 with the images using only the > number of the mid name of images and finaly i take the full original path > like this var1='C:/my/store/path/myimage_1010_im.png' ? > i try something but not work > import os > cwd = os.getcwd() > path = os.path.join(cwd, "my_file") i want like this a=1010 path = os.path.join(cwd, a") print path and the path i need full absolute path like this : var1='C:/my/store/path/myimage_1010_im.png' in my first code i dont have error but i take wrong for me path not full -- https://mail.python.org/mailman/listinfo/python-list
relative paths connect using python
i have a little confused problem. i want to store some paths from images using python 2.7 in windows 10. i have some relative path like this var1='C:/my/store/path' and in the final folder where in my example is the name 'path' inside that folder i have some images like this : -path -myimage_1010_im.png -myimage_1010_im1.png -myimage_1010_im3.png -myimage_1020_im.png -myimage_1020_im1.png can i connect my relative path like var1 with the images using only the number of the mid name of images and finaly i take the full original path like this var1='C:/my/store/path/myimage_1010_im.png' ? i try something but not work import os cwd = os.getcwd() path = os.path.join(cwd, "my_file") -- https://mail.python.org/mailman/listinfo/python-list
Re: python script Non-ASCII character
Τη Κυριακή, 19 Μαρτίου 2017 - 7:38:19 μ.μ. UTC+2, ο χρήστης Xristos Xristoou έγραψε: @Terry non-ascii in pathnames i need for ex :var1="C:\Users\username\Desktop\my language\mylanguage\myfile" and for the blank ? -- https://mail.python.org/mailman/listinfo/python-list
Re: python script Non-ASCII character
Τη Κυριακή, 19 Μαρτίου 2017 - 7:38:19 μ.μ. UTC+2, ο χρήστης Xristos Xristoou έγραψε: yes that i know but i need python 2.7 for my task -- https://mail.python.org/mailman/listinfo/python-list
Re: python script Non-ASCII character
Τη Κυριακή, 19 Μαρτίου 2017 - 7:38:19 μ.μ. UTC+2, ο χρήστης Xristos Xristoou έγραψε: how to define my script with encoding of ISO-8859-7 or UTF-8?and for the blanks ? -- https://mail.python.org/mailman/listinfo/python-list
python script Non-ASCII character
hello i have create a python script when read some files using paths and do something with that files. if that paths for files is in english likes this "c:/my_path/english " then python script working but if that paths is in my main language or the path have some blank character then not working and i take that error : SyntaxError: Non-ASCII character '\xce' in file Untitled_.py on line 15, but no encoding declared; can i fix that in python 2.7.13 ? can i find some solution to python read paths in my main language or paths with blanks? -- https://mail.python.org/mailman/listinfo/python-list
Re: python and databases
Τη Τρίτη, 14 Μαρτίου 2017 - 9:59:42 μ.μ. UTC+2, ο χρήστης Xristos Xristoou έγραψε: first thx for response second i cant use additional packate because i build tool for other python program and that use standar python only, sqlite is in standar python 2.7 @Irmen de Jong ? can use quyries in CSV @ Irving Duran @Chris Angelico ? -- https://mail.python.org/mailman/listinfo/python-list
python and databases
I have a database in microsoft ACCESS with about 150 records.. if I want to get some data from this database using a query in python and i want to store in some variables in python that will do this ? to avoid the 150 if ...: Using the standard library the python? know easily put it an SQL query but i canot use additional library python. -- https://mail.python.org/mailman/listinfo/python-list
python and pyqt4
i will want to create a simple python script with pyqt4 and Q designer where the user put a number (line_edit) and if that number is something the user take back three new codes(lineEdit_2,lineEdit_3,lineEdit_4) and if user press ok(buttonBox) then plugin do something else in the some GUI. for that i create a new additional pushButton in Qdesigner and i create additional def function(run1) for execute code for pushButton. first i add new pushbutton in __init__ : def __init__(self, iface): self.dlg = pluginDialog() self.dlg.pushButton.clicked.connect(self.run1) plugin work without error but dont show me the codes (lineEdit_2,lineEdit_3,lineEdit_4) in the plugin window if i press pushbutton any idea ? my python code : def run1(self): distance = str(self.dlg.lineEdit.text()) if distance==0: area1='some' area2='hello' area3='world' self.dlg.lineEdit_2.setText(str(area1)) self.dlg.lineEdit_3.setText(str(area2)) self.dlg.lineEdit_4.setText(str(area3)) def run(self): self.dlg.show() result = self.dlg.exec_() if result: pass and i try to replace run1 with : def run1(self): self.dlg.show() result = self.dlg.exec_() if result: distance = str(self.dlg.lineEdit.text()) if distance==0: area1='some' area2='hello' area3='world' self.dlg.lineEdit_2.setText(str(area1)) self.dlg.lineEdit_3.setText(str(area2)) self.dlg.lineEdit_4.setText(str(area3)) pass but no change. -- https://mail.python.org/mailman/listinfo/python-list
python/gui question
i want to create a very simple python plugin using QT designer but i an not sure how to connect my variable from gui to my python script. my gui is simple have only one lineEdit and ok or cancel. in the gui (widget): 20 90 171 31 def run(self): self.dlg.show() result = self.dlg.exec_() if result: distance = self.dlg.lineEdit.value() if distance == 0: #do something else: #do sothing else pass i test this code but dont work dont show me anything. any idea ? -- https://mail.python.org/mailman/listinfo/python-list
DJANGO image processing
I want to create a django app with the base64 help where the users can upload images(specific ".tiff" ext) using DJANGO forms without model and without that images store in my server. and i will the users can be get back new processing image. i have success with encode/decode image with base64 and i can display that image in template using safari because that can display TIFF images. here the code : views.py def convert_to_base64(image_file): base64_string = base64.encodestring(image_file) return "data:image/png;base64,"+base64_string @csrf_exempt def index(request): form = ImageUploadForm(request.POST or None, request.FILES or None) if request.method == "POST" and form.is_valid(): image_file = request.FILES['image'].read() base64_string = convert_to_base64(image_file) file = base64_string.decode('utf8') return render_to_response("blog/success.html", {"image_file":file}) return render_to_response('blog/calc.html', {'form': form}, RequestContext(request)) my problem is now after the base64 i cant use that image for image processing(work fine in standalone python script) and i take two error : RuntimeError at / not a string in the browser and that message in command line : "GET / HTTP/1.1" 200 346 ERROR 4: `II*' does not exist in the file system, and is not recognised as a supported dataset name. here the code : @csrf_exempt def index(request): form = ImageUploadForm(request.POST or None, request.FILES or None) if request.method == "POST" and form.is_valid(): image_file = request.FILES['image'].read() base64_string = convert_to_base64(image_file) file = base64_string.decode('utf8') file_like = cStringIO.StringIO(image_file) flow_direction_uri = "output.tif" routing.flow_direction_d_inf(file_like, flow_direction_uri) return render_to_response("blog/success.html", {"image_file":file}) return render_to_response('blog/calc.html', {'form': form}, RequestContext(request)) and if i use file = base64_string.decode('utf8') as input in my function then i take that error : AttributeError at / 'NoneType' object has no attribute 'GetRasterBand' and in command line i take to like that : AIAAgACAAIAAgACAAIAAgACAAIAAgACA AIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAA gACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACA AIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAA with to many lines. -- https://mail.python.org/mailman/listinfo/python-list
image handling(donwloading/display) in django using html and form
i want to do some image processing using Django and now work and on the image handling(donwloading/display) using Django. first on my task i dont want to store that images on my server. but i have some problems. that my code : urls.py from django.conf.urls import url from . import views urlpatterns = [ #url(r'^$',views.index, name='index'), url(r'^$',views.calc, name='calc'), ] file.html Title {% csrf_token %} {{ form.as_p }} {{ flow_direction_uri.url }} forms.py from django import forms class ImageUploadForm(forms.Form): """Image upload form.""" image = forms.ImageField() views.py from django.shortcuts import render from django.shortcuts import render_to_response from django.template import RequestContext from pygeoprocessing import routing from django import forms from blog.forms import ImageUploadForm def calc(request): form = ImageUploadForm() if request.method == "POST" and form.is_valid(): image_file = request.FILES['image'] form.save() '''do something image process''' '''and finaly i take that output in standalone python script out of django''' outpu1 = "outpu1.tif" outpu2 = "outpu2.tif" outpu3 = "outpu3.tif" outpu4 = "outpu4.tif" return render_to_response ('blog/calc.html', {'form':form,'output1':output1}, RequestContext(request)) and i take that error : UnboundLocalError at / local variable 'output1' referenced before assignment but i thing so its not that error why if i change to response request to {return render_to_response ('blog/calc.html', {'form':form}, RequestContext(request)) ` dont show me that error i can see in the browser two buttons where i can choose image from my files and submit button but i thing so that do nothing. maybe to use html forms and no Django forms ? -- https://mail.python.org/mailman/listinfo/python-list
DJANGO IMAGES QUESTION
who is the better method to take images from uses(visitors) on my web site and to return the new images(processing) back to users using DJANGO? i am new i dont know how to connect my python script with the html templetes to take the images and how to return? for example my script take images paths to processing new images with new paths. -- https://mail.python.org/mailman/listinfo/python-list
Re: count points where is within the polygons using shapely and fiona
tell your proposal to count -- https://mail.python.org/mailman/listinfo/python-list
count points where is within the polygons using shapely and fiona
i tried to count points from the point shapefile where is within in the polygon shapefile but i fail.Maybe my code is complete wrong but i tried. any idea how to fix my code ? i want fast method because i have big data features from shapely.geometry import shape import fiona filepath1 = "point.shp" file1features = [] intersectfeatures_file1 = [] intersectfeatures_file2 = [] count =0 count=count+1 outschema = None with fiona.collection(filepath1, "r") as input1: outschema = input1.schema.copy() for p1 in input1: file1features.append(p1) filepath2 = "polygon.shp" with fiona.collection(filepath2, "r") as input2: for p2 in input2: for p1 in file1features: [count for i in [shape(p1['geometry']).within(shape(p2['geometry']))]] if p1 not in intersectfeatures_file1: intersectfeatures_file1.append(p1) if p2 not in intersectfeatures_file2: intersectfeatures_file2.append(p2) print count ''' if intersectfeatures_file1: outfile = "outputfile1.shp" with fiona.collection(outfile, "w", "ESRI Shapefile", outschema) as output: for outfeature in intersectfeatures: output.write(outfeature) if intersectfeatures_file2: outfile = "outputfile2.shp" with fiona.collection(outfile, "w", "ESRI Shapefile", outschema) as output: for outfeature in intersectfeatures: output.write(outfeature) ''' on the print count i take 20 times the number 1. after for this count i want to export to new shapefile the polygons where have specific number of points. thnx -- https://mail.python.org/mailman/listinfo/python-list
Re: python corrupted double-linked list error
how to understand that ?solution ? -- https://mail.python.org/mailman/listinfo/python-list
python corrupted double-linked list error
i am a python 2.7 and ubuntu 16.04 user and i have unexpected error when try to excute some python scripts . i use pycharm and i have the some error when i try to run python script from the ubuntu terminal. the error : *** Error in `/usr/bin/python2.7': corrupted double-linked list: 0x0b83c880 *** the error message : === Backtrace: = /lib/i386-linux-gnu/libc.so.6(+0x67377)[0xb764b377] /lib/i386-linux-gnu/libc.so.6(+0x6d2f7)[0xb76512f7] /lib/i386-linux-gnu/libc.so.6(+0x6e2f1)[0xb76522f1] /usr/lib/i386-linux-gnu/libstdc++.so.6(_ZdlPv+0x18)[0xb6ba9d88] /usr/lib/libgdal.so.1(_ZN15GDALMajorObjectD0Ev+0x22)[0xb075a582] /usr/lib/libgdal.so.1(GDALClose+0x77)[0xb074d747] /usr/lib/qgis/plugins/libgdalprovider.so(+0xa930)[0xa4888930] /usr/lib/qgis/plugins/libgdalprovider.so(+0xaafa)[0xa4888afa] /usr/lib/libqgis_core.so.2.18.3(_ZN13QgsRasterPipeD1Ev+0x75)[0xb3d6a7d5] /usr/lib/libqgis_core.so.2.18.3(_ZN14QgsRasterLayerD1Ev+0x2f)[0xb3d5cd0f] /usr/lib/python2.7/dist-packages/qgis/_core.i386-linux-gnu.so(_ZN17sipQgsRasterLayerD1Ev+0x3b)[0xb489dd2b] /usr/lib/python2.7/dist-packages/qgis/_core.i386-linux-gnu.so(_ZN17sipQgsRasterLayerD0Ev+0x1a)[0xb489dd5a] /usr/lib/python2.7/dist-packages/qgis/_core.i386-linux-gnu.so(+0x43df45)[0xb4883f45] /usr/lib/python2.7/dist-packages/qgis/_core.i386-linux-gnu.so(+0x43df8a)[0xb4883f8a] /usr/lib/python2.7/dist-packages/sip.i386-linux-gnu.so(+0x5d49)[0xb724dd49] /usr/lib/python2.7/dist-packages/sip.i386-linux-gnu.so(+0xc19b)[0xb725419b] /usr/bin/python2.7[0x8144aad] /usr/bin/python2.7[0x80fd127] /usr/bin/python2.7(PyDict_SetItem+0x478)[0x80e9268] /usr/bin/python2.7(_PyModule_Clear+0xba)[0x8149a1a] /usr/bin/python2.7(PyImport_Cleanup+0x37a)[0x81495ca] /usr/bin/python2.7(Py_Finalize+0x99)[0x8147399] /usr/bin/python2.7(Py_Main+0x4bd)[0x80e639d] /usr/bin/python2.7(main+0x26)[0x80e5ec6] /lib/i386-linux-gnu/libc.so.6(__libc_start_main+0xf7)[0xb75fc637] /usr/bin/python2.7[0x80e5dc8] === Memory map: 08048000-0838f000 r-xp 08:01 1583892/usr/bin/python2.7 0839-08391000 r--p 00347000 08:01 1583892/usr/bin/python2.7 08391000-083f1000 rw-p 00348000 08:01 1583892/usr/bin/python2.7 083f1000-08406000 rw-p 00:00 0 0a0f7000-0ba69000 rw-p 00:00 0 [heap] a03e-a03eb000 r-xp 08:01 1049930 /lib/i386-linux-gnu/libnss_files-2.23.so a03eb000-a03ec000 r--p a000 08:01 1049930 /lib/i386-linux-gnu/libnss_files-2.23.so a03ec000-a03ed000 rw-p b000 08:01 1049930 /lib/i386-linux-gnu/libnss_files-2.23.so a03ed000-a03f3000 rw-p 00:00 0 a03f3000-a03fe000 r-xp 08:01 1048664 /lib/i386-linux-gnu/libnss_nis-2.23.so a03fe000-a03ff000 r--p a000 08:01 1048664 /lib/i386-linux-gnu/libnss_nis-2.23.so a03ff000-a040 rw-p b000 08:01 1048664 /lib/i386-linux-gnu/libnss_nis-2.23.so a040-a0421000 rw-p 00:00 0 a0421000-a050 ---p 00:00 0 a0509000-a052 r-xp 08:01 1048674 /lib/i386-linux-gnu/libnsl-2.23.so a052-a0521000 r--p 00016000 08:01 1048674 /lib/i386-linux-gnu/libnsl-2.23.so a0521000-a0522000 rw-p 00017000 08:01 1048674 /lib/i386-linux-gnu/libnsl-2.23.so a0522000-a0524000 rw-p 00:00 0 a0524000-a052c000 r-xp 08:01 1048675 /lib/i386-linux-gnu/libnss_compat-2.23.so a052c000-a052d000 r--p 7000 08:01 1048675 /lib/i386-linux-gnu/libnss_compat-2.23.so a052d000-a052e000 rw-p 8000 08:01 1048675 /lib/i386-linux-gnu/libnss_compat-2.23.so a054a000-a054b000 ---p 00:00 0 a054b000-a10cb000 rw-p 00:00 0 a10cb000-a10d4000 r-xp 08:01 150141 /usr/lib/i386-linux-gnu/qt4/plugins/iconengines/libqsvgicon.so a10d4000-a10d5000 r--p 8000 08:01 150141 /usr/lib/i386-linux-gnu/qt4/plugins/iconengines/libqsvgicon.so a10d5000-a10d6000 rw-p 9000 08:01 150141 /usr/lib/i386-linux-gnu/qt4/plugins/iconengines/libqsvgicon.so a10d6000-a1296000 rw-p 00:00 0 a1296000-a12a5000 r-xp 08:01 283552 /usr/lib/python2.7/dist-packages/scipy/stats/mvn.i386-linux-gnu.so a12a5000-a12a6000 ---p f000 08:01 283552 /usr/lib/python2.7/dist-packages/scipy/stats/mvn.i386-linux-gnu.so a12a6000-a12a7000 r--p f000 08:01 283552 /usr/lib/python2.7/dist-packages/scipy/stats/mvn.i386-linux-gnu.so a12a7000-a12a8000 rw-p 0001 08:01 283552 /usr/lib/python2.7/dist-packages/scipy/stats/mvn.i386-linux-gnu.so a12a8000-a139f000 rw-p 00:00 0 a139f000-a13a8000 r-xp 08:01 283553 /usr/lib/python2.7/dist-packages/scipy/stats/statlib.i386-linux-gnu.so a13a8000-a13a9000 ---p 9000 08:01 283553 /usr/lib/python2.7/dist-packages/scipy/stats/statlib.i386-linux-gnu.so a13a9000-a13aa000 r--p 9000 08:01 283553 /usr/lib/python2.7/dist-packages/scipy/stats/statlib.i386-linux-gnu.so a13aa000-a13ab000 rw-p a000 08:01 283553 /usr/lib/python2.7/dist-packages/scipy/stats/statlib.i386-linux-gnu.so a13ab000-a13eb000 rw-p 00:0
Re: geopandas bug ?
Τη Σάββατο, 14 Ιανουαρίου 2017 - 8:09:53 μ.μ. UTC+2, ο χρήστης duncan smith έγραψε: > On 14/01/17 14:59, Xristos Xristoou wrote: > > Τη Σάββατο, 14 Ιανουαρίου 2017 - 4:38:39 μ.μ. UTC+2, ο χρήστης duncan smith > > έγραψε: > >> On 14/01/17 11:18, Xristos Xristoou wrote: > >>> i want to create a simple spatial joing using geopandas but i thing so > >>> geopandas has bug ? > >>> > >>> > >>> > >>> geopandas code : > >>> > >>> from geopandas import gpd > >>> import geopandas > >>> points = geopandas.GeoDataFrame.from_file('points.shp') # or geojson etc > >>> polys = geopandas.GeoDataFrame.from_file('polygons.shp') > >>> pointInPoly = gpd.sjoin(points, polys, how='left',op='within') > >>> > >>> error : > >>> > >>> Traceback (most recent call last): > >>> File "/home/sarantis/testshapely/sumpointsinsidepolygon/testgeo.py", > >>> line 7, in > >>> pointInPoly = gpd.sjoin(points, polys, how='left',op='within') > >>> File "/usr/local/lib/python2.7/dist-packages/geopandas/tools/sjoin.py", > >>> line 57, in sjoin > >>> r_idx = np.concatenate(idxmatch.values) > >>> ValueError: need at least one array to concatenate > >>> > >>> and if i change the imports with the some code : > >>> > >>> import geopandas > >>> import pandas as pd > >>> import geopandas as gpd > >>> from geopandas import GeoDataFrame, read_file > >>> from geopandas.tools import sjoin > >>> from shapely.geometry import Point, mapping,shape > >>> import pandas as gpd > >>> > >>> i take that error : > >>> > >>> pointInPoly = gpd.sjoin(points, polys, how='left',op='within') > >>> AttributeError: 'module' object has no attribute 'sjoin' > >>> > >>> > >>> any idea why ? > >>> > >> > >> > >> import geopandas as gpd > >> import pandas as gpd > >> > >> Does pandas have an attribute 'sjoin'? > >> > >> Duncan > > > > i dont know i follow detais i am newbie > > > > You import geopandas as gpd, then import pandas as gpd. So maybe you > think gpd refers to geopandas while it actually refers to pandas. I > don't know geopandas or pandas, but you should check your imports. > > Duncan @Duncan i see that and i remove line with pandas ans no change -- https://mail.python.org/mailman/listinfo/python-list
Re: geopandas bug ?
Τη Σάββατο, 14 Ιανουαρίου 2017 - 6:33:54 μ.μ. UTC+2, ο χρήστης Peter Otten έγραψε: > Xristos Xristoou wrote: > > >> I suggest that you file a bug report. > > > > Mr.Peter Otten do you see my shapefiles ?have instersection 100 to 100 i > > use instersection on QGIS ad work fine > > Yes, I downloaded the zipfile at > > > https://www.dropbox.com/s/2693nfi248z0y9q/files.zip?dl=0 with the > > and when I ran your code I got the very error that you saw. There are many > NaN values in your data, so if it works elsewhere perhaps the data is > corrupted in some way. I'm sorry I cannot help you any further. > > Good luck! one more question,i have a idea what is wrong,but if my code work how to export spatial join "pointInPoly" to new shapefile ? -- https://mail.python.org/mailman/listinfo/python-list
Re: geopandas bug ?
Τη Σάββατο, 14 Ιανουαρίου 2017 - 6:01:39 μ.μ. UTC+2, ο χρήστης Peter Otten έγραψε: > Xristos Xristoou wrote: > > > Τη Σάββατο, 14 Ιανουαρίου 2017 - 4:30:48 μ.μ. UTC+2, ο χρήστης Peter Otten > > έγραψε: > >> Xristos Xristoou wrote: > >> > >> > Τη Σάββατο, 14 Ιανουαρίου 2017 - 3:43:10 μ.μ. UTC+2, ο χρήστης Peter > >> > Otten έγραψε: > >> >> Xristos Xristoou wrote: > >> >> > >> >> > i want to create a simple spatial joing using geopandas but i thing > >> >> > so geopandas has bug ? > >> >> > >> >> Have you tried the examples on > >> >> <http://geopandas.org/mergingdata.html>? Do they work? If yes, inspect > >> >> your data, does it have the same format? > >> > >> Looks like you chose to ignore the hard part. > >> > >> >> > geopandas code : > >> >> > > >> >> > from geopandas import gpd > >> >> > import geopandas > >> >> > points = geopandas.GeoDataFrame.from_file('points.shp') # or geojson > >> >> > etc polys = geopandas.GeoDataFrame.from_file('polygons.shp') > >> >> > pointInPoly = gpd.sjoin(points, polys, how='left',op='within') > >> >> > > >> >> > error : > >> >> > > >> >> > Traceback (most recent call last): > >> >> > File > >> >> > "/home/sarantis/testshapely/sumpointsinsidepolygon/testgeo.py", > >> >> > line 7, in > >> >> > pointInPoly = gpd.sjoin(points, polys, how='left',op='within') > >> >> > File > >> >> > "/usr/local/lib/python2.7/dist-packages/geopandas/tools/sjoin.py", > >> >> > line 57, in sjoin > >> >> > r_idx = np.concatenate(idxmatch.values) > >> >> > ValueError: need at least one array to concatenate > >> > >> >> > any idea why ? > >> >> > >> >> My crystal ball says that either points or polys is empty ;) > >> > > >> > is not empty and yes i have two shapefiles from qgis. > >> > >> Can I download those files somewhere? > >> > >> > what is the error ? > >> > >> No idea. Without those files I cannot run your code. > > > > https://www.dropbox.com/s/2693nfi248z0y9q/files.zip?dl=0 with the > > shapefiles > > It looks like there are no intersections in your data. > With the proviso that I've learned about the library only today I think you > should get an empty result set rather than the ValueError. > Here's a way to reproduce the error (?) with the data provided in the > project: > > import geopandas > from geopandas import gpd > > world = gpd.read_file(gpd.datasets.get_path('naturalearth_lowres')) > cities = gpd.read_file(gpd.datasets.get_path('naturalearth_cities')) > countries = world[['geometry', 'name']] > > def find(items, name): > # didn't find the idomatic way quickly, so > for index, n in enumerate(items["name"]): > if n == name: > return items[index:index+1] > raise ValueError > > berlin = find(cities, "Berlin") > paris = find(cities, "Paris") > germany = find(countries, "Germany") > > print(gpd.sjoin(berlin, germany)) > print(gpd.sjoin(paris, germany)) # ValueError > > $ python demo.py > geometry name_left index_right \ > 175 POINT (13.39960276470055 52.52376452225116)Berlin 41 > > name_right > 175Germany > > [1 rows x 4 columns] > Traceback (most recent call last): > File "demo.py", line 20, in > print(gpd.sjoin(paris, germany)) # ValueError > File "/home/peter/virt/geopandas/lib/python3.4/site- > packages/geopandas/tools/sjoin.py", line 57, in sjoin > r_idx = np.concatenate(idxmatch.values) > ValueError: need at least one array to concatenate > $ > > I suggest that you file a bug report. Mr.Peter Otten do you see my shapefiles ?have instersection 100 to 100 i use instersection on QGIS ad work fine -- https://mail.python.org/mailman/listinfo/python-list
Re: geopandas bug ?
Τη Σάββατο, 14 Ιανουαρίου 2017 - 4:38:39 μ.μ. UTC+2, ο χρήστης duncan smith έγραψε: > On 14/01/17 11:18, Xristos Xristoou wrote: > > i want to create a simple spatial joing using geopandas but i thing so > > geopandas has bug ? > > > > > > > > geopandas code : > > > > from geopandas import gpd > > import geopandas > > points = geopandas.GeoDataFrame.from_file('points.shp') # or geojson etc > > polys = geopandas.GeoDataFrame.from_file('polygons.shp') > > pointInPoly = gpd.sjoin(points, polys, how='left',op='within') > > > > error : > > > > Traceback (most recent call last): > > File "/home/sarantis/testshapely/sumpointsinsidepolygon/testgeo.py", line > > 7, in > > pointInPoly = gpd.sjoin(points, polys, how='left',op='within') > > File "/usr/local/lib/python2.7/dist-packages/geopandas/tools/sjoin.py", > > line 57, in sjoin > > r_idx = np.concatenate(idxmatch.values) > > ValueError: need at least one array to concatenate > > > > and if i change the imports with the some code : > > > > import geopandas > > import pandas as pd > > import geopandas as gpd > > from geopandas import GeoDataFrame, read_file > > from geopandas.tools import sjoin > > from shapely.geometry import Point, mapping,shape > > import pandas as gpd > > > > i take that error : > > > > pointInPoly = gpd.sjoin(points, polys, how='left',op='within') > > AttributeError: 'module' object has no attribute 'sjoin' > > > > > > any idea why ? > > > > > import geopandas as gpd > import pandas as gpd > > Does pandas have an attribute 'sjoin'? > > Duncan i dont know i follow detais i am newbie -- https://mail.python.org/mailman/listinfo/python-list
Re: geopandas bug ?
Τη Σάββατο, 14 Ιανουαρίου 2017 - 4:30:48 μ.μ. UTC+2, ο χρήστης Peter Otten έγραψε: > Xristos Xristoou wrote: > > > Τη Σάββατο, 14 Ιανουαρίου 2017 - 3:43:10 μ.μ. UTC+2, ο χρήστης Peter Otten > > έγραψε: > >> Xristos Xristoou wrote: > >> > >> > i want to create a simple spatial joing using geopandas but i thing so > >> > geopandas has bug ? > >> > >> Have you tried the examples on <http://geopandas.org/mergingdata.html>? > >> Do they work? If yes, inspect your data, does it have the same format? > > Looks like you chose to ignore the hard part. > > >> > geopandas code : > >> > > >> > from geopandas import gpd > >> > import geopandas > >> > points = geopandas.GeoDataFrame.from_file('points.shp') # or geojson > >> > etc polys = geopandas.GeoDataFrame.from_file('polygons.shp') > >> > pointInPoly = gpd.sjoin(points, polys, how='left',op='within') > >> > > >> > error : > >> > > >> > Traceback (most recent call last): > >> > File "/home/sarantis/testshapely/sumpointsinsidepolygon/testgeo.py", > >> > line 7, in > >> > pointInPoly = gpd.sjoin(points, polys, how='left',op='within') > >> > File > >> > "/usr/local/lib/python2.7/dist-packages/geopandas/tools/sjoin.py", > >> > line 57, in sjoin > >> > r_idx = np.concatenate(idxmatch.values) > >> > ValueError: need at least one array to concatenate > > >> > any idea why ? > >> > >> My crystal ball says that either points or polys is empty ;) > > > > is not empty and yes i have two shapefiles from qgis. > > Can I download those files somewhere? > > > what is the error ? > > No idea. Without those files I cannot run your code. https://www.dropbox.com/s/2693nfi248z0y9q/files.zip?dl=0 with the shapefiles -- https://mail.python.org/mailman/listinfo/python-list
Re: geopandas bug ?
Τη Σάββατο, 14 Ιανουαρίου 2017 - 4:30:48 μ.μ. UTC+2, ο χρήστης Peter Otten έγραψε: > Xristos Xristoou wrote: > > > Τη Σάββατο, 14 Ιανουαρίου 2017 - 3:43:10 μ.μ. UTC+2, ο χρήστης Peter Otten > > έγραψε: > >> Xristos Xristoou wrote: > >> > >> > i want to create a simple spatial joing using geopandas but i thing so > >> > geopandas has bug ? > >> > >> Have you tried the examples on <http://geopandas.org/mergingdata.html>? > >> Do they work? If yes, inspect your data, does it have the same format? > > Looks like you chose to ignore the hard part. > > >> > geopandas code : > >> > > >> > from geopandas import gpd > >> > import geopandas > >> > points = geopandas.GeoDataFrame.from_file('points.shp') # or geojson > >> > etc polys = geopandas.GeoDataFrame.from_file('polygons.shp') > >> > pointInPoly = gpd.sjoin(points, polys, how='left',op='within') > >> > > >> > error : > >> > > >> > Traceback (most recent call last): > >> > File "/home/sarantis/testshapely/sumpointsinsidepolygon/testgeo.py", > >> > line 7, in > >> > pointInPoly = gpd.sjoin(points, polys, how='left',op='within') > >> > File > >> > "/usr/local/lib/python2.7/dist-packages/geopandas/tools/sjoin.py", > >> > line 57, in sjoin > >> > r_idx = np.concatenate(idxmatch.values) > >> > ValueError: need at least one array to concatenate > > >> > any idea why ? > >> > >> My crystal ball says that either points or polys is empty ;) > > > > is not empty and yes i have two shapefiles from qgis. > > Can I download those files somewhere? > > > what is the error ? > > No idea. Without those files I cannot run your code. yes i sent you -- https://mail.python.org/mailman/listinfo/python-list
Re: geopandas bug ?
Τη Σάββατο, 14 Ιανουαρίου 2017 - 3:43:10 μ.μ. UTC+2, ο χρήστης Peter Otten έγραψε: > Xristos Xristoou wrote: > > > i want to create a simple spatial joing using geopandas but i thing so > > geopandas has bug ? > > Have you tried the examples on <http://geopandas.org/mergingdata.html>? > Do they work? If yes, inspect your data, does it have the same format? > > > geopandas code : > > > > from geopandas import gpd > > import geopandas > > points = geopandas.GeoDataFrame.from_file('points.shp') # or geojson etc > > polys = geopandas.GeoDataFrame.from_file('polygons.shp') > > pointInPoly = gpd.sjoin(points, polys, how='left',op='within') > > > > error : > > > > Traceback (most recent call last): > > File "/home/sarantis/testshapely/sumpointsinsidepolygon/testgeo.py", > > line 7, in > > pointInPoly = gpd.sjoin(points, polys, how='left',op='within') > > File "/usr/local/lib/python2.7/dist-packages/geopandas/tools/sjoin.py", > > line 57, in sjoin > > r_idx = np.concatenate(idxmatch.values) > > ValueError: need at least one array to concatenate > > > > and if i change the imports with the some code : > > > > import geopandas > > import pandas as pd > > import geopandas as gpd > > from geopandas import GeoDataFrame, read_file > > from geopandas.tools import sjoin > > from shapely.geometry import Point, mapping,shape > > import pandas as gpd > > > > i take that error : > > > > pointInPoly = gpd.sjoin(points, polys, how='left',op='within') > > AttributeError: 'module' object has no attribute 'sjoin' > > > > > > any idea why ? > > My crystal ball says that either points or polys is empty ;) is not empty and yes i have two shapefiles from qgis.what is the error ? -- https://mail.python.org/mailman/listinfo/python-list
geopandas bug ?
i want to create a simple spatial joing using geopandas but i thing so geopandas has bug ? geopandas code : from geopandas import gpd import geopandas points = geopandas.GeoDataFrame.from_file('points.shp') # or geojson etc polys = geopandas.GeoDataFrame.from_file('polygons.shp') pointInPoly = gpd.sjoin(points, polys, how='left',op='within') error : Traceback (most recent call last): File "/home/username/testshapely/sumpointsinsidepolygon/testgeo.py", line 7, in pointInPoly = gpd.sjoin(points, polys, how='left',op='within') File "/usr/local/lib/python2.7/dist-packages/geopandas/tools/sjoin.py", line 57, in sjoin r_idx = np.concatenate(idxmatch.values) ValueError: need at least one array to concatenate and if i change the imports with the some code : import geopandas import pandas as pd import geopandas as gpd from geopandas import GeoDataFrame, read_file from geopandas.tools import sjoin from shapely.geometry import Point, mapping,shape import pandas as gpd i take that error : pointInPoly = gpd.sjoin(points, polys, how='left',op='within') AttributeError: 'module' object has no attribute 'sjoin' any idea why ? -- https://mail.python.org/mailman/listinfo/python-list
geopandas bug ?
i want to create a simple spatial joing using geopandas but i thing so geopandas has bug ? geopandas code : from geopandas import gpd import geopandas points = geopandas.GeoDataFrame.from_file('points.shp') # or geojson etc polys = geopandas.GeoDataFrame.from_file('polygons.shp') pointInPoly = gpd.sjoin(points, polys, how='left',op='within') error : Traceback (most recent call last): File "/home/sarantis/testshapely/sumpointsinsidepolygon/testgeo.py", line 7, in pointInPoly = gpd.sjoin(points, polys, how='left',op='within') File "/usr/local/lib/python2.7/dist-packages/geopandas/tools/sjoin.py", line 57, in sjoin r_idx = np.concatenate(idxmatch.values) ValueError: need at least one array to concatenate and if i change the imports with the some code : import geopandas import pandas as pd import geopandas as gpd from geopandas import GeoDataFrame, read_file from geopandas.tools import sjoin from shapely.geometry import Point, mapping,shape import pandas as gpd i take that error : pointInPoly = gpd.sjoin(points, polys, how='left',op='within') AttributeError: 'module' object has no attribute 'sjoin' any idea why ? -- https://mail.python.org/mailman/listinfo/python-list
topology rules in python
I have a PostGIS database with shapefiles lines, polygons and points and I want to create a topology rules with python. Any idea how to do that ?some packages ? I like some easy way to do that because I am newbie but its OK. Some topology rules when I want. shapefile must not have gaps shapefile must not have overlaps shapefile must not overlap with shapefile2 invalid geometries -- https://mail.python.org/mailman/listinfo/python-list
Re: SIP install error on windows
Τη Δευτέρα, 12 Δεκεμβρίου 2016 - 9:29:38 μ.μ. UTC+2, ο χρήστης Xristos Xristoou έγραψε: > hello i want to install sip on windows bit using python > 32 bit. > i download sip from this link https://www.riverbankcomputing.com > i try to install from cmd line : > > C:\WINDOWS\system32>cd C:\Users\username\Desktop\sip-4.17 > > C:\Users\username\Desktop\sip-4.17>python configure.py install > and take that error any idea ? > > This is SIP 4.17 for Python 2.7.11 on win32. > Error: Unsupported macro name specified. Use the --show-build-macros flag to > see a list of supported macros. yes but i dont have python 3 i need use python 2.7 -- https://mail.python.org/mailman/listinfo/python-list
SIP install error on windows
hello i want to install sip on windows bit using python 32 bit. i download sip from this link https://www.riverbankcomputing.com i try to install from cmd line : C:\WINDOWS\system32>cd C:\Users\username\Desktop\sip-4.17 C:\Users\username\Desktop\sip-4.17>python configure.py install and take that error any idea ? This is SIP 4.17 for Python 2.7.11 on win32. Error: Unsupported macro name specified. Use the --show-build-macros flag to see a list of supported macros. -- https://mail.python.org/mailman/listinfo/python-list
Re: Couldn't load SIP module.
Τη Σάββατο, 19 Νοεμβρίου 2016 - 10:45:16 μ.μ. UTC+2, ο χρήστης Xristos Xristoou έγραψε: > hello > i using python 2.7.12 on ubuntu 16.04 and i have that error with SIP : > > Couldn't load SIP module. > > > Traceback (most recent call last): > File "", line 1, in > ImportError: /usr/local/lib/python2.7/site-packages/sip.so: undefined symbol: > PyUnicodeUCS2_AsUTF8String > > ('Qt version:', '4.8.7') > ('SIP version:', '4.17') > ('PyQt version:', '4.11.4') > > any idea how to fix that ? how to delete complete python with all packages on ubuntu ? -- https://mail.python.org/mailman/listinfo/python-list
Couldn't load SIP module.
hello i using python 2.7.12 on ubuntu 16.04 and i have that error with SIP : Couldn't load SIP module. Traceback (most recent call last): File "", line 1, in ImportError: /usr/local/lib/python2.7/site-packages/sip.so: undefined symbol: PyUnicodeUCS2_AsUTF8String ('Qt version:', '4.8.7') ('SIP version:', '4.17') ('PyQt version:', '4.11.4') any idea how to fix that ? -- https://mail.python.org/mailman/listinfo/python-list
Raster top and lowe x,y how ca i get
How can i get left lower X,Y left top X,Y right lower X,Y and right Top X,Y from a raster image like dem(digital elevation model). I am nembie sorry if i have stupid quest -- https://mail.python.org/mailman/listinfo/python-list
Re: define variables in the txt file using python
Τη Σάββατο, 8 Οκτωβρίου 2016 - 12:25:28 π.μ. UTC+3, ο χρήστης Xristos Xristoou έγραψε: > hello > > > i have one .txt file and i want to create python script with sys.argv or > argparse or other package to define some variables in the txt file and i take > some result. > > > > txt file maybe like this : > > input number 1= %var1% > input number 2= %var2% > result = %vresult(var1-var2)% > > how can i write a python script to update dynamic variables in the txt file ? > i dont want with replace i thing so arguments is the better. thanks Mr.Peter your code look nice,i have one question,must be running from cmd line ?i cant to run your code in the python script ? -- https://mail.python.org/mailman/listinfo/python-list
define variables in the txt file using python
hello i have one .txt file and i want to create python script with sys.argv or argparse or other package to define some variables in the txt file and i take some result. txt file maybe like this : input number 1= %var1% input number 2= %var2% result = %vresult(var1-var2)% how can i write a python script to update dynamic variables in the txt file ? i dont want with replace i thing so arguments is the better. -- https://mail.python.org/mailman/listinfo/python-list
python and dos files question
hello some programs allow to export tools to dos .bat files for running from command line. my question is how can i do to running .bat files and how can i do to define some variables from the .bat file before the running. for example i want to define 4 variable and run this .bat file with the python variables can be strings paths,images and text. .bat file like this : @ECHO OFF REM SET program1=C:\program1\Modules REM SET PATH=%PATH%;C:\program1 REM Tool: Tool1 program1_cmd tool1 0 -variable1=NULL -variable2=NULL -variable3=NULL -variable4=NULL - PAUSE -- https://mail.python.org/mailman/listinfo/python-list
scipy tutorial question
hello i want to follow this scipy tutorial http://www2.geog.ucl.ac.uk/~plewis/geogg122-2011-12/dem2.html to calculate slope/aspect and more. first question,this is a good way to calculate slope/aspect with scipy ? can i find more easy way for this calculate ? second question and most important,how can i use mine DEM (raster image) inside the tutorial code to calculate slope/aspect from mine DEM (raster image)? and how to export that calculation to new tiff images ? i thing so easy but i am very new. i have and gdal package in my python the tutorial code : import numpy as np def gaussianFilter(sizex,sizey=None,scale=0.333): ''' Generate and return a 2D Gaussian function of dimensions (sizex,sizey) If sizey is not set, it defaults to sizex A scale can be defined to widen the function (default = 0.333) ''' sizey = sizey or sizex x, y = np.mgrid[-sizex:sizex+1, -sizey:sizey+1] g = np.exp(-scale*(x**2/float(sizex)+y**2/float(sizey))) return g/g.sum() def randomDEM(nx,sizex,max,min,sizey=None,ny=None): ''' Generate a pseudo-DEM from random correlated noise. Parameters: nx : number of pixels of the output sizex : number of pixels of the smoothing filter max : max height in DEM min : min height in DEM Options: sizey : defaults to sizex ny : defaults to nx ''' from scipy import signal ny = ny or nx sizey = sizey or sizex dem1 = np.random.rand(nx+2*sizex,ny+2*sizey) demSmooth = signal.convolve(dem1,gaussianFilter(sizex,sizey),mode='valid') demSmooth = (demSmooth - demSmooth.min())/(demSmooth.max() - demSmooth.min()) demSmooth = demSmooth*(max-min)+min return demSmooth def plot(array,file=None): ''' Produce a plot of the 2D array Options: file: specify an output file ''' import matplotlib.pylab as plt plt.imshow(array,interpolation='nearest') if file == None: plt.show() else: plt.savefile(file) smoothDEM = randomDEM(300,20,100.,0.,sizey=5) #plot(smoothDEM) def padding(dem,size=1): ''' Apply a border of size to a spatial dataset Return the padded data with the original centred in the array ''' out = np.zeros([dem.shape[0]+2*size,dem.shape[1]+2*size]) out[:,:] = np.max(dem)+1 out[size:-size,size:-size] = dem return out padDEM = padding(smoothDEM) #plot(padDEM) def localMin(dem): ''' We wish to return the location of the minimum grid value in a neighbourhood. We assume the array is 2D and defined (y,x) We return wx,wy which are the cell displacements in x and y directions. ''' wy = np.zeros_like(dem).astype(int) wx = np.zeros_like(dem).astype(int) winx = np.ones([3,3]) for i in xrange(3): winx[:,i] = i - 1 winy = winx.transpose() demp = padding(dem,size=1) for y in np.arange(1,demp.shape[0]-1): for x in np.arange(1,demp.shape[1]-1): win = demp[y-1:y+2,x-1:x+2] ww = np.where(win == np.min(win)) whereX = winx[ww][0] whereY = winy[ww][0] wy[y-1,x-1] = whereY wx[y-1,x-1] = whereX return wx,wy (wx,wy) = localMin(smoothDEM) #plot(wx) def grad2d(dem): ''' Calculate the slope and gradient of a DEM ''' from scipy import signal f0 = gaussianFilter(3) I = signal.convolve(dem,f0,mode='valid') f1 = np.array([[-1,0,1],[-2,0,2],[-1,0,1]]) f2 = f1.transpose() g1 = signal.convolve(I,f1,mode='valid') g2 = signal.convolve(I,f2,mode='valid') slope = np.sqrt(g1**2 + g2**2) aspect = np.arctan2(g2,g1) return slope, aspect slope, aspect = grad2d(smoothDEM) plot(slope) plot(aspect) -- https://mail.python.org/mailman/listinfo/python-list
Re: RASTER analysis(slope)
Τη Σάββατο, 1 Οκτωβρίου 2016 - 8:52:13 μ.μ. UTC+3, ο χρήστης Xristos Xristoou έγραψε: > hello team > > i want to calculate slope and aspect from some RASTER > IMAGE(.grid,tiff,geotiff) > who is the better method to can i do this ? > with numpy and scipy or with some package? > > > thnx you team pydem like easy but have errors like this : from pydem.dem_processing import DEMProcessor filename_to_elevation_geotiff = 'dem.tif' dem_proc = DEMProcessor(filename_to_elevation_geotiff) mag, aspect = dem_proc.calc_slopes_directions() error message : Warning (from warnings module): File "C:\Python27\lib\site-packages\pydem-0.1.1-py2.7-win32.egg\pydem\dem_processing.py", line 563 self.data[data.mask] = FILL_VALUE MaskedArrayFutureWarning: setting an item on a masked array which has a shared mask will not copy the mask and also change the original mask array in the future. Check the NumPy 1.11 release notes for more information. starting slope/direction calculation for chunk 1 [0:516, 0:516] Traceback (most recent call last): File "C:/Python27/test/test/slop.py", line 4, in mag, aspect = dem_proc.calc_slopes_directions() File "C:\Python27\lib\site-packages\pydem-0.1.1-py2.7-win32.egg\pydem\dem_processing.py", line 853, in calc_slopes_directions self.dY[te:be-1]) File "C:\Python27\lib\site-packages\pydem-0.1.1-py2.7-win32.egg\pydem\dem_processing.py", line 879, in _slopes_directions return self._tarboton_slopes_directions(data, dX, dY) File "C:\Python27\lib\site-packages\pydem-0.1.1-py2.7-win32.egg\pydem\dem_processing.py", line 890, in _tarboton_slopes_directions self.facets, self.ang_adj) File "C:\Python27\lib\site-packages\numba\dispatcher.py", line 285, in _compile_for_args return self.compile(tuple(argtypes)) File "C:\Python27\lib\site-packages\numba\dispatcher.py", line 531, in compile cres = self._compiler.compile(args, return_type) File "C:\Python27\lib\site-packages\numba\dispatcher.py", line 80, in compile flags=flags, locals=self.locals) File "C:\Python27\lib\site-packages\numba\compiler.py", line 725, in compile_extra return pipeline.compile_extra(func) File "C:\Python27\lib\site-packages\numba\compiler.py", line 369, in compile_extra return self.compile_bytecode(bc, func_attr=self.func_attr) File "C:\Python27\lib\site-packages\numba\compiler.py", line 378, in compile_bytecode return self._compile_bytecode() File "C:\Python27\lib\site-packages\numba\compiler.py", line 690, in _compile_bytecode return self._compile_core() File "C:\Python27\lib\site-packages\numba\compiler.py", line 677, in _compile_core res = pm.run(self.status) File "C:\Python27\lib\site-packages\numba\compiler.py", line 257, in run raise patched_exception LoweringError: Caused By: Traceback (most recent call last): File "C:\Python27\lib\site-packages\numba\compiler.py", line 249, in run stage() File "C:\Python27\lib\site-packages\numba\compiler.py", line 455, in stage_objectmode_frontend cres = self.frontend_looplift() File "C:\Python27\lib\site-packages\numba\compiler.py", line 446, in frontend_looplift func_attr=self.func_attr) File "C:\Python27\lib\site-packages\numba\compiler.py", line 743, in compile_ir return pipeline.compile_ir(interp=interp, lifted=lifted, lifted_from=lifted_from, func_attr=func_attr) File "C:\Python27\lib\site-packages\numba\compiler.py", line 389, in compile_ir return self._compile_ir() File "C:\Python27\lib\site-packages\numba\compiler.py", line 697, in _compile_ir return self._compile_core() File "C:\Python27\lib\site-packages\numba\compiler.py", line 677, in _compile_core res = pm.run(self.status) File "C:\Python27\lib\site-packages\numba\compiler.py", line 257, in run raise patched_exception LoweringError: Caused By: Traceback (most recent call last): File "C:\Python27\lib\site-packages\numba\compiler.py", line 249, in run stage() File "C:\Python27\lib\site-packages\numba\compiler.py", line 595, in stage_objectmode_backend self._backend(lowerfn, objectmode=True) File "C:\Python27\lib\site-packages\numba\compiler.py", line 572, in _backend lowered = lowerfn() File "C:\Python27\lib\site-packages\numba\compiler.py", line 546, in backend_object_mode self.flags) File "C:\Python27\lib\site-packages\numba\compiler.py", line 869, in py_lowering_stage lower.lower() File "C:\Python27\lib\site-packages\numba\lowering.py", line 125, in lower self.lower_normal_function(self.fndesc) File "C:\Python27\lib\site-packages\numba\lowering.py", line 160, in lower_normal_function entry_blo
RASTER analysis(slope)
hello team i want to calculate slope and aspect from some RASTER IMAGE(.grid,tiff,geotiff) who is the better method to can i do this ? with numpy and scipy or with some package? thnx you team -- https://mail.python.org/mailman/listinfo/python-list
batch files and path in python (subprocess | sys)
hello i use some programs where support python api. but to can use that api from programs need to define some paths(pythonpath program and more) and call some batch files(if i not do that i cant access api support).create an .bat file where if i run i can use api. mybatch.bat set ROOT=C:\path\path call “%ROOT%“\path1\path1.bat call “%ROOT%“\path2\path2\path2\path2\path2.bat set GDPATH=%ROOT%\path3\path3 path %PATH%;”%ROOT%\path4\path4\path4\” set PYTHONPATH=%PYTHONPATH%;%ROOT%\path4\path4\path4; set PYTHONPATH=%PYTHONPATH%;%ROOT%\path5\path5\path5\path5 set SPATH=%ROOT%\path6 start “name ide” /B “path from idle.exe” but i can use api only from this file i dont want that i want to create a script where to run or call batch file with the |subprocess | and run on background(activate). and i need define path with the |sys|,sys.path.extend,sys.path.append i am not sure who is right. i need a mybatch.bat to convert to python script to take easy api -- https://mail.python.org/mailman/listinfo/python-list
.bat files and path in python(subprocess | sys)
hello i use some programs where support python api. but to can use that api from programs need to define some paths(pythonpath program and more) and call some batch files(if i not do that i cant access api support).create an .bat file where if i run i can use api. mybatch.bat set ROOT=C:\path\path call “%ROOT%“\path1\path1.bat call “%ROOT%“\path2\path2\path2\etc\path2.bat set GDPATH=%OSGEO4W_ROOT%\path3\path3 path %PATH%;”%OSGEO4W_ROOT%\path\Python27\Scripts\” set PYTHONPATH=%PYTHONPATH%;%ROOT%\path4\path4\python; set PYTHONPATH=%PYTHONPATH%;%ROOT%\path5\Python27\Lib\site-packages set SPATH=%ROOT%\path6 start “name ide” /B “path from idle.exe” but i can use api only from this file i dont want that i want to create a script where to run or call batch file with the |subprocess | and run on background(activate). and i need define path with the |sys|,sys.path.extend,sys.path.append i am not sure who is right. -- https://mail.python.org/mailman/listinfo/python-list
python for complte program ?
hello i want to ask if a python is a good for to do it a complete program(.exe)? with user interface,module interface,background scripts where compile if the users calls some scripts,windows with interaction with the users? how can i do that with the python? how can libs need for this ? some tutorial for complete programs ? -- https://mail.python.org/mailman/listinfo/python-list
errors with QGIS API USING PYTHON
i want to use python API from the QGIS in my python idle out from QGIS program , but i have some errors if i try to import qgis.core in my idle. i have python 2.7 64 bit (my version) and i install QGIS via OSGeo4W64. first i try to set two PATHS PYTHONPATH = C:\OSGeo4W64\apps\qgis\pythonPYTHONPATH(because there is the python python) and set PATH=C:\OSGeo4W64\apps\qgis\binPATH(because there is the python modules modules).now if i try to import qgis.core then show me error message no module name siperror in idle after this error i try to import paths inside the idle via sys.path.extend import sys sys.path.extend([r"C:\OSGeo4W64\apps\qgis\python", r"C:\OSGeo4W64\apps\qgis\bin", r"C:\OSGeo4W64\bin", r"C:\OSGeo4W64\apps\qgis\bin", r"C:\OSGeo4W64\apps\qgis\python", r"C:\OSGeo4W64\apps\Python27", r"C:\OSGeo4W64\apps\Python27\Scripts", r"C:\OSGeo4W64\apps\Python27\sip", r"C:\OSGeo4W64\apps\Python27\sip\Qt", r"C:\OSGeo4W64\apps\Python27\sip\QtCore", r"C:\OSGeo4W64\apps\Python27\sip\Qwt5", r"C:\OSGeo4W64\apps\Python27\sip\QtScriptTools", r"C:\OSGeo4W64\apps\Python27\DLLs", r"C:\OSGeo4W64\apps\Python27\Lib", r"C:\OSGeo4W64\apps\Python27\Lib\site-packages", r"C:\OSGeo4W64\apps\Python27\Tools\Scripts", r"C:\OSGeo4W64\apps\qgis\plugins", r"C:\OSGeo4W64\apps\qgis\python\qsci_apis", r"C:\OSGeo4W64\apps\qgis\python\qgis", r"C:\OSGeo4W64\apps\qgis\python\qgis\core", r"C:\OSGeo4W64\apps\qgis\python\qgis\analysis", r"C:\OSGeo4W64\apps\qgis\python\PyQt", r"C:\OSGeo4W64\apps\qgis\python\PyQt4", r"C:\OSGeo4W64\apps\qgis\python\PyQt4\uic\widget-plugins", r"C:\OSGeo4W64\apps\qgis\bin", r"C:\Python27", r"C:\Python27\Scripts", r"C:\OSGeo4W64\apps\qgis\python"]) i use more paths for sure but now show me DLL error load failed error 2 finaly i try other method from this bat file(question). my bat file. set PYTHONPATH=C:\OSGeo4W64\apps\qgis\python set PATH=C:\OSGeo4W64\apps\qgis\bin;C:\OSGeo4W64\bin;C:\OSGeo4W64\apps\qgis\bin;C:\OSGeo4W64\apps\qgis\python;C:\OSGeo4W64\apps\Python27;C:\OSGeo4W64\apps\Python27\Scripts;C:\OSGeo4W64\apps\Python27\sip;C:\OSGeo4W64\apps\Python27\sip\Qt;C:\OSGeo4W64\apps\Python27\sip\QtCore;C:\OSGeo4W64\apps\Python27\sip\Qwt5;C:\OSGeo4W64\apps\Python27\sip\QtScriptTools;C:\OSGeo4W64\apps\Python27\DLLs;C:\OSGeo4W64\apps\Python27\Lib;C:\OSGeo4W64\apps\Python27\Lib\site-packages;C:\OSGeo4W64\apps\Python27\Tools\Scripts;C:\OSGeo4W64\apps\qgis\plugins;C:\OSGeo4W64\apps\qgis\python\qsci_apis;C:\OSGeo4W64\apps\qgis\python\qgis;C:\OSGeo4W64\apps\qgis\python\qgis\core;C:\OSGeo4W64\apps\qgis\python\qgis\analysis;C:\OSGeo4W64\apps\qgis\python\PyQt;C:\OSGeo4W64\apps\qgis\python\PyQt4;C:\OSGeo4W64\apps\qgis\python\PyQt4\uic\widget-plugins;C:\OSGeo4W64\apps\qgis\bin;C:\Python27\;C:\Python27\Scripts if i run this bat file in the OSGeo4w shell work but only in the shell shell image. but not work again in my idle again show me error no module name SIPerror sip why?any idea how to fix that? the problem is the paths sure but i dont know how to fix that.err -- https://mail.python.org/mailman/listinfo/python-list
Re: Python packages for hydrology and DEM
Τη Τρίτη, 19 Απριλίου 2016 - 9:19:33 π.μ. UTC+3, ο χρήστης Xristos Xristoou έγραψε: > I want to ask for hydrology python packages with complete function to > calculate hydrology tasks like fill,flow direction,flow accumulator and > more?or how can i find genetic algorithms for to do this tasks to finaly > create a complete hydro model with python. > > can someone tell me some documentation to do that with python ? i want to > find like this TopoToolbox from matlab in python using > > also i want to ask and for python psckage for digital elevation models > calcultor like idw krigging spline and more...or some documentation for this > or some genetic algorithm for this > > ty. all this packages is old and without or low support-documentecion -- https://mail.python.org/mailman/listinfo/python-list
Python packages for hydrology and DEM
I want to ask for hydrology python packages with complete function to calculate hydrology tasks like fill,flow direction,flow accumulator and more?or how can i find genetic algorithms for to do this tasks to finaly create a complete hydro model with python. can someone tell me some documentation to do that with python ? i want to find like this TopoToolbox from matlab in python using also i want to ask and for python psckage for digital elevation models calcultor like idw krigging spline and more...or some documentation for this or some genetic algorithm for this ty. -- https://mail.python.org/mailman/listinfo/python-list
Re: scipy install error,need help its important
Τη Δευτέρα, 18 Απριλίου 2016 - 6:53:30 π.μ. UTC+3, ο χρήστης Xristos Xristoou έγραψε: > guys i have big proplem i want to install scipy > but all time show me error > i have python 2.7 and windows 10 > i try to use pip install scipy and i take that error > > raise NotFoundError('no lapack/blas resources found') > numpy.distutils.system_info.NotFoundError: no lapack/blas resources found > > > Command "C:\Python27\python.exe -u -c "import setuptools, > tokenize;__file__='c:\\users\\name\\appdata\\local\\temp\\pip-build-a3fjaf\\scipy\\setup.py';exec(compile(getattr(tokenize, > 'open', open)(__file__).read().replace('\r\n', '\n'), __file__, 'exec'))" > install --record > c:\users\name\appdata\local\temp\pip-pgtkuz-record\install-record.txt > --single-version-externally-managed --compile" failed with error code 1 in > c:\users\name\appdata\local\temp\pip-build-a3fjaf\scipy\ yes i have idle python 2.7 before,must delete first before install anaconda ?how can anaconda packages to run with old idle ?because i have to many packages in old python. -- https://mail.python.org/mailman/listinfo/python-list
Re: scipy install error,need help its important
Τη Δευτέρα, 18 Απριλίου 2016 - 6:53:30 π.μ. UTC+3, ο χρήστης Xristos Xristoou έγραψε: > guys i have big proplem i want to install scipy > but all time show me error > i have python 2.7 and windows 10 > i try to use pip install scipy and i take that error > > raise NotFoundError('no lapack/blas resources found') > numpy.distutils.system_info.NotFoundError: no lapack/blas resources found > > > Command "C:\Python27\python.exe -u -c "import setuptools, > tokenize;__file__='c:\\users\\name\\appdata\\local\\temp\\pip-build-a3fjaf\\scipy\\setup.py';exec(compile(getattr(tokenize, > 'open', open)(__file__).read().replace('\r\n', '\n'), __file__, 'exec'))" > install --record > c:\users\name\appdata\local\temp\pip-pgtkuz-record\install-record.txt > --single-version-externally-managed --compile" failed with error code 1 in > c:\users\name\appdata\local\temp\pip-build-a3fjaf\scipy\ i fllow you with anaconda route and i install scipy without error but in the idle i write import scipy and show me erroe msg no module name scipy,why ? -- https://mail.python.org/mailman/listinfo/python-list
Re: scipy install error,need help its important
Τη Δευτέρα, 18 Απριλίου 2016 - 6:53:30 π.μ. UTC+3, ο χρήστης Xristos Xristoou έγραψε: after google search to many post propose install lapack and atla bt=ut i dont know > guys i have big proplem i want to install scipy > but all time show me error > i have python 2.7 and windows 10 > i try to use pip install scipy and i take that error > > raise NotFoundError('no lapack/blas resources found') > numpy.distutils.system_info.NotFoundError: no lapack/blas resources found > > > Command "C:\Python27\python.exe -u -c "import setuptools, > tokenize;__file__='c:\\users\\name\\appdata\\local\\temp\\pip-build-a3fjaf\\scipy\\setup.py';exec(compile(getattr(tokenize, > 'open', open)(__file__).read().replace('\r\n', '\n'), __file__, 'exec'))" > install --record > c:\users\name\appdata\local\temp\pip-pgtkuz-record\install-record.txt > --single-version-externally-managed --compile" failed with error code 1 in > c:\users\name\appdata\local\temp\pip-build-a3fjaf\scipy\ -- https://mail.python.org/mailman/listinfo/python-list
scipy install error,need help its important
guys i have big proplem i want to install scipy but all time show me error i have python 2.7 and windows 10 i try to use pip install scipy and i take that error raise NotFoundError('no lapack/blas resources found') numpy.distutils.system_info.NotFoundError: no lapack/blas resources found Command "C:\Python27\python.exe -u -c "import setuptools, tokenize;__file__='c:\\users\\name\\appdata\\local\\temp\\pip-build-a3fjaf\\scipy\\setup.py';exec(compile(getattr(tokenize, 'open', open)(__file__).read().replace('\r\n', '\n'), __file__, 'exec'))" install --record c:\users\name\appdata\local\temp\pip-pgtkuz-record\install-record.txt --single-version-externally-managed --compile" failed with error code 1 in c:\users\name\appdata\local\temp\pip-build-a3fjaf\scipy\ -- https://mail.python.org/mailman/listinfo/python-list
import opencv error (DLL load failed)
hi i have windows 10 and python 3.5.1 and i want to install open cv. first i go to http://www.lfd.uci.edu/~gohlke/pythonlibs/#opencv and download the opencv_python-3.1.0-cp35-none-win_amd64.whl from command prompt i install with pip. pip install \opencv_python-3.1.0-cp35-none-win_amd64.whl and show me successfuly installed opencv-python-3.1.0. i look the files in the site-packages and now i have opencv files cv.py cv2.cp35-win_amd64.pyd and more opencv.dll files after successfuly installed open python idle i a try to import cv2 and i take that error massege .. error massege import cv2 Traceback (most recent call last): File "", line 1, in import cv2 ImportError: DLL load failed : after this error downloaded opencv 3.0 and extracted it.copying cv2.pyd to the site-packages folder and show me again this error massege . can you tell why?and how to FIX THAT ? -- https://mail.python.org/mailman/listinfo/python-list
testing python program,project and django site
hello, i am python user and i have some projects,programs and sites with django in python. i want one more step deeper,i want to test my programs for bugs,weaknesses,vulnerability,security or penetration test,on my sites for crashes(because use python apps).because the user i am now on the feature maybe i have thousand users to work with my programs. can you tell me how to find this?some propram to do that or some for that ? some method to do that? some program to testing the programs? thnX you -- https://mail.python.org/mailman/listinfo/python-list
Re: install open cv on windows 10 and python 3.5
Τη Παρασκευή, 1 Απριλίου 2016 - 1:56:52 μ.μ. UTC+3, ο χρήστης Xristos Xristoou έγραψε: > hello, > > i have windows 10 and python 3.5 and i want to use > open cv but i think so opencv work only on python 2.7 ? > and i install this http://www.lfd.uci.edu/~gohlke/pythonlibs/#opencv > but not work again yes i cant import cv2 on my idle that is my problem -- https://mail.python.org/mailman/listinfo/python-list
Re: install open cv on windows 10 and python 3.5
Τη Παρασκευή, 1 Απριλίου 2016 - 1:56:52 μ.μ. UTC+3, ο χρήστης Xristos Xristoou έγραψε: > hello, > > i have windows 10 and python 3.5 and i want to use > open cv but i think so opencv work only on python 2.7 ? > and i install this http://www.lfd.uci.edu/~gohlke/pythonlibs/#opencv > but not work again in my site-packages i have : opencv_python-3.1.0.dist-info cv2.cp35-win32.pyd cv2.pyd cv and more opencv.dlls yes i have and python2.7 for other version in pip install succefully -- https://mail.python.org/mailman/listinfo/python-list