FieldStudiesCouncil / QGIS-Biological-Recording-Tools

QGIS plugin for biological recorders. Created with the FSC Tomorrow's Biodiversity project.
GNU General Public License v3.0
10 stars 4 forks source link

Can't make Temp Grid layer permanent #56

Closed gideonsway closed 2 years ago

gideonsway commented 3 years ago

I can't believe this is new but nor can I find via Google etc answer. I am a novice so please be patient. I have greated Grid Layer using Tom-Bio on UK Nat Grid. But when I go to try to save by Make pernamanent or save as work I get: Save Error and following: Screen Shot 2021-07-05 at 17 00 36 If I am doing something stupid then apologies.

burkmarr commented 3 years ago

Hi @gideonsway - I can't reproduce the problem. Can you give some step by step bullets indicating which options you chose (e.g. file format). Also what version of QGIS?

gideonsway commented 3 years ago

Rich, In answer to some of your questions - and I think must be something in my set up that is causing the issue.

I am using Odense 3.2 - latest stable version on a Mac. I am using National grid 27700 CRS. In order to try to see if it was just the particular project I opened a new and just loaded Bing Ariel and OS Parish Shp file as 2 layers.

I selected the polygon/feature of Brighton and then generated the 1km by using the yellow grid icon on TomBio toolbar. Then I have both tried to “make permanent” and also tried to use the “Export” and save as. Both failed.

I then did the same but tried and generated the 10km grid and again failed.

As you can see from the screen shots It seems to be something to do with the string exceeding the 20 maximum field length. I am not aware that I have set any min of max field length.

Any help gratefully received as at moment I am having to generate the grid after every file close.

Martyn TomBio2 TonBio1

burkmarr commented 3 years ago

Hello Martyn. I thought it might be something to do with saving in geopackage format, but I have just done that and it worked (on 3.6 with Windows). Can you try doing it again, but change the format of the saved data, e.g. shapefile or geojson?

burkmarr commented 3 years ago

Just had another look at this. I have found a problem with the tool. It creates a layer for the grid references with two fields - GridType and GridRef. Both are created as text with max length of 20 characters. However, this is not enough for the GridType field whose values which can exceed this. On Windows QGIS doesn't seem to complain which is very strange, but that is the source of the error you are seeing. I will log this as a bug that needs fixing. In the meatime, a workaround for you is to delete the field GridType from your 'OSGR grid squares' layer before you save it.

gideonsway commented 3 years ago

Hi Rich,

still not working - am I deleting the grid type in wrong place via properties? Sorry to be dumb but could you please be bit clearer in what I need to do to work round this bug - I am getting this error - not new as I have had before “Could not make temporary scratch layer permanent. Error: Creation of layer failed (OGR error: Failed to create file grid1.shp: Permission denied)” What am I doing wrong?

Martyn

On 13 July 2021 at 11:12:26, Rich Burkmar @.***) wrote:

Just had another look at this. I have found a problem with the tool. It creates a layer for the grid references with two fields - GridType and GridRef. Both are created as text with max length of 20 characters. However, this is not enough for the GridType field whose values which can exceed this. On Windows QGIS doesn't seem to complain which is very strange, but that is the source of the error you are seeing. I will log this as a bug that needs fixing. In the meatime, a workaround for you is to delete the field GridType from your 'OSGR grid squares' layer before you save it.

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/FieldStudiesCouncil/QGIS-Biological-Recording-Tools/issues/56#issuecomment-878960427, or unsubscribe https://github.com/notifications/unsubscribe-auth/APEHB2IG3Q64O24ZF7QGFHDTXQGQVANCNFSM4727VFFQ .

burkmarr commented 3 years ago

A QGIS permission error like that on saving a shapefile is usually because you are just typing in the name of your shapefile and not using the browse button to locate a folder (where you have write permission) to put the shapefile.

drdcarpenter commented 2 years ago

I have this bug also, where the string in the GridType field exceeds the 20 character limit. I am using QGIS 3.16 on Ubuntu. Deleting the GridType column does allow me to save it or make it permanent.

ygphil commented 2 years ago

I have noticed this bug also using TomBio v3.4.0 and QGIS 3.22 on Windows. I was using the OSGR Tool to create a Hectad grid. The auto generated GridType was a string 21 characters long. Editing the field contents and then saving worked for me. I could then make the layer permanent.

KenElsom commented 2 years ago

This has been a persistent bug for me for well over a year. Currently still does it in Windows 11/QGIS 3.22.3/TomBio 3.4.0

KenElsom commented 2 years ago

The correction you seek is that in osgrLayer.py, line 76, change the "&field=GridType:string(20)&field=GridRef:string(20)" to "&field=GridType:string(21)&field=GridRef:string(21)". This is changeable by everyone, the file in Windows is in AppData\Roaming\QGIS\QGIS3\profiles\default\python\plugins\TomBio.zip\TomBio\osgrLayer.py where AppData is a hidden directory in the user’s home file. There maybe ramifications of this change but I don’t see any: layer saves and restores correctly.

burkmarr commented 2 years ago

Fixed in release 3.4.1.