jeffreyhanson / global-protected-areas

Automatically download and clean global protected area data
GNU General Public License v3.0
10 stars 5 forks source link

`pip is not installed` error after apparently successful installation #2

Closed rasenior closed 4 years ago

rasenior commented 4 years ago

Thanks first of all for all these amazing tools to download and clean the WDPA.

To give the full background to my problem, I am trying to download and clean the global WDPA for some analyses in Google Earth Engine (the version available on GEE also seems to suffer from the various issues within WDPA). Mainly I need to calculate the proportion of species' ranges that are contained within PAs.

Initially I tried wdpar in R, and ran into various problems similar to this issue: https://github.com/prioritizr/wdpar/issues/16. Based on your recommendation there, I switched to trying https://github.com/jeffreyhanson/global-protected-areas.

I followed your instructions in the README and in INSTALL.md, but then when I try run.bat I get the error pip is not installed. Please see INSTALL.md.

I don't know what I've done wrong here, because I downloaded and ran https://bootstrap.pypa.io/get-pip.py and it seemed to install correctly:

RESTART: C:\Users\rsenior\Documents\global-protected-areas-master\get-pip.py DEPRECATION: Python 2.7 will reach the end of its life on January 1st, 2020. Please upgrade your Python as Python 2.7 won't be maintained after that date. A future version of pip will drop support for Python 2.7. More details about Python 2 support in pip, can be found at https://pip.pypa.io/en/latest/development/release-process/#python-2-support Collecting pip Using cached https://files.pythonhosted.org/packages/00/b6/9cfa56b4081ad13874b0c6f96af8ce16cfbc1cb06bedf8e9164ce5551ec1/pip-19.3.1-py2.py3-none-any.whl Installing collected packages: pip Found existing installation: pip 19.3.1 Uninstalling pip-19.3.1: Successfully uninstalled pip-19.3.1 Successfully installed pip-19.3.1

I have also added the Scripts folder to the PATH (C:\Python27\ArcGIS10.7\Scripts).

I guess something is wrong with where pip is installed versus which Python version is being used? Or something like that? My setup is a bit complicated I think because the Python version in my PATH is the one installed with ArcGIS, for which I have also set up a conda environment. Then I have another conda environment for using with the GEE Python API. And both environments already have pip installed as well.

Do I need to maybe run the Python scripts within my conda environment? Sorry if this is unclear, I'm not sure what information would be most useful to you to help me figure out the problem. Thanks in advance!

jeffreyhanson commented 4 years ago

Hmm, it might be that the code for checking if pip is installed isn't working correctly. Can you access pip from the command line? What happens if you enter the command pip --version?

If that works, then could you please try running the command make all in the command prompt with the working directory set to the global-protected-areas directory? This will bypass the potentially faulty installation checks in the .bat file.

rasenior commented 4 years ago

Ok looks like pip was installed correctly, and the version pops up no problem when I run pip --version.

Running make all does work in that the files downloaded and the cleaning process began. However I then had some new errors - first a good old error 999999 on RepairGeometry, and then Out of Memory error 000426 on SimplifyPolygon. Not sure how to deal with those. Maybe I need to split the data & run separately?

Full output here:

C:\Users\rsenior\Documents\global-protected-areas-master>make all downloading data 100% [....................................................................] 1359539595 / 1359539595extracting polygon data repairing polygon data Traceback (most recent call last): File "code/python/repair-geometry.py", line 18, in arcpy.RepairGeometry_management(sys.argv[1]) File "C:\Program Files (x86)\ArcGIS\Desktop10.7\ArcPy\arcpy\management.py", line 3049, in RepairGeometry raise e arcgisscripting.ExecuteError: ERROR 999999: Error executing function. Failed to execute (RepairGeometry).

make: *** [Makefile:143: data/intermediate/1/WDPA_shapefile_polygons.gdb] Error 1

C:\Users\rsenior\Documents\global-protected-areas-master>make all omitting invalid areas from polygon data reprojecting polygon data to output coordinate system simplifying polygon data Traceback (most recent call last): File "code/python/simplify.py", line 22, in simplify_params['error_option'], simplify_params['collapsed_point_option'] File "C:\Program Files (x86)\ArcGIS\Desktop10.7\ArcPy\arcpy\cartography.py", line 1564, in SimplifyPolygon raise e arcgisscripting.ExecuteError: ERROR 000426: Out Of Memory Failed to execute (SimplifyPolygon).

make: *** [Makefile:90: data/intermediate/4/WDPA_shapefile_polygons.gdb] Error 1

jeffreyhanson commented 4 years ago

Ok, I'm sorry I don't know if I can be much more help. I haven't encountered those errors before when running the code. Is it possible the issue with the repair geometry tool is because I'm running an earlier version of ArcMap (version 10.3)? Also, could the out of memory error be due to differences in the amount of RAM on our systems (my system 16 GB RAM)? In terms of addressing these issue, if you manually open the data in the global-protected-areas/intermediate/1 folder, you can manually inspect the WDPA data in the geodatabase and rerun the repair geometry tool in ArcMap. After that, you could delete the subsequent intermediate directories (i.e. folders named 2 and greater) and try running make all again and see if that fixes it?

rasenior commented 4 years ago

Thanks for your help and suggestions. To update, I have no idea why SimplifyPolygon kept running into the out of memory error (I also have 16 GB RAM), but I did manage to simplify the polygons in R instead. From there I manually went through each line in Makefile, with two additional but fixable problems:

  1. Dissolve would not work initially because of invalid geometries, so inside the for loop of dissolve_each.py I again had to run RepairGeometry, prior to the dissolve
  2. Within remove_slivers.py, Eliminate would throw an error 999998. As suggested here, it runs successfully if run in the foreground of ArcMap

Everything else worked perfectly, and I've been able to complete all the steps. Hooray!