Changeset 3745


Ignore:
Timestamp:
03/04/08 15:18:53 (11 years ago)
Author:
spascoe
Message:

More GDAL code.

Location:
TI05-delivery/ows_framework/branches/ows_framework-refactor/ows_common/ows_common
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • TI05-delivery/ows_framework/branches/ows_framework-refactor/ows_common/ows_common/service/wms_gdal.py

    r3695 r3745  
    183183    """ 
    184184    ds = dataSource.getDataset() 
     185 
     186    sr_src = osr.SpatialReference(dataSource.GetProjection()) 
     187    sr_dst = osr.SpatialReference(wkt) 
     188    ct = osr.CoordinateTransform(sr_src, sr_dst) 
     189 
     190    # What is a reasonable resolution?  We should transform the resolution 
     191    # of the source image into the new coordinates 
     192    T = ds.GetGeoTransform() 
     193    #!TODO ... 
     194     
     195 
    185196    dr = gdal.GetDriverByName(driverName) 
    186197    #!TODO: How big should the image be? Just fudge the issue for now. 
    187     dsOut = dr.Create(datasetName, ds.RasterXSize, ds.RasterYSize, 4, 
     198    dsOut = dr.Create(datasetName, width, height, 4, 
    188199                      gdal.GDT_Byte) 
    189200    dsOut.SetProjection(wkt) 
     201 
     202    # We need to calculate the warped GeoTransform 
     203    topLeft = ct(T[0], T[3]) 
     204 
    190205 
    191206    gdal.ReprojectImage(ds, dsOut, ds.GetProjection(), wkt) 
  • TI05-delivery/ows_framework/branches/ows_framework-refactor/ows_common/ows_common/test/data/obs_gdal.png.aux.xml

    r3634 r3745  
    11<PAMDataset> 
    22  <SRS>GEOGCS[&quot;WGS 84&quot;,DATUM[&quot;WGS_1984&quot;,SPHEROID[&quot;WGS 84&quot;,6378137,298.257223563,AUTHORITY[&quot;EPSG&quot;,&quot;7030&quot;]],AUTHORITY[&quot;EPSG&quot;,&quot;6326&quot;]],PRIMEM[&quot;Greenwich&quot;,0,AUTHORITY[&quot;EPSG&quot;,&quot;8901&quot;]],UNIT[&quot;degree&quot;,0.01745329251994328,AUTHORITY[&quot;EPSG&quot;,&quot;9122&quot;]],AUTHORITY[&quot;EPSG&quot;,&quot;4326&quot;]]</SRS> 
    3   <GeoTransform> -1.8000000000000000e+02,  7.0312500000000000e-01,  0.0000000000000000e+00,  9.0000000000000000e+01,  0.0000000000000000e+00, -7.0312500000000000e-01</GeoTransform> 
     3  <GeoTransform> -1.8000000000000000e+02,  7.0175438596491224e-01,  0.0000000000000000e+00,  9.0000000000000000e+01,  0.0000000000000000e+00, -7.0038910505836571e-01</GeoTransform> 
    44  <Metadata domain="IMAGE_STRUCTURE"> 
    55    <MDI key="INTERLEAVE">PIXEL</MDI> 
  • TI05-delivery/ows_framework/branches/ows_framework-refactor/ows_common/ows_common/test/test_wms_gdal.py

    r3694 r3745  
    3232        sr = osr.SpatialReference() 
    3333        sr.ImportFromWkt(self._ds.GetProjection()) 
    34         self.crs = '%s:%s' % (sr.GetAuthorityName('GEOGCS'), 
    35                               sr.GetAuthorityCode('GEOGCS')) 
     34 
     35        if sr.GetAuthorityName('PROJCS'): 
     36            self.crs = '%s:%s' % (sr.GetAuthorityName('PROJCS'), 
     37                                  sr.GetAuthorityCode('PROJCS')) 
     38        else: 
     39            self.crs = '%s:%s' % (sr.GetAuthorityName('GEOGCS'), 
     40                                  sr.GetAuthorityCode('GEOGCS')) 
    3641 
    3742    def getWKT(self): 
     
    4348        w, h = self._ds.RasterXSize, self._ds.RasterYSize 
    4449 
    45         bbox = geoTransform(0, h, T) + geoTransform(w, 0, T) 
     50        # the GeoTransform is relative to the top-left corner of pixel 0,0 
     51        # therefore to encompass all of the pixels we add 1 to w and h. 
     52        llx, lly = geoTransform(0, h+1, T) 
     53        urx, ury = geoTransform(w+1, 0, T) 
     54        bbox = (llx, lly, urx, ury) 
    4655 
    4756        return bbox 
     
    8291    def test4(self): 
    8392        layer = self.setupWarp() 
     93        print layer.crss 
    8494        assert layer.crss == ['EPSG:27700', 'EPSG:4326'] 
    8595 
     
    8797        layer = self.setupWarp() 
    8898        slab = layer.getSlab('EPSG:4326') 
    89         img = slab.getImage((-3.46, 55.08, 3.46, 61.08), 100, 100) 
     99 
     100        # Create a copy of the warped image 
     101        ds = slab._data 
     102        import pdb; pdb.set_trace() 
     103 
     104        img = slab.getImage((-3.0, 54.0, 3.0, 60.0), 100, 100) 
    90105        img.save('out2.png') 
Note: See TracChangeset for help on using the changeset viewer.