Skip to main content

A python module for obtaining reduced(min,max,avg) value from netCDF file under a polygon region

Project description


Test Python package
A Python3 module for extracting data from netcdf file under a shapefile region.


pyscissor can be installed using the following commands

$ git clone
$ cd pyscissor
$ python3 install

or using pip

$ pip install

Using pyscissor

import numpy as np
from pyscissor import scissor 

'''<code for reading netcdf and shapefile>'''

pys = scissor(polygon,lats,lons)

weight_grid = pys.get_masked_weight()

# assign mas to variable
var.mask = weight_grid.mask 

# get weighted average
avg = np.average(var,weights=weight_grid)

A detailed use case can be found here


this package contains a script. A command line tool that can be used to quickly extract reduced(min/max/average/weighted average) time-series form netcdf file with shapefile

# with 3d array [data/] generel case
$ -nci='Y=lat;X=lon;T=time;V=tmin;' \
		-sp='ADM2_EN;ADM3_EN' -r=avg -o=test2.csv

# with 4d array [data/]
$ -nci='Y=lat;X=lon;T=time;V=temperature;slicer=[:,0,:,:]' \
		-sfp='ADM2_EN;ADM3_EN' -r=wavg -o=test1.csv


-nc  = netcdf file

-nci = netcdf variable and dimension information
		available options:
		X = x dimension variable name,
		Y = y dimension variable name,
		T = time dimension variable name,
		V = variable name,
		slicer = slicing index for obtaining 3d array [optional]

		note: `slicer` is required if variable has more than three dimension

-sf  = shape file ( can be zipped shapefile, shapefile or geojson )

-sfp = shapefile properties
		only required when shapefile contains multiple records

-r   = reducer, default is average
		Available options: min,max,avg,wavg

-o   = output file name

Causes of Erroneous output

- when shapefile and netcdf file have different projection
- shapefile dosen't fully reside within netcdf bounds 

Project details

Release history Release notifications | RSS feed

This version


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Files for pyscissor, version 1.0
Filename, size File type Python version Upload date Hashes
Filename, size pyscissor-1.0-py3-none-any.whl (11.5 kB) File type Wheel Python version py3 Upload date Hashes View
Filename, size pyscissor-1.0.tar.gz (9.6 kB) File type Source Python version None Upload date Hashes View

Supported by

Pingdom Pingdom Monitoring Google Google Object Storage and Download Analytics Sentry Sentry Error logging AWS AWS Cloud computing DataDog DataDog Monitoring Fastly Fastly CDN DigiCert DigiCert EV certificate StatusPage StatusPage Status page