Skip to content

Instantly share code, notes, and snippets.

View geogradient's full-sized avatar

Jose Beltran geogradient

  • Stockholm University
  • Sweden
View GitHub Profile
@geogradient
geogradient / gist_beam_utils.py
Last active August 29, 2015 14:07
Builds BEAM-VISAT pin files as a batch process. Outputs "pin_sampling_date_batched.placemark" files using an input table/pandas data frame with the details of the sampling locations.
def create_pin_files(data_frame, outdir = '/outdir/path/only/' ):
"""
Batch process the creation of BEAM-VISAT (http://www.brockmann-consult.de/cms/web/beam/) pin files.
Outputs a "pin_sampling_date_batched.placemark" file.
Uses pandas data_frame as input.
Expected column names in the input data frame are:
["IS_DATE"] YYYYMMDD format
["SITE"] Name of the Placemark, ie. station, sampling site or Cast ID
["Latitude"] Latitude of Placemark in decimal degrees using WGS84 datum
["Longitude"] Longitude of Placemark in decimal degrees using WGS84 datum
@geogradient
geogradient / gist: files_per_week_per_year.py
Last active August 29, 2015 14:04
get the number of images that per week per year loading from a json file in order to tabulate per week and year later on
#!/usr/bin/env python
# -*- coding: utf-8 -*-
__author__ = "[José M. Beltrán](<beltran.data@gmail.com>)"
__credits__ = ["José M. Beltrán"]
__license__ = "GPL-3.0"
"""
The json file has the following scheme:
{"20020614":{"KEY1":{"KEY1.1":"path_to_file_01", ...},
@urschrei
urschrei / shapefile.py
Last active September 29, 2021 08:24
Open a shapefile using Fiona, and plot its features using Matplotlib and Descartes
import matplotlib.pyplot as plt
from matplotlib.collections import PatchCollection
from descartes import PolygonPatch
import fiona
from shapely.geometry import Polygon, MultiPolygon, shape
# We can extract the London Borough boundaries by filtering on the AREA_CODE key
mp = MultiPolygon(
[shape(pol['geometry']) for pol in fiona.open('data/boroughs/boroughs.shp')
if pol['properties']['AREA_CODE'] == 'LBO'])
@vgoklani
vgoklani / mongodb_drop.py
Created January 3, 2012 18:40
drop a database or collection via pymongo
# dropping a database via pymongo
from pymongo import Connection
c = Connection()
c.drop_database('mydatabase')
# drop a collection via pymongo
from pymongo import Connection
c = Connection()
c['mydatabase'].drop_collection('mycollection')