Skip to content

Instantly share code, notes, and snippets.

\documentclass[10pt]{article}
\usepackage{labels}
\usepackage{url}
\newcommand{\brk}{$\cdot$ }
%\LabelGridtrue % Enable this to
\LabelCols=2% Number of columns of labels per page
\LabelRows=6% Number of rows of labels per page
\begin{document}
\numberoflabels=12
Based on [this](http://stackoverflow.com/questions/27905295/how-to-replace-nans-by-preceding-values-in-pandas-dataframe)
ee['company']=ee['company'].fillna(method='ffill')
@nishadhka
nishadhka / RasterReader.py
Created June 1, 2017 17:07
Reading, editing and visualizing Raster tiffs in Python
import rasterio
from numpy import copy, random, arange
import numpy as np
from matplotlib import pyplot
from matplotlib.colors import LinearSegmentedColormap
#Reading
dataset = rasterio.open('raster.tif')
#example raster is from https://daac.ornl.gov/VEGETATION/guides/Decadal_LULC_India.html
data=dataset.read(1)
@nishadhka
nishadhka / AccessBasemapObject.ipynb
Created June 3, 2017 07:44
AccessingtheBasemapObject.ipynb
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@nishadhka
nishadhka / ImageResizingPIL.ipynb
Created June 4, 2017 07:18
AccessingtheBasemapObject.ipynb
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@nishadhka
nishadhka / rastermerege-rasterio,py
Created July 30, 2017 12:05
Raster merge using rasterio
import rasterio.merge
bounds=None
res=None
nodata=None
precision=7
def merge(input1,bounds, res, nodata, precision):
import warnings
warnings.warn("Deprecated; Use rasterio.merge instead", DeprecationWarning)
@nishadhka
nishadhka / listToFionaGeometryDictofPolygon.py
Last active November 21, 2017 09:26
Create fiona geometry dict from the list
from shapely import geometry
ll=(84.945856,23.475927)
ue=(86.505248, 23.871591)
p1 = geometry.Point(ll[0],ll[1])
p2 = geometry.Point(ue[0],ll[1])
p3 = geometry.Point(ue[0],ue[1])
p4 = geometry.Point(ll[0],ue[1])
@nishadhka
nishadhka / GitBranchMerge.ipynb
Created September 20, 2017 06:13
GitBranchMerge.ipynb
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@nishadhka
nishadhka / PandasdToFionaGeometryDictPoint.py
Last active November 21, 2017 11:45
Pandas dataframe into Fiona geometric dictionary of points
import pandas as pd
from shapely.geometry import Point, shape
from geopandas import GeoDataFrame
import fiona
from collections import OrderedDict
# a test to create shape file
df=pd.read_csv('VNP14IMGTDL_NRT_South_Asia_24h.csv')
geometry = [Point(xy) for xy in zip(df.longitude, df.latitude)]
df = GeoDataFrame(df, geometry=geometry)
@nishadhka
nishadhka / Read kml into data frame using python
Created December 17, 2017 12:01
Read kml file into dataframe
from pykml import parser
import pandas as pd
filename='ref1.kml'
with open(filename) as f:
folder = parser.parse(f).getroot().Document.Folder
plnm=[]
cordi=[]
for pm in folder.Placemark: