I hereby claim:
- I am prakharcode on github.
- I am prakharcode (https://keybase.io/prakharcode) on keybase.
- I have a public key ASCrc_Og_FiOO4Itmc2IFtGDs_5eS4LIQk5zg4TTuRnBTgo
To claim this, I am signing this object:
I hereby claim:
To claim this, I am signing this object:
import geopandas as gpd | |
from shapely.geometry import Polygon | |
df = gpd.read_file('/path/to/file') | |
df.geometry = df.geometry.apply(lambda x: Polygon([[i[0], i[1]] for i in x.exterior.coords])) |
def calc_poi_avg_in_r(poi, entity, radius, **kwargs): | |
entity = entity.copy() | |
KDT = KDTree(poi[['lat', 'long']]) | |
deg_to_m = 1/108000.0 | |
query = entity.progress_apply(lambda g: KDT.query_radius([[g.lat, g.long1]], r= deg_to_m * radius), axis=1) | |
name = kwargs['name'] if kwargs['name'] else 'default' | |
entity.loc[:, f'{name}'] = [ len(x[0]) for x in tqdm(query)] | |
return entity |
def calc_poi_opr_in_radius(poi, entity, radius, **kwargs): | |
entity = entity.copy() | |
KDT = KDTree(poi[['lat', 'long']]) | |
deg_to_m = 1/108000.0 | |
query = entity.progress_apply(lambda g: KDT.query_radius([[g.lat, g.long1]], r= deg_to_m * radius), axis=1) | |
name = kwargs['name'] if kwargs['name'] else 'default' | |
pos_item = list(poi.columns).index(kwargs['avg_by']) | |
col = kwargs['avg_by'] | |
entity.loc[:, kwargs['opr'] + "_" + name] = [ eval("poi.iloc[ x[0], pos_item].{0}()".format(kwargs['opr']), {'poi': poi, 'x':x,'pos_item': pos_item, 'col':col }) if len(x[0]) > 0 else 0 for x in tqdm(query)] | |
return entity |
import rasterio | |
from rasterio import Affine | |
from rasterio.warp import reproject, Resampling | |
with rasterio.open('path/to/band') as src: | |
scale = 2 # scaling amount of data so a scale of 2 would double the pixel size | |
aff = src.transform | |
# adjust the new affine transform to new scale |
band_dict = { | |
""" dictonary containing all the bands that are to be stacked | |
in the following format: | |
band_index : "path/to/band" | |
""" | |
} | |
dst_projection = 'EPSG:4326' # the final projection | |
ref_band = "path/to/ref_band/" # the band that you want as a reference |
cd /etc/apt/
sudo vim sources.list
# paste the following
# QGIS 3 install
deb https://qgis.org/ubuntu-ltr/ bionic main