Skip to content

Commit

Permalink
Merge pull request #5 from ar-siddiqui/development
Browse files Browse the repository at this point in the history
merge version 0.1 to main for release
  • Loading branch information
ar-siddiqui authored Mar 4, 2021
2 parents d7ee2c0 + 50c123a commit f62b63d
Show file tree
Hide file tree
Showing 34 changed files with 2,876 additions and 2 deletions.
7 changes: 7 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
# pyc files
*.pyc


Table.jpeg
area_weighted_average_algorithm.py
.vscode/settings.json
244 changes: 244 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,244 @@
#/***************************************************************************
# AreaWeightedAverage
#
# Area Area Weighted Average.
# -------------------
# begin : 2021-02-21
# git sha : $Format:%H$
# copyright : (C) 2021 by Abdul Raheem Siddiqui
# email : ars.work.ce@gmail.com
# ***************************************************************************/
#
#/***************************************************************************
# * *
# * This program is free software; you can redistribute it and/or modify *
# * it under the terms of the GNU General Public License as published by *
# * the Free Software Foundation; either version 2 of the License, or *
# * (at your option) any later version. *
# * *
# ***************************************************************************/

#################################################
# Edit the following to match your sources lists
#################################################


#Add iso code for any locales you want to support here (space separated)
# default is no locales
# LOCALES = af
LOCALES =

# If locales are enabled, set the name of the lrelease binary on your system. If
# you have trouble compiling the translations, you may have to specify the full path to
# lrelease
#LRELEASE = lrelease
#LRELEASE = lrelease-qt4


# translation
SOURCES = \
__init__.py \
area_weighted_average.py

PLUGINNAME = area_weighted_average

PY_FILES = \
__init__.py \
area_weighted_average.py

UI_FILES =

EXTRAS = metadata.txt

EXTRA_DIRS =

COMPILED_RESOURCE_FILES =

PEP8EXCLUDE=pydev,resources.py,conf.py,third_party,ui

# QGISDIR points to the location where your plugin should be installed.
# This varies by platform, relative to your HOME directory:
# * Linux:
# .local/share/QGIS/QGIS3/profiles/default/python/plugins/
# * Mac OS X:
# Library/Application Support/QGIS/QGIS3/profiles/default/python/plugins
# * Windows:
# AppData\Roaming\QGIS\QGIS3\profiles\default\python\plugins'

QGISDIR=C:\Users\abdul\AppData/Roaming/QGIS/QGIS3/profiles/default/python/plugins

#################################################
# Normally you would not need to edit below here
#################################################

HELP = help/build/html

PLUGIN_UPLOAD = $(c)/plugin_upload.py

RESOURCE_SRC=$(shell grep '^ *<file' | sed 's@</file>@@g;s/.*>//g' | tr '\n' ' ')

.PHONY: default
default:
@echo While you can use make to build and deploy your plugin, pb_tool
@echo is a much better solution.
@echo A Python script, pb_tool provides platform independent management of
@echo your plugins and runs anywhere.
@echo You can install pb_tool using: pip install pb_tool
@echo See https://g-sherman.github.io/plugin_build_tool/ for info.

compile: $(COMPILED_RESOURCE_FILES)

%.py : %.qrc $(RESOURCES_SRC)
pyrcc5 -o $*.py $<

%.qm : %.ts
$(LRELEASE) $<

test: compile transcompile
@echo
@echo "----------------------"
@echo "Regression Test Suite"
@echo "----------------------"

@# Preceding dash means that make will continue in case of errors
@-export PYTHONPATH=`pwd`:$(PYTHONPATH); \
export QGIS_DEBUG=0; \
export QGIS_LOG_FILE=/dev/null; \
nosetests -v --with-id --with-coverage --cover-package=. \
3>&1 1>&2 2>&3 3>&- || true
@echo "----------------------"
@echo "If you get a 'no module named qgis.core error, try sourcing"
@echo "the helper script we have provided first then run make test."
@echo "e.g. source run-env-linux.sh <path to qgis install>; make test"
@echo "----------------------"

