Closed xxqhh closed 4 years ago
Not sure what you mean, could you be more precise with your question?
like this problem:https://github.com/geodesign/django-raster/issues/30 I have try this, But i can't visual display
Its hard to guess what could be going wrong. Did you successfully parse a raster? Where RasterTile objects created?
I find i can't create rasterfile, [2019-09-10 17:49:05,438: ERROR/MainProcess] Task raster.tasks.create_tiles[c43eb70b-ef66-434b-a575-2d2583c3d0d1] raised unexpected: PermissionError(13, 'Another program is using this file and the process cannot access it.') I don't know how to solve it.
This could be related to the media storage settings. When you create a new RasterLayer, you probably uploaded a raster file. Maybe your django application does not have read access to the raster that you uploaded? https://docs.djangoproject.com/en/2.2/ref/settings/#std:setting-MEDIA_ROOT
Sorry, I don't know how to set it up.
MEDIA_URL = "/media/" MEDIA_ROOT = os.path.join(BASE_DIR, 'media')
The MEDIA_ROOT is where your uploaded raster will be stored. So the web application needs write permissions for that folder. Depending on how you run your Django, that might not be in the BASE_DIR. Generally, its not a good idea to put it in BASE_DIR. You want it to be a permanent location. So create a folder somewhere for it, in development it could be something like (~/Documents/my_django_app_media_files/). Make sure that your django app has read and write permissions on that folder. In production, you will need to ensure that the media file location is a stable permanent location, otherwise you loose the files when your django server reboots.
Raster layer metadatas, Raster layers can create, but Raster tiles can't,I changed the location of the storage, but it didn't work.
Well, your error indicates that it is a file access permission issue. Are you using celery? Could you share the traceback of your error?
yes
This indicates that the tiles are actually being created, but that the last cleanup step there is a problem with permissions of the temporary directory that the parser creates. So the error arises after the raster is parsed successfully, the rmdir is a cleanup step.
Could you confirm that the RasterTiles are created (have a look at the raster/rasteritile admin and see if there are objects).
Its hard for me to understand why the create_tiles can not remove this temporary directory. It might have to do with windows or with the user permissions on your celery instance.
I create RasterTiles, But it has no object.
The two errors you shared are not the same! One fails on line 50 the other on line 40. Make sure your celery worker has read and write access in the D:\\data\\
directory. The problem you have does not seem to be a django-raster bug but rather a setup configuration problem with permissions.
Can you help me look at the code?This is my first time using celery.I don't what i should do
It looks like you are using anaconda. That means that your django and celery apps are running through this environment. I am not familiar with anaconda, but you might be able to select a MEDIA_ROOT that is within anaconda's permissions? Your problems might be related to that.
dest_zip = zipfile.ZipFile(dest.name, 'w', allowZip64=True)
I think there's a problem here, but I don't know how to fix it.
import zipfile dest_zip = zipfile.ZipFile(r'C:\Users\Lenovo\AppData\Local\Temp\tmpso_qiewj\tmpwvnred35.zip', 'w', allowZip64=True) error import zipfile
dest_zip = zipfile.ZipFile(r'D:\rsgis.zip', 'w', allowZip64=True) ok i don't know why
One is on disk C:\
and another one is on disk D:\
, it looks like the tempfiles are placed in another folder that might not be accessible by celery or django.
I seem to have found the problem. It's related to the system I use. tempfile.NamedTemporaryFile([mode='w+b'[, bufsize=-1[, suffix=''[, prefix='tmp'[, dir=None[, delete=True]]]]]]) This function operates exactly as TemporaryFile() does, except that the file is guaranteed to have a visible name in the file system (on Unix, the directory entry is not unlinked). That name can be retrieved from the name attribute of the returned file-like object. Whether the name can be used to open the file a second time, while the named temporary file is still open, varies across platforms (it can be so used on Unix; it cannot on Windows NT or later). If delete is true (the default), the file is deleted as soon as it is closed. The returned object is always a file-like object whose file attribute is the underlying true file object. This file-like object can be used in a with statement, just like a normal file. New in version 2.3. New in version 2.6: The delete parameter. https://docs.python.org/2/library/tempfile.html
Hi,I have new problem,I don't know how to solve,hope you can reply me.Thank you
Based on your feedback I made some improvements in file handling, see https://github.com/geodesign/django-raster/commit/1dcc3e19499b18a5de95e247e22a8677a7088d75. Could you check if your problems persist if you install the current master branch?
Yes, it solved my previous problems.but it have new problem.And then what system did you use to write this project? Thank you.
This looks like a very related issue. The warping of a raster fails probably because the underlying tempfile is not allowing it to open again. I made another update here https://github.com/geodesign/django-raster/commit/3f5dd55fa1f0abc9e909abd92fc3ffea47613bc6. Could you check if that solves your second problem?
https://github.com/geodesign/django-raster/commit/1dcc3e19499b18a5de95e247e22a8677a7088d75 It doesn't seem to solve the problem.
There seems to be some problem. if i use os.remove(dest_file_name),it will error
What is the traceback?
I know how to modify it, but i think it not well
'destructor = capi.close_ds' can't run.
If I do this, temporary files cannot be deleted.
I don't understand how you can have a permissions error in that case. Does the file not exist anymore?
@xxqhh Is this solved?
There are still some problems, but I don't know what went wrong.
Like this
PermissionError: [Errno 13] Another program is using this file and the process cannot access it.: 'D:/datatest\tmp47rya8d7\ndvi.tiff_copy.GTiff'
I don't know if it's because of this problem.I can't parse the second band.
Your questions are very specific to your set up. Its hard to help you like this. Hope you figured out a solution!
Hi I want to use WMS.But i don't how to import them.Can you give me some example?Thank you.