mcuttler / CoastSat.islands

Satellite-derived shorelines and 2D planform measurements for islands, extension of the CoastSat toolbox.
GNU General Public License v3.0
22 stars 3 forks source link

Problem in running coastsat #2

Closed Alerovere closed 1 year ago

Alerovere commented 4 years ago

Hi, I can run coastsat with no problems, but once I try to run the default example (jupyter notebook) on coastsat.islands, I run into the following error at the step "Batch contour detection".

Some details on my config: -I updated to Matplotlib 3.3.1, but the error persists. -I copied the coastsat.islands in my coastsat folder, and copied the "classification" folder into the coastsat.islands folder.

Maybe there is another way to "install" the island toolbox.

BTW, this is exceptional work, keep it up!

Error:

Mapping shorelines: S2: 8%

ValueError Traceback (most recent call last)

in 1 get_ipython().run_line_magic('matplotlib', 'qt') ----> 2 output = SDS_islands.extract_sand_poly(metadata, settings) ~\Documents\coastsat\CoastSat\CoastSat.islands\coastsat\SDS_islands.py in extract_sand_poly(metadata, settings) 297 if settings['check_detection_sand_poly']: 298 date = filenames[i][:18] --> 299 skip_image = show_detection_sand_poly(im_ms, cloud_mask, im_labels, im_binary_sand, im_binary_sand_closed,sand_contours, settings, date, satname, regions) 300 # if user decides to skip the image 301 if skip_image: ~\Documents\coastsat\CoastSat\CoastSat.islands\coastsat\SDS_islands.py in show_detection_sand_poly(im_ms, cloud_mask, im_labels, im_binary_sand, im_binary_sand_closed, sand_contours, settings, date, satname, regions) 458 black_line = mlines.Line2D([],[],color='k',linestyle='-', label='shoreline') 459 ax2.legend(handles=[orange_patch,white_patch,blue_patch, black_line], --> 460 loc='bottom right', fontsize=10) 461 ax2.set_title(date, fontweight='bold', fontsize=16) 462 ~\AppData\Local\Continuum\anaconda3\envs\coastsat\lib\site-packages\matplotlib\axes\_axes.py in legend(self, *args, **kwargs) 415 if len(extra_args): 416 raise TypeError('legend only accepts two non-keyword arguments') --> 417 self.legend_ = mlegend.Legend(self, handles, labels, **kwargs) 418 self.legend_._remove_method = self._remove_legend 419 return self.legend_ ~\AppData\Local\Continuum\anaconda3\envs\coastsat\lib\site-packages\matplotlib\legend.py in __init__(self, parent, handles, labels, loc, numpoints, markerscale, markerfirst, scatterpoints, scatteryoffsets, prop, fontsize, labelcolor, borderpad, labelspacing, handlelength, handleheight, handletextpad, borderaxespad, columnspacing, ncol, mode, fancybox, shadow, title, title_fontsize, framealpha, edgecolor, facecolor, bbox_to_anchor, bbox_transform, frameon, handler_map) 455 raise ValueError( 456 "Unrecognized location {!r}. Valid locations are\n\t{}\n" --> 457 .format(loc, '\n\t'.join(self.codes))) 458 else: 459 loc = self.codes[loc] ValueError: Unrecognized location 'bottom right'. Valid locations are best upper right upper left lower left lower right right center left center right lower center upper center center
mcuttler commented 4 years ago

hey @Alerovere, thanks for checking out the CoastSat extension. It looks like it might be a small bug in how we were setting the legend location (lines 459-460 in SDS_islands.py).

can you try editing line 459-460 of SDS_islands.py to : ax2.legend(handles=[orange_patch,white_patch,blue_patch,
black_line], loc='lower right', fontsize=10)

Alerovere commented 4 years ago

Hey, thanks for the quick turnaround. I thought about this, and I had already tried. I get the same error with your code. See here.

Mapping shorelines: S2: 8%

ValueError Traceback (most recent call last)

in 1 get_ipython().run_line_magic('matplotlib', 'qt') ----> 2 output = SDS_islands.extract_sand_poly(metadata, settings) ~\Documents\coastsat\CoastSat.islands\coastsat\SDS_islands.py in extract_sand_poly(metadata, settings) 298 date = filenames[i][:18] 299 skip_image = show_detection_sand_poly(im_ms, cloud_mask, im_labels, im_binary_sand, im_binary_sand_closed, --> 300 sand_contours, settings, date, satname, regions) 301 # if user decides to skip the image 302 if skip_image: ~\Documents\coastsat\CoastSat.islands\coastsat\SDS_islands.py in show_detection_sand_poly(im_ms, cloud_mask, im_labels, im_binary_sand, im_binary_sand_closed, sand_contours, settings, date, satname, regions) 459 black_line = mlines.Line2D([],[],color='k',linestyle='-', label='shoreline') 460 ax2.legend(handles=[orange_patch,white_patch,blue_patch,black_line], loc='lower right', fontsize=10) --> 461 ax2.set_title(date, fontweight='bold', fontsize=16) 462 463 # create image 3 (closed sand polygon) ~\AppData\Local\Continuum\anaconda3\envs\coastsat\lib\site-packages\matplotlib\axes\_axes.py in legend(self, *args, **kwargs) 415 if len(extra_args): 416 raise TypeError('legend only accepts two non-keyword arguments') --> 417 self.legend_ = mlegend.Legend(self, handles, labels, **kwargs) 418 self.legend_._remove_method = self._remove_legend 419 return self.legend_ ~\AppData\Local\Continuum\anaconda3\envs\coastsat\lib\site-packages\matplotlib\legend.py in __init__(self, parent, handles, labels, loc, numpoints, markerscale, markerfirst, scatterpoints, scatteryoffsets, prop, fontsize, labelcolor, borderpad, labelspacing, handlelength, handleheight, handletextpad, borderaxespad, columnspacing, ncol, mode, fancybox, shadow, title, title_fontsize, framealpha, edgecolor, facecolor, bbox_to_anchor, bbox_transform, frameon, handler_map) 455 raise ValueError( 456 "Unrecognized location {!r}. Valid locations are\n\t{}\n" --> 457 .format(loc, '\n\t'.join(self.codes))) 458 else: 459 loc = self.codes[loc] ValueError: Unrecognized location 'bottom right'. Valid locations are best upper right upper left lower left lower right right center left center right lower center upper center center
Alerovere commented 4 years ago

Getting rid altogether of the "loc" keyword works fine.

mcuttler commented 4 years ago

great! i was just typing that as another suggestion

I will leave this issue open until we have modified the notebook and example .py script

kvos commented 4 years ago

hey @Alerovere, I think in the new version of matplotlib "bottom right" has been replaced with "lower right" and that's why it's throwing an error. @mcuttler the best solution here would be to change it to loc=4 so that it works with the new and older versions of matplotlib. image

Ayowande04 commented 2 years ago

How can I run coassat library in Rstudio