Search code examples
arcgisprojection

how to get projection(espg number) from fif or tfw file


I have tif file whith a tfw file

 30.00000000
 0.00000000
 0.00000000
-30.00000000
4558664.95812873
4002879.73390571

The file owner said that their data is in wgs84 and generate the tif with arcgis. The last two number are too large to be wgs84.


Solution

  • Some .tif files have GeoTIFF tags embedded in the file, which specify the raster's spatial reference. To see whether the .tif has a spatial reference built in, navigate to the .tif in ArcMap's catalog window, right-click the .tif, choose Properties, and scroll down to the Spatial Reference properties on the General tab. Or if you want to do it in Python code, just check to see if the spatial reference's factory code, also known as a well-known ID or WKID, is zero or not:

    import arcpy
    raster = arcpy.Raster(r"C:\path\to\raster.tif")
    wkid = raster.spatialReference.factoryCode
    print("spatial reference " + str(wkid) if 0 != wkid else "NO spatial reference!")
    

    See the documentation for the Raster and SpatialReference Python classes in ArcGIS's ArcPy module.

    A .tfw file, officially known as a world file, does not contain a spatial reference. It provides georeferencing information but not an actual spatial reference. You will not be able to get the spatial reference from it. However, you can get some clues. For example, the last two numbers in your world file are the x- and y-coordinates of the upper-left pixel. Clearly, those values are not longitude and latitude, so the dataset is very unlikely to be in WGS84 if the world file is correct.