0

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

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.

| improve this answer | |
  • 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? – Wesley Bowman Jan 8 '16 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. – If you do not know- just GIS Jan 8 '16 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. – Wesley Bowman Jan 8 '16 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/… – If you do not know- just GIS Jan 8 '16 at 19:43
  • Yeah, no problem. My fix made it work. Thanks for your help! – Wesley Bowman Jan 9 '16 at 12:25

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.