- Timestamp:
- Sep 4, 2008, 5:22:08 PM (16 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
anuga_core/source/anuga/geospatial_data/geospatial_data.py
r5729 r5730 228 228 self.attributes = attributes 229 229 230 #def set_geo_reference(self, geo_reference): 231 # # FIXME (Ole): Backwards compatibility - deprecate 232 # self.setgeo_reference(geo_reference) 230 233 231 234 def set_geo_reference(self, geo_reference): 232 """ 233 Set's the georeference of geospatial. 234 It can also be used to change the georeference 235 """Set the georeference of geospatial data. 236 237 It can also be used to change the georeference and will ensure that 238 the absolute coordinate values are unchanged. 235 239 """ 236 240 from anuga.coordinate_transforms.geo_reference import Geo_reference 237 241 238 242 if geo_reference is None: 239 geo_reference = Geo_reference() # Use default 243 # Use default - points are in absolute coordinates 244 geo_reference = Geo_reference() 245 246 # Allow for tuple (zone, xllcorner, yllcorner) 240 247 geo_reference = ensure_geo_reference(geo_reference) 248 241 249 if not isinstance(geo_reference, Geo_reference): 250 # FIXME (Ole): This exception will be raised if geo_reference is None 242 251 msg = 'Argument geo_reference must be a valid Geo_reference \n' 243 252 msg += 'object or None.' 244 253 raise msg 245 254 246 # if a geo ref already exists, change the point datato247 # represent the new geo-ref255 # If a geo_reference already exists, change the point data according to 256 # the new geo reference 248 257 if self.geo_reference is not None: 249 #FIXME: Maybe put out a warning here... 250 self.data_points = self.get_data_points \ 251 (geo_reference=geo_reference) 258 self.data_points = self.get_data_points(geo_reference=geo_reference) 252 259 253 260 self.geo_reference = geo_reference … … 376 383 lats_longs = [] 377 384 for point in self.get_data_points(True): 378 ### UTMtoLL(northing, easting, zone, 385 386 # UTMtoLL(northing, easting, zone, 379 387 lat_calced, long_calced = UTMtoLL(point[1],point[0], 380 388 zone, isSouthHemisphere) 381 389 lats_longs.append((lat_calced, long_calced)) # to hash 382 390 return lats_longs 391 383 392 if absolute is True and geo_reference is None: 384 393 return self.geo_reference.get_absolute(self.data_points) … … 388 397 self.geo_reference) 389 398 else: 399 # If absolute is False 390 400 return self.data_points 391 401 … … 1315 1325 1316 1326 def ensure_absolute(points, geo_reference=None): 1317 """ 1327 """Ensure that points are in absolute coordinates. 1328 1318 1329 This function inputs several formats and 1319 1330 outputs one format. - a numeric array of absolute points. 1320 1331 1321 Input edformats are;1322 points: List or numeric array of coordinate pairs [xi, eta] of1332 Input formats are; 1333 points: List or numeric array of coordinate pairs [xi, eta] of 1323 1334 points or geospatial object or points file name 1324 1335 … … 1328 1339 relative to their respective origins. 1329 1340 """ 1330 if isinstance(points,type('')): 1331 #It's a string1332 #assume it is a point file1333 points = Geospatial_data(file_name = points)1334 1335 if isinstance(points,Geospatial_data):1336 points = points.get_data_points( \1337 absolute =True)1338 msg = "Use a Geospatial_data object or a mesh origin. Not both."1341 1342 # Input check 1343 if isinstance(points, basestring): 1344 #It's a string - assume it is a point file 1345 points = Geospatial_data(file_name=points) 1346 1347 if isinstance(points, Geospatial_data): 1348 points = points.get_data_points(absolute=True) 1349 msg = 'Use a Geospatial_data object or a mesh origin. Not both.' 1339 1350 assert geo_reference == None, msg 1340 1341 1351 else: 1342 1352 points = ensure_numeric(points, Float) 1353 1354 # Sort of geo_reference and convert points 1343 1355 if geo_reference is None: 1344 1356 geo = None #Geo_reference() … … 1351 1363 geo_reference[2]) 1352 1364 points = geo.get_absolute(points) 1365 1366 # Return 1353 1367 return points 1354 1368 … … 1368 1382 relative to their respective origins. 1369 1383 """ 1370 if isinstance(points,Geospatial_data): 1384 1385 # Input check 1386 if isinstance(points, Geospatial_data): 1371 1387 msg = "Use a Geospatial_data object or a mesh origin. Not both." 1372 assert geo_reference ==None, msg1388 assert geo_reference is None, msg 1373 1389 return points 1374 1390 else: 1391 # List or numeric array of absolute points 1375 1392 points = ensure_numeric(points, Float) 1393 1394 # Sort out geo reference 1376 1395 if geo_reference is None: 1377 1396 geo = None … … 1383 1402 geo_reference[1], 1384 1403 geo_reference[2]) 1404 1405 # Create Geospatial_data object with appropriate geo reference and return 1385 1406 points = Geospatial_data(data_points=points, geo_reference=geo) 1386 1407 return points
Note: See TracChangeset
for help on using the changeset viewer.