1

When you run QGIS and open a project file (.qgs), a new version of QGIS will read the .shp files and update them for format changes that go with the new version.

The changes finish, but don't work, the layer is blank, and the .shp file ends up at size 100 bytes.

I have ruined many files this way, downloaded fresh ones, and then ruined them again.

What am I doing wrong?

Using Lubuntu-19.10, qgis-3.4.10 (from Ubuntu repository).

Update

Normally the situation would be that you have changed to a new version QGIS, like 2.8.* to 3.4.10, but since I have 3.4.10 already installed (from the ubuntu repository) I re-install it, launch it and start a new project:

$ sudo apt remove qgis  
$ sudo apt install qgis  
$ qgis  

My first shapefile layer is in /home/dk/GISdata/cadastral/CassowaryCoast/2020-01-13/Cadastral_data_QLD_CADASTRE_DCDB.shp, 9.8 MB. When I click on New Shapefile Layer, then the "..." button, and navigate to the .shp file, it is shown as 10.3 MB.

The file encoding used to show "system" but now shows "unicode". The dropdown list, which contains hundreds of entries, does NOT contain "system".

The geometry type shows "Point", so I change it to polygon. The file's projection is GDA94, so I choose "EPSG:3577 - GDA94 / Australian Albers"

The Fields List shows only one line:

id integer 10 [this is definitely wrong]

I click "OK".

An error message appears saying:

"The layer already exists. Are you sure you want to overwrite the existing file?"

This is wrong, it is a new project.

I click on "Yes", a notification appears, saying:

"Remote Layer: file path".

This disappears after 1 second, leaving a blank screen.

The Layers panel shows 1 layer "Cadastral data QLD CADAS..."

I save the project as rubbish.qgz

In File Manager, /home/dk/GISdata/cadastral/CassowaryCoast/2020-01-13/ shows the file Cadastral_data_QLD_CADASTRE_DCDB.shp has been changed to 100 bytes, the .cpg file has changed to 7 bytes, the .dbf file has changed to 66 bytes, the .prj file changed to 415 bytes, the .qpj file has changed to 695 bytes, and the .shx file has changed to 100 bytes.

The file Cadastral_data_QLD_CADASTRE_ROAD.shp remains unchanged at 7.1 MB. "rubbish.qgz" does not exist.

  • 4
    Well, you are ruining them, that's obviously what you are doing wrong!? ...but seriously, can you add some more detail? When exactly does this happen? Why does QGIS rewrite .shp for format changes? – geozelot Jan 10 at 7:53
  • 4
    Detail every step of what you are doing. eg, "start qgis, load shapefile, quit qgis, shapefile is now corrupted". Or are you doing anything to the qgis layer (editing?)? What do you mean "qgis rewrites the shp files for format changes"? What are "format changes"? Are you adding columns? Can you share one of your 100 byte files? I'm curious to see what's in it. – Spacedman Jan 10 at 8:11
  • 3
    The shapefile header is exactly 100 bytes (the .shx has the same 100 bytes as the corresponding .shp), so a 100 byte shapefile is merely an empty shapefile (the .dbf would have 32 * (1 + number_of_fields) bytes). – Vince Jan 10 at 11:58
  • 4
    @DaveKimble the message you receive is only related to the qgis project file (.qgs) and in 99% of the cases it will still work in older qgis version. However, this message has nothing to with the data this project contains. So lets start from very scratch: What was your excact workflow from the very beginning? Download data (from where, and is this data ok), then what exactly you do? Create a new qgis project and load this newly downloaded data into? ... – MrXsquared Jan 13 at 15:56
  • 3
    You are saving a new empty shapefile over the top of your existing shapefile. – user2856 Jan 15 at 2:53
5

First off, a 100 byte shapefile indicates, that this file is just empty. The header of a shapefile is 100 byte. See https://www.esri.com/library/whitepapers/pdfs/shapefile.pdf on page 3.

Secondly, the message "When you run QGIS and open a project file (.qgs), a new version of QGIS will read the .shp files and update them for format changes that go with the new version." has nothing to do with shapefiles or any data you are using within a project. It is only related to the project file (.qgs/.qgz) itself. This means, if you are using new features from a new QGIS version and save this project, you wont be able to use this feature with an older QGIS version. In most cases you can still open the project file though and use it without that new feature.

Last and most important: You are overwriting your data with empty new files. Thats why your shapefile ends up having 100 bytes (see #1). So remind the following:

  • If you want to create a new shapefile, make sure to use another location or filename. Otherwise you will overwrite your previous/existing data.
  • In addition, if the message "The layer already exists. Are you sure you want to overwrite the existing file?" pops up, it clearly indicates that you are about to overwrite an existing file. Click "no".
  • If you want to add existing data to your project, do NOT use "New Shapefile layer", instead DO USE "Add Shapefile layer".

Keeping this in mind, all your other issues like wrong field types or encoding will be solved as well.

You may also want to check out this QGIS manual: https://docs.qgis.org/3.4/en/docs/user_manual/managing_data_source/index.html

|improve this answer|||||

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.