Bug report #15336

(Shape file) Layer extent not updated on project load

Added by Casper Børgesen over 3 years ago. Updated about 1 year ago.

Status:Feedback
Priority:Normal
Assignee:-
Category:Unknown
Affected QGIS version:master Regression?:No
Operating System:windows Easy fix?:No
Pull Request or Patch supplied:No Resolution:
Crashes QGIS or corrupts data:No Copied to github as #:23268

Description

I have a QGIS project file with shape file layer A.

Shape file layer A contains one feature. I have another shape file B, which is not loaded into the QGIS project, and it contains one feature which is at a different location than the feature in layer A.

If I close the QGIS project, switch the names of the two Shape files and open the QGIS project, the zoom-to-extent moves the map to the location of the feature in layer A, but this time its actually layer B, which is loaded in QGIS.

Thus the extent of shape file layers in QGIS projects are NOT updated upon loading. Looking at the metadata pane under the layers properties, confirms the wrong extent.

Is this the expected behavior?

data_A.dbf (76 Bytes) Casper Børgesen, 2016-07-25 05:02 AM

data_A.prj (143 Bytes) Casper Børgesen, 2016-07-25 05:02 AM

data_A.shp (252 Bytes) Casper Børgesen, 2016-07-25 05:02 AM

data_A.shx (108 Bytes) Casper Børgesen, 2016-07-25 05:02 AM

data_B.dbf (76 Bytes) Casper Børgesen, 2016-07-25 05:02 AM

data_B.prj (143 Bytes) Casper Børgesen, 2016-07-25 05:02 AM

data_B.shp (252 Bytes) Casper Børgesen, 2016-07-25 05:02 AM

data_B.shx (108 Bytes) Casper Børgesen, 2016-07-25 05:02 AM

project.qgs (8.25 KB) Casper Børgesen, 2016-07-25 05:02 AM

History

#1 Updated by Harrissou Santanna over 3 years ago

Yes, I think it's the expected behavior. When you save the project, QGIS also saves the current map canvas extent. That does nothing to have with the loaded layer(s). And it's the saved extent that will be shown the next time you open the project. Imagine if anytime you open your project, QGIS zooms to the extent of the loaded layers ignoring that you were working last time on a precise location, It won't be fun nor usable, I guess.

However, when you load the first layer in a new and empty project, QGIS by default automatically zooms to its extent. Is it what you are looking for?

#2 Updated by Casper Børgesen over 3 years ago

Harrissou Santanna wrote:

Yes, I think it's the expected behavior. When you save the project, QGIS also saves the current map canvas extent. That does nothing to have with the loaded layer(s). And it's the saved extent that will be shown the next time you open the project. Imagine if anytime you open your project, QGIS zooms to the extent of the loaded layers ignoring that you were working last time on a precise location, It won't be fun nor usable, I guess.

However, when you load the first layer in a new and empty project, QGIS by default automatically zooms to its extent. Is it what you are looking for?

Hi Harrissou.

Well I rewrote the issue a couple of times before posting it, and I probably made the description even worse - Sorry :)

The issue has nothing to do with the extent that QGIS zooms to or shows when loading a project. I'll try to explain the problem in steps:

1. Load layer A into QGIS.
2. Save the project.
3. Close QGIS.
4. Delete the layer A files.
5. Rename the layer B files to the names of the layer A files.
6. Open the QGIS project.
7. Zoom-to-extent of layer A (which is actually now using the layer B data). It zooms to the extent of the original layer A data instead of the layer B data, which is the current data in the layer.

I would expect QGIS to update the layer extent information of all layers when loading the QGIS project.

#3 Updated by Giovanni Manghi almost 3 years ago

  • Easy fix? set to No
  • Regression? set to No

#4 Updated by Jürgen Fischer over 2 years ago

  • Category set to Unknown

#5 Updated by Giovanni Manghi about 1 year ago

  • Status changed from Open to Feedback

Please check if this issue is still valid on QGIS 3.4.5 or 3.6.

Also available in: Atom PDF