deploy: compile doc transcompile
@echo
@echo "------------------------------------------"
@echo "Deploying plugin to your .qgis2 directory."
@echo "------------------------------------------"
# The deploy target only works on unix like operating system where
# the Python plugin directory is located at:
# $HOME/$(QGISDIR)/python/plugins
mkdir -p $(HOME)/$(QGISDIR)/python/plugins/$(PLUGINNAME)
cp -vf $(PY_FILES) $(HOME)/$(QGISDIR)/python/plugins/$(PLUGINNAME)
cp -vf $(UI_FILES) $(HOME)/$(QGISDIR)/python/plugins/$(PLUGINNAME)
cp -vf $(COMPILED_RESOURCE_FILES) $(HOME)/$(QGISDIR)/python/plugins/$(PLUGINNAME)
cp -vf $(EXTRAS) $(HOME)/$(QGISDIR)/python/plugins/$(PLUGINNAME)
cp -vfr i18n $(HOME)/$(QGISDIR)/python/plugins/$(PLUGINNAME)
cp -vfr $(HELP) $(HOME)/$(QGISDIR)/python/plugins/$(PLUGINNAME)/help
# Copy extra directories if any
(foreach EXTRA_DIR,(EXTRA_DIRS), cp -R (EXTRA_DIR) (HOME)/(QGISDIR)/python/plugins/(PLUGINNAME)/;)


# The dclean target removes compiled python files from plugin directory
# also deletes any .git entry
dclean:
@echo
@echo "-----------------------------------"
@echo "Removing any compiled python files."
@echo "-----------------------------------"
find $(HOME)/$(QGISDIR)/python/plugins/$(PLUGINNAME) -iname "*.pyc" -delete
find $(HOME)/$(QGISDIR)/python/plugins/$(PLUGINNAME) -iname ".git" -prune -exec rm -Rf {} \;


derase:
@echo
@echo "-------------------------"
@echo "Removing deployed plugin."
@echo "-------------------------"
rm -Rf $(HOME)/$(QGISDIR)/python/plugins/$(PLUGINNAME)

zip: deploy dclean
@echo
@echo "---------------------------"
@echo "Creating plugin zip bundle."
@echo "---------------------------"
# The zip target deploys the plugin and creates a zip file with the deployed
# content. You can then upload the zip file on http://plugins.qgis.org
rm -f $(PLUGINNAME).zip
cd $(HOME)/$(QGISDIR)/python/plugins; zip -9r $(CURDIR)/$(PLUGINNAME).zip $(PLUGINNAME)

package: compile
# Create a zip package of the plugin named $(PLUGINNAME).zip.
# This requires use of git (your plugin development directory must be a
# git repository).
# To use, pass a valid commit or tag as follows:
# make package VERSION=Version_0.3.2
@echo
@echo "------------------------------------"
@echo "Exporting plugin to zip package. "
@echo "------------------------------------"
rm -f $(PLUGINNAME).zip
git archive --prefix=$(PLUGINNAME)/ -o $(PLUGINNAME).zip $(VERSION)
echo "Created package: $(PLUGINNAME).zip"

upload: zip
@echo
@echo "-------------------------------------"
@echo "Uploading plugin to QGIS Plugin repo."
@echo "-------------------------------------"
$(PLUGIN_UPLOAD) $(PLUGINNAME).zip

transup:
@echo
@echo "------------------------------------------------"
@echo "Updating translation files with any new strings."
@echo "------------------------------------------------"
@chmod +x scripts/update-strings.sh
@scripts/update-strings.sh $(LOCALES)

transcompile:
@echo
@echo "----------------------------------------"
@echo "Compiled translation files to .qm files."
@echo "----------------------------------------"
@chmod +x scripts/compile-strings.sh
@scripts/compile-strings.sh $(LRELEASE) $(LOCALES)

