Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- # Imports - some of them are nor really needed right now
- import os
- import sys
- import rasterio
- import gdal
- import geopandas
- import numpy as np
- import pandas as pd
- import seaborn as sns
- import matplotlib.pyplot as plt
- from plotly import __version__
- from plotly.offline import download_plotlyjs, init_notebook_mode, plot, iplot
- import cufflinks as cf
- from osgeo import gdal_array
- # For Notebooks
- init_notebook_mode(connected=True)
- # For offline use
- cf.go_offline()
- %matplotlib inline
- import pyrasterframes
- import pyrasterframes.rf_ipython # enables nicer visualizations of pandas DF
- from pyrasterframes.rasterfunctions import (rf_geometry, rf_local_add, rf_dimensions, rf_extent, rf_crs, rf_mk_crs,
- st_geometry, st_reproject, rf_tile)
- import pyspark.sql.functions as F
- ########### The following commented cells are different tryouts that i made in order to read raster data locally
- spark = pyrasterframes.get_spark_session()
- #path = r'D:\TFM\ACF\ACF_NDVI_savgolfix.envi'
- #uri = 'file:///' + path.replace('\\', '/')
- #tryout = os.path.join("D:\\", "TFM", "ACF", "ACF_NDVI_savgolfix.envi")
- #uri = 'gdal:\\' + r'D:\TFM\ACF\ACF_NDVI_savgolfix'
- #uri = r'D:\TFM\ACF\ACF_NDVI_savgolfix.envi'
- uri = r'C:\Users\Miguel\Desktop\Teledeteccion\B02.tif'
- df = spark.read.raster('gdal:/'+ uri, band_indexes=range(250))
- ### The following info might help - problem is df.count() gives 0.
- print(uri)
- # C:\Users\Miguel\Desktop\Teledeteccion\B02.tif
- df.count()
- # 0
- os.path.exists(uri)
- # True
- !gdalinfo {uri}
- '''
- Driver: GTiff/GeoTIFF
- Files: C:\Users\Miguel\Desktop\Teledeteccion\B02.tif
- Size is 1830, 1830
- Coordinate System is:
- PROJCS["WGS 84 / UTM zone 17N",
- GEOGCS["WGS 84",
- DATUM["WGS_1984",
- SPHEROID["WGS 84",6378137,298.257223563,
- AUTHORITY["EPSG","7030"]],
- AUTHORITY["EPSG","6326"]],
- PRIMEM["Greenwich",0,
- AUTHORITY["EPSG","8901"]],
- UNIT["degree",0.0174532925199433,
- AUTHORITY["EPSG","9122"]],
- AUTHORITY["EPSG","4326"]],
- PROJECTION["Transverse_Mercator"],
- PARAMETER["latitude_of_origin",0],
- PARAMETER["central_meridian",-81],
- PARAMETER["scale_factor",0.9996],
- PARAMETER["false_easting",500000],
- PARAMETER["false_northing",0],
- UNIT["metre",1,
- AUTHORITY["EPSG","9001"]],
- AXIS["Easting",EAST],
- AXIS["Northing",NORTH],
- AUTHORITY["EPSG","32617"]]
- Origin = (699960.000000000000000,4300020.000000000000000)
- Pixel Size = (60.000000000000000,-60.000000000000000)
- Metadata:
- AREA_OR_POINT=Area
- Image Structure Metadata:
- COMPRESSION=DEFLATE
- INTERLEAVE=BAND
- Corner Coordinates:
- Upper Left ( 699960.000, 4300020.000) ( 78d41'47.51"W, 38d49'34.61"N)
- Lower Left ( 699960.000, 4190220.000) ( 78d43'39.49"W, 37d50'15.04"N)
- Upper Right ( 809760.000, 4300020.000) ( 77d26' 0.77"W, 38d47'40.30"N)
- Lower Right ( 809760.000, 4190220.000) ( 77d28'53.90"W, 37d48'24.69"N)
- Center ( 754860.000, 4245120.000) ( 78d 5' 5.42"W, 38d19' 4.78"N)
- Band 1 Block=256x256 Type=UInt16, ColorInterp=Gray
- '''
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement