From 6bc6e2ffe756619c86b0fa2be472262496556bc8 Mon Sep 17 00:00:00 2001 From: Abdul Date: Wed, 4 Aug 2021 08:03:59 -0400 Subject: [PATCH 1/5] add vscode color setting --- .gitignore | 3 +-- .vscode/settings.json | 3 +++ 2 files changed, 4 insertions(+), 2 deletions(-) create mode 100644 .vscode/settings.json diff --git a/.gitignore b/.gitignore index d0fb421..72a49d1 100644 --- a/.gitignore +++ b/.gitignore @@ -1,5 +1,4 @@ -# vs code files -.vscode/settings.json + # .pyc files *.pyc diff --git a/.vscode/settings.json b/.vscode/settings.json new file mode 100644 index 0000000..ff45a1a --- /dev/null +++ b/.vscode/settings.json @@ -0,0 +1,3 @@ +{ + "workbench.colorTheme": "Solarized Dark" +} \ No newline at end of file From 7af4d7617b1bfa410e8dc99873911cbe46e59dfc Mon Sep 17 00:00:00 2001 From: Abdul Date: Wed, 4 Aug 2021 08:17:04 -0400 Subject: [PATCH 2/5] change NLCD to 2019, update metadata for v 1.3 --- README.md | 8 ++++---- README.txt | 8 ++++---- __init__.py | 2 +- curve_number_generator.py | 2 +- curve_number_generator_algorithm.py | 20 ++++++++++---------- curve_number_generator_provider.py | 2 +- metadata.txt | 9 ++++----- 7 files changed, 25 insertions(+), 26 deletions(-) diff --git a/README.md b/README.md index 40c24b9..f994490 100644 --- a/README.md +++ b/README.md @@ -20,13 +20,13 @@ This algorithm generates Curve Number layer for the given Area of Interest withi ## Outputs - NLCD Land Cover Vector: - NLCD 2016 Land Cover Dataset Vectorized + NLCD 2019 Land Cover Dataset Vectorized - NLCD Land Cover Raster: - NLCD 2016 Land Cover Dataset + NLCD 2019 Land Cover Dataset - NLCD Impervious Surface Raster: - NLCD 2016 Impervious Surface Dataset + NLCD 2019 Impervious Surface Dataset - Soil Layer: SSURGO Extended Soil Dataset @@ -38,7 +38,7 @@ This algorithm generates Curve Number layer for the given Area of Interest withi Algorithm author: Abdul Raheem Siddiqui Help author: Abdul Raheem Siddiqui -Algorithm version: 1.2 +Algorithm version: 1.3 Contact email: ars.work.ce@gmail.com Disclaimer: The curve number generated with this algorithm is a high level estimate and should not be used for detailed modeling or construction projects. diff --git a/README.txt b/README.txt index 602e6c2..0abd303 100644 --- a/README.txt +++ b/README.txt @@ -18,13 +18,13 @@ Certain Soils are categorized as dual category in SSURGO dataset. They have Hydr Outputs NLCD Land Cover Raster -NLCD 2016 Land Cover Dataset +NLCD 2019 Land Cover Dataset NLCD Land Cover Vector -NLCD 2016 Land Cover Dataset Vectorized +NLCD 2019 Land Cover Dataset Vectorized NLCD Impervious Surface Raster -NLCD 2016 Impervious Surface Dataset +NLCD 2019 Impervious Surface Dataset Soil Layer SSURGO Extended Soil Dataset @@ -35,6 +35,6 @@ Generated Curve Number Layer based on Land Cover and HSG values. Algorithm author: Abdul Raheem Siddiqui Help author: Abdul Raheem Siddiqui -Algorithm version: 1.2 +Algorithm version: 1.3 Contact email: ars.work.ce@gmail.com Disclaimer: The curve number generated with this algorithm is a high level estimate and should not be used for detailed modeling or construction projects. diff --git a/__init__.py b/__init__.py index 84b34e1..5d37767 100644 --- a/__init__.py +++ b/__init__.py @@ -23,7 +23,7 @@ """ __author__ = "Abdul Raheem Siddiqui" -__date__ = "2021-06-19" +__date__ = "2021-08-04" __copyright__ = "(C) 2021 by Abdul Raheem Siddiqui" diff --git a/curve_number_generator.py b/curve_number_generator.py index 7aa13cf..a9922c5 100644 --- a/curve_number_generator.py +++ b/curve_number_generator.py @@ -23,7 +23,7 @@ """ __author__ = "Abdul Raheem Siddiqui" -__date__ = "2021-06-19" +__date__ = "2021-08-04" __copyright__ = "(C) 2021 by Abdul Raheem Siddiqui" # This will get replaced with a git SHA1 when you do a git archive diff --git a/curve_number_generator_algorithm.py b/curve_number_generator_algorithm.py index 737ffdf..1b76562 100644 --- a/curve_number_generator_algorithm.py +++ b/curve_number_generator_algorithm.py @@ -62,14 +62,14 @@ ) __author__ = "Abdul Raheem Siddiqui" -__date__ = "2021-06-19" +__date__ = "2021-08-04" __copyright__ = "(C) 2021 by Abdul Raheem Siddiqui" # This will get replaced with a git SHA1 when you do a git archive __revision__ = "$Format:%H$" -curr_version = "1.2" +curr_version = "1.3" class CurveNumberGeneratorAlgorithm(QgsProcessingAlgorithm): @@ -252,11 +252,11 @@ def processAlgorithm(self, parameters, context, model_feedback): # NLCD Impervious Raster if nlcd_rast_imp_output == True: - request_URL = f"https://www.mrlc.gov/geoserver/mrlc_display/NLCD_2016_Impervious_L48/ows?version=1.3.0&service=WMS&layers=NLCD_2016_Impervious_L48&styles&crs={str(EPSGCode)}&format=image/geotiff&request=GetMap&width={str(BBOX_width_int)}&height={str(BBOX_height_int)}&BBOX={str(xmin)},{str(ymin)},{str(xmax)},{str(ymax)}&" + request_URL = f"https://www.mrlc.gov/geoserver/mrlc_display/NLCD_2019_Impervious_L48/ows?version=1.3.0&service=WMS&layers=NLCD_2019_Impervious_L48&styles&crs={str(EPSGCode)}&format=image/geotiff&request=GetMap&width={str(BBOX_width_int)}&height={str(BBOX_height_int)}&BBOX={str(xmin)},{str(ymin)},{str(xmax)},{str(ymax)}&" # Download NLCD Impervious Raster try: - ping_URL = "https://www.mrlc.gov/geoserver/mrlc_display/NLCD_2016_Impervious_L48/ows" + ping_URL = "https://www.mrlc.gov/geoserver/mrlc_display/NLCD_2019_Impervious_L48/ows" r = requests.head(ping_URL, verify=False) r.raise_for_status() @@ -341,11 +341,11 @@ def processAlgorithm(self, parameters, context, model_feedback): or nlcd_vect_output == True or nlcd_rast_output == True ): - request_URL = f"https://www.mrlc.gov/geoserver/mrlc_display/NLCD_2016_Land_Cover_L48/ows?version=1.3.0&service=WMS&layers=NLCD_2016_Land_Cover_L48&styles&crs={str(EPSGCode)}&format=image/geotiff&request=GetMap&width={str(BBOX_width_int)}&height={str(BBOX_height_int)}&BBOX={str(xmin)},{str(ymin)},{str(xmax)},{str(ymax)}&" + request_URL = f"https://www.mrlc.gov/geoserver/mrlc_display/NLCD_2019_Land_Cover_L48/ows?version=1.3.0&service=WMS&layers=NLCD_2019_Land_Cover_L48&styles&crs={str(EPSGCode)}&format=image/geotiff&request=GetMap&width={str(BBOX_width_int)}&height={str(BBOX_height_int)}&BBOX={str(xmin)},{str(ymin)},{str(xmax)},{str(ymax)}&" # Download NLCD try: - ping_URL = "https://www.mrlc.gov/geoserver/mrlc_display/NLCD_2016_Land_Cover_L48/ows" + ping_URL = "https://www.mrlc.gov/geoserver/mrlc_display/NLCD_2019_Land_Cover_L48/ows" r = requests.head(ping_URL, verify=False) r.raise_for_status() @@ -1100,16 +1100,16 @@ def shortHelpString(self): If checked the algorithm will assume HSG A/B/C for each dual category soil.

Outputs

NLCD Land Cover Vector

-

NLCD 2016 Land Cover Dataset Vectorized

+

NLCD 2019 Land Cover Dataset Vectorized

NLCD Land Cover Raster

-

NLCD 2016 Land Cover Dataset

+

NLCD 2019 Land Cover Dataset

NLCD Impervious Surface Raster

-

NLCD 2016 Impervious Surface Dataset

+

NLCD 2019 Impervious Surface Dataset

Soil Layer

SSURGO Extended Soil Dataset

Curve Number Layer

Generated Curve Number Layer based on Land Cover and HSG values.

-

Algorithm author: Abdul Raheem Siddiqui

Help author: Abdul Raheem Siddiqui

Algorithm version: 1.2

Contact email: ars.work.ce@gmail.com

Disclaimer: The curve numbers generated with this algorithm are high level estimates and should be reviewed in detail before being used for detailed modeling or construction projects.

""" +

Algorithm author: Abdul Raheem Siddiqui

Help author: Abdul Raheem Siddiqui

Algorithm version: 1.3

Contact email: ars.work.ce@gmail.com

Disclaimer: The curve numbers generated with this algorithm are high level estimates and should be reviewed in detail before being used for detailed modeling or construction projects.

""" def helpUrl(self): return "mailto:ars.work.ce@gmail.com" diff --git a/curve_number_generator_provider.py b/curve_number_generator_provider.py index f2a9db6..251860e 100644 --- a/curve_number_generator_provider.py +++ b/curve_number_generator_provider.py @@ -23,7 +23,7 @@ """ __author__ = "Abdul Raheem Siddiqui" -__date__ = "2021-06-19" +__date__ = "2021-08-04" __copyright__ = "(C) 2021 by Abdul Raheem Siddiqui" # This will get replaced with a git SHA1 when you do a git archive diff --git a/metadata.txt b/metadata.txt index 0074bb5..48bb767 100644 --- a/metadata.txt +++ b/metadata.txt @@ -6,7 +6,7 @@ name=Curve Number Generator qgisMinimumVersion=3.6 description=This plugin generates a Curve Number layer for the given Area of Interest within the contiguous United States. It can also download Soil, Land Cover, and Impervious Surface datasets for the same area. -version=1.2 +version=1.3 author=Abdul Raheem Siddiqui email=ars.work.ce@gmail.com @@ -21,10 +21,9 @@ repository=https://github.com/ar-siddiqui/curve_number_generator hasProcessingProvider=yes # Uncomment the following line and add your changelog: -changelog= Version 1.2 - 2021-06-19 - - Return layers in CRS of input layer - - Check for the availability of the latest version of the plugin - - Fix error in default CN lookup table +changelog= Version 1.3 - 2021-08-04 + - Change NLCD LU to 2019 + - Change NLCD Impervious Raster to 2019 # Tags are comma separated with spaces allowed From a39c4728e63cc0495710e1e27bf6dd42777541d3 Mon Sep 17 00:00:00 2001 From: Abdul Date: Wed, 4 Aug 2021 08:20:52 -0400 Subject: [PATCH 3/5] add video tutorials to help --- curve_number_generator_algorithm.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/curve_number_generator_algorithm.py b/curve_number_generator_algorithm.py index 1b76562..33190f1 100644 --- a/curve_number_generator_algorithm.py +++ b/curve_number_generator_algorithm.py @@ -1085,7 +1085,8 @@ def icon(self): return icon def shortHelpString(self): - return """

Algorithm description

+ return """Video Tutorials +

Algorithm description

This algorithm generates Curve Number layer for the given Area of Interest within the contiguous United States. It can also download Soil, Land Cover, and Impervious Surface datasets for the same area.

Input parameters

Area Boundary

From 61431914e13ebe221fb44bdc7011822784912b7f Mon Sep 17 00:00:00 2001 From: Abdul Date: Wed, 4 Aug 2021 09:08:21 -0400 Subject: [PATCH 4/5] move usage log outside. --- curve_number_generator_algorithm.py | 28 +++++++++++++++++++++------- usage_counter.log | 1 - 2 files changed, 21 insertions(+), 8 deletions(-) delete mode 100644 usage_counter.log diff --git a/curve_number_generator_algorithm.py b/curve_number_generator_algorithm.py index 33190f1..fae1a31 100644 --- a/curve_number_generator_algorithm.py +++ b/curve_number_generator_algorithm.py @@ -30,6 +30,7 @@ from qgis.PyQt.QtGui import QIcon from qgis.PyQt.QtCore import QCoreApplication, QVariant from qgis.core import ( + QgsApplication, QgsProcessing, QgsProcessingAlgorithm, QgsProcessingParameterFeatureSource, @@ -54,6 +55,8 @@ cmd_folder = os.path.split(inspect.getfile(inspect.currentframe()))[0] sys.path.append(cmd_folder) +qgis_settings_path = QgsApplication.qgisSettingsDirPath().replace("\\", "/") +cn_log_path = os.path.join(qgis_settings_path, "curve_number_generator.log") from cust_functions import ( check_crs_acceptable, @@ -141,13 +144,24 @@ def initAlgorithm(self, config=None): ) ) - # read usage - with open(os.path.join(cmd_folder, "usage_counter.log"), "r+") as f: - counter = int(f.readline()) + # read usage to add HTML Output option - # check if counter is milestone - if (counter + 1) % 25 == 0: - self.addOutput(QgsProcessingOutputHtml("Message", "Curve Number Generator")) + try: # try-except because trivial feature + if os.path.exists(cn_log_path): + with open(cn_log_path, "r+") as f: + counter = int(f.readline()) + + # check if counter is milestone + if (counter + 1) % 25 == 0: + self.addOutput( + QgsProcessingOutputHtml("Message", "Curve Number Generator") + ) + + else: # for the first time create file + with open(cn_log_path, "w") as f: + f.write(str(0)) + except: + pass # check if new version is available of the plugin try: # try except because this is not a critical part @@ -1029,7 +1043,7 @@ def processAlgorithm(self, parameters, context, model_feedback): ) # log usage - with open(os.path.join(cmd_folder, "usage_counter.log"), "r+") as f: + with open(cn_log_path, "r+") as f: counter = int(f.readline()) f.seek(0) f.write(str(counter + 1)) diff --git a/usage_counter.log b/usage_counter.log deleted file mode 100644 index c227083..0000000 --- a/usage_counter.log +++ /dev/null @@ -1 +0,0 @@ -0 \ No newline at end of file From 030239836ae8aed665e89063aba83187a3a6ad02 Mon Sep 17 00:00:00 2001 From: Abdul Date: Wed, 4 Aug 2021 09:09:25 -0400 Subject: [PATCH 5/5] remove pylintrc --- pylintrc | 281 ------------------------------------------------------- 1 file changed, 281 deletions(-) delete mode 100644 pylintrc diff --git a/pylintrc b/pylintrc deleted file mode 100644 index 7e168f6..0000000 --- a/pylintrc +++ /dev/null @@ -1,281 +0,0 @@ -[MASTER] - -# Specify a configuration file. -#rcfile= - -# Python code to execute, usually for sys.path manipulation such as -# pygtk.require(). -#init-hook= - -# Profiled execution. -profile=no - -# Add files or directories to the blacklist. They should be base names, not -# paths. -ignore=CVS - -# Pickle collected data for later comparisons. -persistent=yes - -# List of plugins (as comma separated values of python modules names) to load, -# usually to register additional checkers. -load-plugins= - - -[MESSAGES CONTROL] - -# Enable the message, report, category or checker with the given id(s). You can -# either give multiple identifier separated by comma (,) or put this option -# multiple time. See also the "--disable" option for examples. -#enable= - -# Disable the message, report, category or checker with the given id(s). You -# can either give multiple identifiers separated by comma (,) or put this -# option multiple times (only on the command line, not in the configuration -# file where it should appear only once).You can also use "--disable=all" to -# disable everything first and then reenable specific checks. For example, if -# you want to run only the similarities checker, you can use "--disable=all -# --enable=similarities". If you want to run only the classes checker, but have -# no Warning level messages displayed, use"--disable=all --enable=classes -# --disable=W" -# see http://stackoverflow.com/questions/21487025/pylint-locally-defined-disables-still-give-warnings-how-to-suppress-them -disable=locally-disabled,C0103 - - -[REPORTS] - -# Set the output format. Available formats are text, parseable, colorized, msvs -# (visual studio) and html. You can also give a reporter class, eg -# mypackage.mymodule.MyReporterClass. -output-format=text - -# Put messages in a separate file for each module / package specified on the -# command line instead of printing them on stdout. Reports (if any) will be -# written in a file name "pylint_global.[txt|html]". -files-output=no - -# Tells whether to display a full report or only the messages -reports=yes - -# Python expression which should return a note less than 10 (10 is the highest -# note). You have access to the variables errors warning, statement which -# respectively contain the number of errors / warnings messages and the total -# number of statements analyzed. This is used by the global evaluation report -# (RP0004). -evaluation=10.0 - ((float(5 * error + warning + refactor + convention) / statement) * 10) - -# Add a comment according to your evaluation note. This is used by the global -# evaluation report (RP0004). -comment=no - -# Template used to display messages. This is a python new-style format string -# used to format the message information. See doc for all details -#msg-template= - - -[BASIC] - -# Required attributes for module, separated by a comma -required-attributes= - -# List of builtins function names that should not be used, separated by a comma -bad-functions=map,filter,apply,input - -# Regular expression which should only match correct module names -module-rgx=(([a-z_][a-z0-9_]*)|([A-Z][a-zA-Z0-9]+))$ - -# Regular expression which should only match correct module level names -const-rgx=(([A-Z_][A-Z0-9_]*)|(__.*__))$ - -# Regular expression which should only match correct class names -class-rgx=[A-Z_][a-zA-Z0-9]+$ - -# Regular expression which should only match correct function names -function-rgx=[a-z_][a-z0-9_]{2,30}$ - -# Regular expression which should only match correct method names -method-rgx=[a-z_][a-z0-9_]{2,30}$ - -# Regular expression which should only match correct instance attribute names -attr-rgx=[a-z_][a-z0-9_]{2,30}$ - -# Regular expression which should only match correct argument names -argument-rgx=[a-z_][a-z0-9_]{2,30}$ - -# Regular expression which should only match correct variable names -variable-rgx=[a-z_][a-z0-9_]{2,30}$ - -# Regular expression which should only match correct attribute names in class -# bodies -class-attribute-rgx=([A-Za-z_][A-Za-z0-9_]{2,30}|(__.*__))$ - -# Regular expression which should only match correct list comprehension / -# generator expression variable names -inlinevar-rgx=[A-Za-z_][A-Za-z0-9_]*$ - -# Good variable names which should always be accepted, separated by a comma -good-names=i,j,k,ex,Run,_ - -# Bad variable names which should always be refused, separated by a comma -bad-names=foo,bar,baz,toto,tutu,tata - -# Regular expression which should only match function or class names that do -# not require a docstring. -no-docstring-rgx=__.*__ - -# Minimum line length for functions/classes that require docstrings, shorter -# ones are exempt. -docstring-min-length=-1 - - -[MISCELLANEOUS] - -# List of note tags to take in consideration, separated by a comma. -notes=FIXME,XXX,TODO - - -[TYPECHECK] - -# Tells whether missing members accessed in mixin class should be ignored. A -# mixin class is detected if its name ends with "mixin" (case insensitive). -ignore-mixin-members=yes - -# List of classes names for which member attributes should not be checked -# (useful for classes with attributes dynamically set). -ignored-classes=SQLObject - -# When zope mode is activated, add a predefined set of Zope acquired attributes -# to generated-members. -zope=no - -# List of members which are set dynamically and missed by pylint inference -# system, and so shouldn't trigger E0201 when accessed. Python regular -# expressions are accepted. -generated-members=REQUEST,acl_users,aq_parent - - -[VARIABLES] - -# Tells whether we should check for unused import in __init__ files. -init-import=no - -# A regular expression matching the beginning of the name of dummy variables -# (i.e. not used). -dummy-variables-rgx=_$|dummy - -# List of additional names supposed to be defined in builtins. Remember that -# you should avoid to define new builtins when possible. -additional-builtins= - - -[FORMAT] - -# Maximum number of characters on a single line. -max-line-length=80 - -# Regexp for a line that is allowed to be longer than the limit. -ignore-long-lines=^\s*(# )??$ - -# Allow the body of an if to be on the same line as the test if there is no -# else. -single-line-if-stmt=no - -# List of optional constructs for which whitespace checking is disabled -no-space-check=trailing-comma,dict-separator - -# Maximum number of lines in a module -max-module-lines=1000 - -# String used as indentation unit. This is usually " " (4 spaces) or "\t" (1 -# tab). -indent-string=' ' - - -[SIMILARITIES] - -# Minimum lines number of a similarity. -min-similarity-lines=4 - -# Ignore comments when computing similarities. -ignore-comments=yes - -# Ignore docstrings when computing similarities. -ignore-docstrings=yes - -# Ignore imports when computing similarities. -ignore-imports=no - - -[IMPORTS] - -# Deprecated modules which should not be used, separated by a comma -deprecated-modules=regsub,TERMIOS,Bastion,rexec - -# Create a graph of every (i.e. internal and external) dependencies in the -# given file (report RP0402 must not be disabled) -import-graph= - -# Create a graph of external dependencies in the given file (report RP0402 must -# not be disabled) -ext-import-graph= - -# Create a graph of internal dependencies in the given file (report RP0402 must -# not be disabled) -int-import-graph= - - -[DESIGN] - -# Maximum number of arguments for function / method -max-args=5 - -# Argument names that match this expression will be ignored. Default to name -# with leading underscore -ignored-argument-names=_.* - -# Maximum number of locals for function / method body -max-locals=15 - -# Maximum number of return / yield for function / method body -max-returns=6 - -# Maximum number of branch for function / method body -max-branches=12 - -# Maximum number of statements in function / method body -max-statements=50 - -# Maximum number of parents for a class (see R0901). -max-parents=7 - -# Maximum number of attributes for a class (see R0902). -max-attributes=7 - -# Minimum number of public methods for a class (see R0903). -min-public-methods=2 - -# Maximum number of public methods for a class (see R0904). -max-public-methods=20 - - -[CLASSES] - -# List of interface methods to ignore, separated by a comma. This is used for -# instance to not check methods defines in Zope's Interface base class. -ignore-iface-methods=isImplementedBy,deferred,extends,names,namesAndDescriptions,queryDescriptionFor,getBases,getDescriptionFor,getDoc,getName,getTaggedValue,getTaggedValueTags,isEqualOrExtendedBy,setTaggedValue,isImplementedByInstancesOf,adaptWith,is_implemented_by - -# List of method names used to declare (i.e. assign) instance attributes. -defining-attr-methods=__init__,__new__,setUp - -# List of valid names for the first argument in a class method. -valid-classmethod-first-arg=cls - -# List of valid names for the first argument in a metaclass class method. -valid-metaclass-classmethod-first-arg=mcs - - -[EXCEPTIONS] - -# Exceptions that will emit a warning when being caught. Defaults to -# "Exception" -overgeneral-exceptions=Exception