I recently downloaded a file (1960 Census tract boundaries), but when I tried to load the shapefile in QGIS, I get this error:
“Layer is not valid: The layer C:/Users/US_tract_1960.shp is not a valid layer and can not be added to the map. Reason: …”
What’s going on?
Thanks for submitting your question!
I was able to successfully add both the original and the conflated 1960 census tract shapefile to QGIS 3.24.2 (Tisler). I don’t use QGIS much, so I’m afraid I don’t have a great answer to your question. I unzipped the shapefile into its own folder, and then I added that shapefile to the QGIS project.
Dave Van Riper
One possibility is that the directory containing the .shp file does not contain the complete shapefile. Be aware that a “shapefile” in fact consists of multiple associated files. The set of associated files all have the same name with a different extension (e.g, shapefile_name.dbf, shapefile_name.shp, shapefile_name.shx). If you move the .shp file to a different location by itself, it is not complete and will not load properly.
I tried both ways. Originally just left the unzipped file alone and got the error message. Removed the .shp to my desktop and got the same error message. There appears to be a zipped file within a zipped file. Do I need to remove former from the latter?
Yes, the complete shapefile–including all component files, not just the .shp file–needs to be fully unzipped from all containing zip archives. All component files must be located in the same place.
(NHGIS delivers the shapefile in a zip file within a zip file because, for requests of multiple shapefiles, each shapefile is in a separate zip within the single downloaded zip.)
Tried it again, and got the same error message when I try to load the file. I’m using QGIS version 3.16.4-Hannover, BTW.
If you can post a screen shot of the directories where you’re storing the shapefiles, that may help us troubleshoot. If you can’t post one to the forum, you can email our user support at firstname.lastname@example.org.
You can see the directory in the original post. I took out a person name for a folder, but I simply saved the file it to my desktop, which is similar to how I do some of my shapefiles I’m experimenting with.
Layer is not valid: The layer /vsizip/C:/Users/[Redacted]/Desktop/nhgis0002_shape.zip/nhgis0002_shape/nhgis0002_shapefile_tl2008_us_tract_1960.zip is not a valid layer and can not be added to the map. Reason:
Based on path I’m seeing on your final post on May 10, the shapefile is still within the ZIP archive (/nhgis0002_shape.zip/nhgis0002/nhgis0002_shapefile_tl2008_us_tract_1960.zip). I would be that’s why you’re getting the layer is not valid message. I downloaded the same ZIP file and extracted it to a folder called nhgis1617_shapefile_tl2008_us_tract_1960. The screen shot shows all the files that you should see in the folder you extract to. If you can’t see all those files in the folder, I think you will continue to receive the “layer is not valid” error.
Yes, this worked. I was originally trying to upload the initial zipped file, and then the …shp in the zip file within the ziped file. So I just unzip the original file and put that folder on my desktop and that worked.