Test3
In [1]:
Copied!
import rasterarea
import ipyleaflet
import rasterarea
import ipyleaflet
In [2]:
Copied!
# read tiff file, create a point cloud array of the tiff file, with the first column is the center longitudes,
# the second column is the center latitudes, the third column is the pixel values.
data = rasterarea.point_cloud_arrary('data/grace_tif/GRD-3_2018152-2018181_GRFO_UTCSR_BA01_0600_LND_v04.tif')
# read tiff file, create a point cloud array of the tiff file, with the first column is the center longitudes,
# the second column is the center latitudes, the third column is the pixel values.
data = rasterarea.point_cloud_arrary('data/grace_tif/GRD-3_2018152-2018181_GRFO_UTCSR_BA01_0600_LND_v04.tif')
In [3]:
Copied!
# caculate the pixel area array of the tiff file
# input: point cloud array
# output: pixel area array
# 0: center longitudes 1: center latitudes 2:pixel areas
raster_area = rasterarea.pixel_area_array(point_cloud_arrary=data,pixel_size=1,coordinatesp='WGS84')
# caculate the pixel area array of the tiff file
# input: point cloud array
# output: pixel area array
# 0: center longitudes 1: center latitudes 2:pixel areas
raster_area = rasterarea.pixel_area_array(point_cloud_arrary=data,pixel_size=1,coordinatesp='WGS84')
In [4]:
Copied!
nodata = rasterarea.get_geotiff_nodata('data/grace_tif/GRD-3_2018152-2018181_GRFO_UTCSR_BA01_0600_LND_v04.tif')
nodata = rasterarea.get_geotiff_nodata('data/grace_tif/GRD-3_2018152-2018181_GRFO_UTCSR_BA01_0600_LND_v04.tif')
In [5]:
Copied!
from rasterarea import ipyleafletmap
from rasterarea import ipyleafletmap
In [6]:
Copied!
m = ipyleafletmap.Map(center=(40.7128, -74.0060), zoom=10)
m
m = ipyleafletmap.Map(center=(40.7128, -74.0060), zoom=10)
m
Out[6]:
In [7]:
Copied!
import rasterio as rio
from rasterio.plot import show
import rasterio as rio
from rasterio.plot import show
In [8]:
Copied!
img = "data/grace_tif/GRD-3_2018152-2018181_GRFO_UTCSR_BA01_0600_LND_v04.tif"
show(rio.open(img))
img = "data/grace_tif/GRD-3_2018152-2018181_GRFO_UTCSR_BA01_0600_LND_v04.tif"
show(rio.open(img))
Out[8]:
<Axes: >
In [9]:
Copied!
m = ipyleaflet.Map(center=(40.7128, -74.0060), zoom=10)
m
m = ipyleaflet.Map(center=(40.7128, -74.0060), zoom=10)
m
Out[9]:
In [10]:
Copied!
image = ipyleaflet.ImageOverlay(url="data/grace_tif/GRD-3_2018152-2018181_GRFO_UTCSR_BA01_0600_LND_v04.tif",bounds=((40, -40), (40, -40)))
m.add_layer(image)
image = ipyleaflet.ImageOverlay(url="data/grace_tif/GRD-3_2018152-2018181_GRFO_UTCSR_BA01_0600_LND_v04.tif",bounds=((40, -40), (40, -40)))
m.add_layer(image)
In [11]:
Copied!
m.layers
m.layers
Out[11]:
(TileLayer(attribution='© <a href="https://www.openstreetmap.org/copyright">OpenStreetMap</a> contributors', base=True, max_zoom=19, min_zoom=1, name='OpenStreetMap.Mapnik', options=['attribution', 'bounds', 'detect_retina', 'max_native_zoom', 'max_zoom', 'min_native_zoom', 'min_zoom', 'no_wrap', 'tile_size', 'tms', 'zoom_offset'], url='https://tile.openstreetmap.org/{z}/{x}/{y}.png'), ImageOverlay(bounds=[(40, -40), (40, -40)], options=['attribution'], url='data/grace_tif/GRD-3_2018152-2018181_GRFO_UTCSR_BA01_0600_LND_v04.tif'))
In [12]:
Copied!
import geemap
m = geemap.Map()
m.add_local_tile('data/grace_tif/GRD-3_2018152-2018181_GRFO_UTCSR_BA01_0600_LND_v04.tif', palette='viridis', layer_name="GRACE")
m
import geemap
m = geemap.Map()
m.add_local_tile('data/grace_tif/GRD-3_2018152-2018181_GRFO_UTCSR_BA01_0600_LND_v04.tif', palette='viridis', layer_name="GRACE")
m
To authorize access needed by Earth Engine, open the following URL in a web browser and follow the instructions:
The authorization workflow will generate a code, which you should paste in the box below.
--------------------------------------------------------------------------- FileNotFoundError Traceback (most recent call last) File ~/.local/lib/python3.9/site-packages/ee/data.py:228, in get_persistent_credentials() 227 try: --> 228 return Credentials(None, **oauth.get_credentials_arguments()) 229 except IOError: File ~/.local/lib/python3.9/site-packages/ee/oauth.py:72, in get_credentials_arguments() 71 def get_credentials_arguments(): ---> 72 with open(get_credentials_path()) as creds: 73 stored = json.load(creds) FileNotFoundError: [Errno 2] No such file or directory: '/home/runner/.config/earthengine/credentials' During handling of the above exception, another exception occurred: EEException Traceback (most recent call last) File ~/.local/lib/python3.9/site-packages/geemap/common.py:225, in ee_initialize(token_name, auth_mode, service_account) 223 copy_credentials_to_drive() --> 225 ee.Initialize(http_transport=httplib2.Http()) 226 except Exception: File ~/.local/lib/python3.9/site-packages/ee/__init__.py:130, in Initialize(credentials, opt_url, cloud_api_key, http_transport, project) 129 if credentials == 'persistent': --> 130 credentials = data.get_persistent_credentials() 131 data.initialize( 132 credentials=credentials, 133 api_base_url=(opt_url + '/api' if opt_url else None), (...) 137 project=project, 138 http_transport=http_transport) File ~/.local/lib/python3.9/site-packages/ee/data.py:230, in get_persistent_credentials() 229 except IOError: --> 230 raise ee_exception.EEException( 231 'Please authorize access to your Earth Engine account by ' 232 'running\n\nearthengine authenticate\n\n' 233 'in your command line, and then retry.') EEException: Please authorize access to your Earth Engine account by running earthengine authenticate in your command line, and then retry. During handling of the above exception, another exception occurred: StdinNotImplementedError Traceback (most recent call last) Cell In[12], line 2 1 import geemap ----> 2 m = geemap.Map() 3 m.add_local_tile('data/grace_tif/GRD-3_2018152-2018181_GRFO_UTCSR_BA01_0600_LND_v04.tif', palette='viridis', layer_name="GRACE") 4 m File ~/.local/lib/python3.9/site-packages/geemap/geemap.py:52, in Map.__init__(self, **kwargs) 49 kwargs["ee_initialize"] = True 51 if kwargs["ee_initialize"]: ---> 52 ee_initialize() 54 # Default map center location (lat, lon) and zoom level 55 latlon = [20, 0] File ~/.local/lib/python3.9/site-packages/geemap/common.py:227, in ee_initialize(token_name, auth_mode, service_account) 225 ee.Initialize(http_transport=httplib2.Http()) 226 except Exception: --> 227 ee.Authenticate(auth_mode=auth_mode) 228 ee.Initialize(http_transport=httplib2.Http()) File ~/.local/lib/python3.9/site-packages/ee/__init__.py:103, in Authenticate(authorization_code, quiet, code_verifier, auth_mode, scopes) 77 def Authenticate( 78 authorization_code=None, 79 quiet=None, 80 code_verifier=None, 81 auth_mode=None, 82 scopes=None): 83 """Prompts the user to authorize access to Earth Engine via OAuth2. 84 85 Args: (...) 101 (auth_url, code_verifier) when called with quiet='init_only' 102 """ --> 103 return oauth.authenticate(authorization_code, quiet, code_verifier, auth_mode, 104 scopes) File ~/.local/lib/python3.9/site-packages/ee/oauth.py:408, in authenticate(cli_authorization_code, quiet, cli_code_verifier, auth_mode, scopes) 405 if flow.display_instructions(quiet): 406 _open_new_browser(flow.auth_url) --> 408 flow.save_code() File ~/.local/lib/python3.9/site-packages/ee/oauth.py:451, in Flow.save_code(self, code) 449 redirect_uri = self.server.url 450 code = self.server.fetch_code() # Waits for oauth callback --> 451 _obtain_and_write_token(code, self.code_verifier, self.scopes, redirect_uri) File ~/.local/lib/python3.9/site-packages/ee/oauth.py:179, in _obtain_and_write_token(auth_code, code_verifier, scopes, redirect_uri) 177 client_info['redirect_uri'] = redirect_uri 178 if not auth_code: --> 179 auth_code = input('Enter verification code: ') 180 assert isinstance(auth_code, str) 181 scopes = scopes or SCOPES File ~/.local/lib/python3.9/site-packages/ipykernel/kernelbase.py:1190, in Kernel.raw_input(self, prompt) 1188 if not self._allow_stdin: 1189 msg = "raw_input was called, but this frontend does not support input requests." -> 1190 raise StdinNotImplementedError(msg) 1191 return self._input_request( 1192 str(prompt), 1193 self._parent_ident["shell"], 1194 self.get_parent("shell"), 1195 password=False, 1196 ) StdinNotImplementedError: raw_input was called, but this frontend does not support input requests.
Last update:
2023-05-11