I have a geotiff file that I made in Python. After I created it, I realized it was for all of North America, and I only need the United States. I then got what I assumed was a shapefile of the US border, and tried to clip with

gdalwarp -cutline shapefile.shp input.tif output.tif

When I do this, it creates an output file, but the whole file is filled with zeros. I have tried a few other methods, but they all end up being filled with zeros. I think it could have to do with the spatial reference or the extent of either the shp or tif. Anyone have any ideas? Files included below.

Here is the geotiff file.

Here is the shapefile.

I have also tried a different shapefile, but that hasn't worked either.

1 Answer 1


You cannot just link to a .shp file, you need to have all the components of the shapefile ,in a zip file preferably (.shp, .dbf, .shx, and in this case .prj) for us to help. From your download you have only have the .shp but this is okay as I recognize the name of your shapefile from the census (from the download file).

This is why you get nothing, nothing is under the USA polygon.

enter image description here

They do not align.

You shapefile is fine but your Geotiff has florida at ~57 degrees north, it is closer to 27 degrees north.

The envelope information is incorrect. Time to go back to your tiff creation process in Python with a view to registration.

  • I only included the shapefile, but I have all the other files in the same directory. And interesting. Whats the best method to get them to match up? Jan 8, 2016 at 19:21
  • It is all on the tiff, you need to go back to the source of this and how you created it. Or GDAL Warp. Jan 8, 2016 at 19:30
  • Thanks. It was just a small error in the python code. I was using geotransform=(xmin, xres, 0, ymax, 0, yres) and my yres was suppose to be negative. Jan 8, 2016 at 19:37
  • Yes that looks like it, , this is my best effort but I did not have the precise info to fix so use yours... but here it is just in case. drive.google.com/file/d/0B_5XlZJJ2R5taU4xMkFDRTJQU0k/… Jan 8, 2016 at 19:43
  • Yeah, no problem. My fix made it work. Thanks for your help! Jan 9, 2016 at 12:25

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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