transclean:
@echo
@echo "------------------------------------"
@echo "Removing compiled translation files."
@echo "------------------------------------"
rm -f i18n/*.qm

clean:
@echo
@echo "------------------------------------"
@echo "Removing uic and rcc generated files"
@echo "------------------------------------"
rm $(COMPILED_UI_FILES) $(COMPILED_RESOURCE_FILES)

doc:
@echo
@echo "------------------------------------"
@echo "Building documentation using sphinx."
@echo "------------------------------------"
cd help; make html

pylint:
@echo
@echo "-----------------"
@echo "Pylint violations"
@echo "-----------------"
@pylint --reports=n --rcfile=pylintrc . || true
@echo
@echo "----------------------"
@echo "If you get a 'no module named qgis.core' error, try sourcing"
@echo "the helper script we have provided first then run make pylint."
@echo "e.g. source run-env-linux.sh <path to qgis install>; make pylint"
@echo "----------------------"


# Run pep8 style checking
#http://pypi.python.org/pypi/pep8
pep8:
@echo
@echo "-----------"
@echo "PEP8 issues"
@echo "-----------"
@pep8 --repeat --ignore=E203,E121,E122,E123,E124,E125,E126,E127,E128 --exclude $(PEP8EXCLUDE) . || true
@echo "-----------"
@echo "Ignored in PEP8 check:"
@echo $(PEP8EXCLUDE)
52 changes: 50 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,2 +1,50 @@
# weighted_average_analysis
Area Weighted Average Analysis. Given an input polygon layer and overlay polygon layer, calculate weighted average of overlay parameters on input layer.
![area weighted average icon](icon.png)

# Area-Weighted-Average
Plugin to perform Area Weighted Average analysis in QGIS.

## Algorithm Description
This algorithm performs spatial area weighted average analysis on an input polygon layer given an attribute in the overlay polygon layer. Each feature in the input layer will be assigned a spatial area weighted average value of the overlay field. A report of the analysis is generated as a GIS Layer and as HTML.

## Input Parameters

- Input Layer:
Polygon layer for which area weighted average will be calculated.

- Overlay Layer:
Polygon layer overlapping the Input Layer.

- Field to Average:
Single numeric field in the Overlay Layer.

- Identifier Field for Report [optional]:
Name or ID field in the Input Layer. This field will be used to identify features in the report.

- Additional Fields to Keep for Report:
Fields in the Overlay Layer that will be included in the reports.

## Outputs

- Result:
Input layer but with the additional attribute of weighted value.

- Report as Layer:
Report as a GIS layer.

- Report as HTML [optional]:
Report containing feature-wise breakdown.

## About

Algorithm author: Abdul Raheem Siddiqui
Help author: Abdul Raheem Siddiqui
Algorithm version: 0.1
Contact email: ars.work.ce@gmail.com

## Donate

<p>If this plugin is useful for you, please consider making a donation of any value to the developer.</p>

<a href="https://www.paypal.com/donate?business=T25JMRWJAL5SQ&item_name=For+Area+Weighted+Average+Plugin&currency_code=USD" target="_blank">
<img border="0" alt="Donate" src="https://www.paypalobjects.com/en_US/i/btn/btn_donateCC_LG.gif">
</a>
40 changes: 40 additions & 0 deletions __init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
# -*- coding: utf-8 -*-
"""
/***************************************************************************
AreaWeightedAverage
A QGIS plugin
Area Area Weighted Average.
Generated by Plugin Builder: http://g-sherman.github.io/Qgis-Plugin-Builder/
-------------------
begin : 2021-02-21
copyright : (C) 2021 by Abdul Raheem Siddiqui
email : ars.work.ce@gmail.com
***************************************************************************/
/***************************************************************************
* *
* This program is free software; you can redistribute it and/or modify *
* it under the terms of the GNU General Public License as published by *
* the Free Software Foundation; either version 2 of the License, or *
* (at your option) any later version. *
* *
***************************************************************************/
This script initializes the plugin, making it known to QGIS.
"""

__author__ = "Abdul Raheem Siddiqui"
__date__ = "2021-02-21"
__copyright__ = "(C) 2021 by Abdul Raheem Siddiqui"


# noinspection PyPep8Naming
def classFactory(iface): # pylint: disable=invalid-name
"""Load AreaWeightedAverage class from file AreaWeightedAverage.
:param iface: A QGIS interface instance.
:type iface: QgsInterface
"""
#
from .area_weighted_average import AreaWeightedAveragePlugin

return AreaWeightedAveragePlugin(iface)
Loading

0 comments on commit f62b63d

Please sign in to comment.