[gdal-dev] Dataset setProjection() method sets PROJCS to "unnamed"

Even Rouault even.rouault at spatialys.com
Tue Feb 10 04:18:42 PST 2015


Le mardi 10 février 2015 13:09:00, Rebo Ghecin a écrit :
> My dataset is raster dataset created from .tif file.

(Re'adding gdal-dev)

With recent GDAL (trunk but likely 1.11 or 1.10 too), I've much more detailed 
preserved:

with your WKT in test.wkt, if I do :
gdal_translate byte.tif byte_custom.tif -a_srs test.wkt

Then gdalinfo byte_custom.tif gives:


PROJCS["UTM3 Degree ITRF96 DOM39",
    GEOGCS["GCS_ITRF_1996",
        DATUM["D_ITRF_1996",
            SPHEROID["GRS_1980",6378137,298.257222101]],
        PRIMEM["Greenwich",0],
        UNIT["degree",0.0174532925199433]],
    PROJECTION["Transverse_Mercator"],
    PARAMETER["latitude_of_origin",0],
    PARAMETER["central_meridian",39],
    PARAMETER["scale_factor",1],
    PARAMETER["false_easting",500000],
    PARAMETER["false_northing",0],
    UNIT["metre",1,
        AUTHORITY["EPSG","9001"]]]

So the ProjCS name is preserved.

$ listgeo byte_custom.tif 
Geotiff_Information:
   Version: 1
   Key_Revision: 1.0
   Tagged_Information:
      ModelTiepointTag (2,3):
         0                 0                 0                
         440720            3751320           0                
      ModelPixelScaleTag (1,3):
         60                60                0                
      End_Of_Tags.
   Keyed_Information:
      GTModelTypeGeoKey (Short,1): ModelTypeProjected
      GTRasterTypeGeoKey (Short,1): RasterPixelIsArea
      GTCitationGeoKey (Ascii,25): "UTM3 Degree ITRF96 DOM39"
      GeographicTypeGeoKey (Short,1): User-Defined
      GeogCitationGeoKey (Ascii,86): "GCS Name = GCS_ITRF_1996|Datum = 
D_ITRF_1996|Ellipsoid = GRS_1980|Primem = Greenwich|"
      GeogGeodeticDatumGeoKey (Short,1): User-Defined
      GeogAngularUnitsGeoKey (Short,1): Angular_Degree
      GeogEllipsoidGeoKey (Short,1): User-Defined
      GeogSemiMajorAxisGeoKey (Double,1): 6378137          
      GeogInvFlatteningGeoKey (Double,1): 298.257222101    
      GeogPrimeMeridianLongGeoKey (Double,1): 0                
      ProjectedCSTypeGeoKey (Short,1): User-Defined
      ProjectionGeoKey (Short,1): User-Defined
      ProjCoordTransGeoKey (Short,1): CT_TransverseMercator
      ProjLinearUnitsGeoKey (Short,1): Linear_Meter
      ProjNatOriginLongGeoKey (Double,1): 39               
      ProjNatOriginLatGeoKey (Double,1): 0                
      ProjFalseEastingGeoKey (Double,1): 500000           
      ProjFalseNorthingGeoKey (Double,1): 0                
      ProjScaleAtNatOriginGeoKey (Double,1): 1                
      End_Of_Keys.
   End_Of_Geotiff.


> 
> On Tue, Feb 10, 2015 at 1:36 PM, Even Rouault <even.rouault at spatialys.com>
> 
> wrote:
> > Le mardi 10 février 2015 12:10:14, Rebo Ghecin a écrit :
> > > Hi,
> > > 
> > > I want to change my Dataset's projection but I have a trouble with it.
> > 
> > Rebo,
> > 
> > you didn't specify which format your dataset is. Depending on format
> > capabilities, only parts of the original WKT can be preserved. There's
> > likely
> > not much you can do about that.
> > 
> > Even
> > 
> > > I have custom projection like below:
> > > 
> > > PROJCS["UTM3 Degree ITRF96 DOM39",
> > > 
> > >   GEOGCS["GCS_ITRF_1996",
> > >   
> > >     DATUM["D_ITRF_1996",
> > >     
> > >       SPHEROID["GRS_1980", 6378137.0, 298.257222101]],
> > >     
> > >     PRIMEM["Greenwich", 0.0],
> > >     UNIT["degree", 0.017453292519943295],
> > >     AXIS["Longitude", EAST],
> > >     AXIS["Latitude", NORTH]],
> > >   
> > >   PROJECTION["Transverse_Mercator"],
> > >   PARAMETER["central_meridian", 39.0],
> > >   PARAMETER["latitude_of_origin", 0.0],
> > >   PARAMETER["scale_factor", 1.0],
> > >   PARAMETER["false_easting", 500000.0],
> > >   PARAMETER["false_northing", 0.0],
> > >   UNIT["m", 1.0],
> > >   AXIS["x", EAST],
> > >   AXIS["y", NORTH],
> > >   AUTHORITY["EPSG","10103390"]]
> > > 
> > > and this is how I changed it:
> > > 
> > > String test = "PROJCS[\"UTM3 Degree ITRF96 DOM39\",
> > > GEOGCS[\"GCS_ITRF_1996\",     DATUM[\"D_ITRF_1996\",
> > > SPHEROID[\"GRS_1980\", 6378137.0, 298.257222101]],
> > > PRIMEM[\"Greenwich\", 0.0],    UNIT[\"degree\", 0.017453292519943295],
> > > 
> > >  AXIS[\"Longitude\", EAST],    AXIS[\"Latitude\", NORTH]],
> > >  PROJECTION[\"Transverse_Mercator\"],  PARAMETER[\"central_meridian\",
> > > 
> > > 39.0],  PARAMETER[\"latitude_of_origin\", 0.0],
> > > 
> > >  PARAMETER[\"scale_factor\", 1.0],  PARAMETER[\"false_easting\",
> > 
> > 500000.0],
> > 
> > >  PARAMETER[\"false_northing\", 0.0],  UNIT[\"m\", 1.0],  AXIS[\"x\",
> > 
> > EAST],
> > 
> > >  AXIS[\"y\", NORTH],  AUTHORITY[\"EPSG\",\"10103390\"]]";
> > > 
> > > SpatialReference oSRS = new SpatialReference();
> > > oSRS.ImportFromWkt(test);
> > > inputDataset.SetProjection(oSRS.ExportToWkt());
> > > 
> > > and it returns
> > > 
> > > PROJCS["unnamed",
> > > 
> > >   GEOGCS["GCS Name = GCS_ITRF_1996",
> > >   
> > >     DATUM["Datum = D_ITRF_1996",
> > >     
> > >       SPHEROID["Ellipsoid = GRS_1980", 6378137.0, 298.257222101]],
> > >     
> > >     PRIMEM["Greenwich", 0.0],
> > >     UNIT["degree", 0.017453292519943295],
> > >     AXIS["Geodetic longitude", EAST],
> > >     AXIS["Geodetic latitude", NORTH]],
> > >   
> > >   PROJECTION["Transverse_Mercator"],
> > >   PARAMETER["central_meridian", 39.0],
> > >   PARAMETER["latitude_of_origin", 0.0],
> > >   PARAMETER["scale_factor", 1.0],
> > >   PARAMETER["false_easting", 500000.0],
> > >   PARAMETER["false_northing", 0.0],
> > >   UNIT["m", 1.0],
> > >   AXIS["Easting", EAST],
> > >   AXIS["Northing", NORTH]]
> > > 
> > > I have created custom.wkt file and include it in epsg.wkt at
> > > "gdal_data" folder but this is also not working for me.
> > > 
> > > custom.wkt content:
> > > 
> > > 10103390,PROJCS["UTM3 Derece ITRF96
> > 
> > DOM39",GEOGCS["GCS_ITRF_1996",DATUM["D_ITRF_1996",SPHEROID["GRS_1980",637
> > 81
> > 
> > 37.0,298.257222101]],PRIMEM["Greenwich",0.0],UNIT["Degree",0.017453292519
> > 94
> > 
> > 33]],PROJECTION["Transverse_Mercator"],PARAMETER["False_Easting",500000.0
> > ],
> > 
> > PARAMETER["False_Northing",0.0],PARAMETER["Central_Meridian",39.0],PARAME
> > TE
> > 
> > R["Scale_Factor",1.0],PARAMETER["Latitude_Of_Origin",0.0],UNIT["Meter",1.
> > 0]
> > 
> > > , AUTHORITY["EPSG","10103390"]]
> > > 
> > > Also I tried to set PROJCS like this
> > > 
> > > oSRS.SetProjCS("My Proj"); but didn't work.
> > > 
> > > Any idea with this?
> > > 
> > > Thanks
> > > Rebo
> > 
> > --
> > Spatialys - Geospatial professional services
> > http://www.spatialys.com

-- 
Spatialys - Geospatial professional services
http://www.spatialys.com


More information about the gdal-dev mailing list