Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
def reproject_point(pos):
pos = point(pos['lon'], pos['lat'], CRS('EPSG:4326'))
coords = pos.to_crs(crs).coords[0]
return {'x': coords[0], 'y': coords[1]}
AUTHORITY["EPSG","9122"]],
AUTHORITY["EPSG","4283"]],
UNIT["metre",1,
AUTHORITY["EPSG","9001"]],
PROJECTION["Albers_Conic_Equal_Area"],
PARAMETER["standard_parallel_1",-18],
PARAMETER["standard_parallel_2",-36],
PARAMETER["latitude_of_center",0],
PARAMETER["longitude_of_center",132],
PARAMETER["false_easting",0],
PARAMETER["false_northing",0],
AUTHORITY["EPSG","3577"],
AXIS["Easting",EAST],
AXIS["Northing",NORTH]]""")
SINIS_PROJ = geometry.CRS("""PROJCS["Sinusoidal",
GEOGCS["GCS_Undefined",
DATUM["Undefined",
SPHEROID["User_Defined_Spheroid",6371007.181,0.0]],
PRIMEM["Greenwich",0.0],
UNIT["Degree",0.0174532925199433]],
PROJECTION["Sinusoidal"],
PARAMETER["False_Easting",0.0],
PARAMETER["False_Northing",0.0],
PARAMETER["Central_Meridian",0.0],
UNIT["Meter",1.0]]""")
LCC2_PROJ = geometry.CRS("""PROJCS["unnamed",
GEOGCS["WGS 84",
DATUM["unknown",
SPHEROID["WGS84",6378137,6556752.3141]],
PRIMEM["Greenwich",0],
def test_australian_albers_comparison(self):
a = geometry.CRS("""PROJCS["GDA94_Australian_Albers",GEOGCS["GCS_GDA_1994",
DATUM["Geocentric_Datum_of_Australia_1994",SPHEROID["GRS_1980",6378137,298.257222101]],
PRIMEM["Greenwich",0],UNIT["Degree",0.017453292519943295]],
PROJECTION["Albers_Conic_Equal_Area"],
PARAMETER["standard_parallel_1",-18],
PARAMETER["standard_parallel_2",-36],
PARAMETER["latitude_of_center",0],
PARAMETER["longitude_of_center",132],
PARAMETER["false_easting",0],
PARAMETER["false_northing",0],
UNIT["Meter",1]]""")
b = epsg3577
assert a == b
assert a != epsg4326
def grid2polygon(grid, crs):
grid = _norm_grid(grid)
h, w = grid.shape
transform = grid.transform
if isinstance(crs, str):
crs = CRS(crs)
return polygon_from_transform(w, h, transform, crs)
def doc2gs(doc):
return GridSpec(crs=CRS(doc['crs']),
tile_size=tuple(doc['tile_size']),
resolution=tuple(doc['resolution']),
origin=tuple(doc['origin']))
def query_group(datacube_config, kwargs):
dc = Datacube(config=datacube_config)
kwargs['geopolygon'] = Geometry(kwargs['geopolygon'], CRS(kwargs['crs']))
kwargs.pop('crs', None)
try:
datasets = virtual_product.query(dc, **kwargs)
grouped = virtual_product.group(datasets, **kwargs)
except Exception as e:
_LOG.warning('something weird happend %s', e)
return None
else:
return grouped
def _write_geographical_extents_attributes(nco, extent):
geo_extents = extent.to_crs(geometry.CRS("EPSG:4326"))
nco.geospatial_bounds = geo_extents.wkt
nco.geospatial_bounds_crs = "EPSG:4326"
geo_bounds = geo_extents.boundingbox
nco.geospatial_lat_min = geo_bounds.bottom
nco.geospatial_lat_max = geo_bounds.top
nco.geospatial_lat_units = "degrees_north"
nco.geospatial_lon_min = geo_bounds.left
nco.geospatial_lon_max = geo_bounds.right
nco.geospatial_lon_units = "degrees_east"
def _dc_crs(crs: Optional[RioCRS]) -> Optional[CRS]:
""" Convert RIO version of CRS to datacube
"""
if crs is None:
return None
if not crs.is_valid:
return None
if crs.is_epsg_code:
return CRS('epsg:{}'.format(crs.to_epsg()))
return CRS(crs.wkt)