Changeset 4452


Ignore:
Timestamp:
May 16, 2007, 2:53:14 PM (18 years ago)
Author:
duncan
Message:

This revision is unstable. Don't check in to this revision.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • anuga_core/source/anuga/geospatial_data/geospatial_data.py

    r4349 r4452  
    1111                        size, shape
    1212from random import randint
     13from copy import deepcopy
     14
    1315#from MA import tolist
    1416
     
    1719from anuga.utilities.numerical_tools import ensure_numeric
    1820from anuga.coordinate_transforms.geo_reference import Geo_reference, \
    19      TitleError, DEFAULT_ZONE
     21     TitleError, DEFAULT_ZONE, ensure_geo_reference, write_NetCDF_georeference
    2022from anuga.coordinate_transforms.redfearn import convert_from_latlon_to_utm
    2123from anuga.utilities.anuga_exceptions import ANUGAError
     
    220222
    221223    def set_geo_reference(self, geo_reference):
    222 
     224        """
     225        Set's the georeference of geospatial.
     226        It can also be used to change the georeference
     227        """
    223228        from anuga.coordinate_transforms.geo_reference import Geo_reference
    224229
    225230        if geo_reference is None:
    226231            geo_reference = Geo_reference() # Use default
     232        geo_reference = ensure_geo_reference(geo_reference)
    227233        if not isinstance(geo_reference, Geo_reference):
    228234            msg = 'Argument geo_reference must be a valid Geo_reference \n'
     
    564570        The point_dict is defined at the top of this file.
    565571       
    566         If absolute is True data points at returned added to the xll and yll
    567         and geo_reference as None
     572        If absolute is True data the xll and yll are added to the points value
     573        and the xll and yll of the geo_reference are set to 0.
    568574       
    569575        If absolute is False data points at returned as relative to the xll
     
    579585            msg = '.xya format is deprecated.  Please use .txt.'
    580586            warn(msg, DeprecationWarning)
    581             if absolute is True:         
     587            if absolute is True:     
     588                geo_ref = deepcopy(self.geo_reference)
     589                geo_ref.xllcorner = 0
     590                geo_ref.yllcorner = 0   
    582591                _write_xya_file(file_name,
    583592                                self.get_data_points(absolute=True),
    584                                 self.get_all_attributes())
     593                                self.get_all_attributes(),
     594                                geo_ref)
    585595            else:
    586596                _write_xya_file(file_name,
     
    591601        elif (file_name[-4:] == ".pts"):
    592602            if absolute is True:
     603                geo_ref = deepcopy(self.geo_reference)
     604                geo_ref.xllcorner = 0
     605                geo_ref.yllcorner = 0
    593606                _write_pts_file(file_name,
    594607                                self.get_data_points(absolute),
    595                                 self.get_all_attributes())
     608                                self.get_all_attributes(),
     609                                geo_ref)
    596610            else:
    597611                _write_pts_file(file_name,
     
    11511165       
    11521166    if write_geo_reference is not None:
    1153         write_geo_reference.write_NetCDF(outfile)
     1167        write_NetCDF_georeference(write_geo_reference, outfile)
    11541168       
    11551169    outfile.close()
     
    11941208
    11951209    if  write_geo_reference is not None:
     1210        write_geo_reference = ensure_geo_reference(write_geo_reference)
    11961211        write_geo_reference.write_ASCII(fd)
    11971212    fd.close()
Note: See TracChangeset for help on using the changeset viewer.