Skip to content

Commit

Permalink
Allow use of geefcc in sequential and add resample=False to plot
Browse files Browse the repository at this point in the history
  • Loading branch information
ghislainv committed May 31, 2024
1 parent 22c481f commit bad3b33
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 14 deletions.
4 changes: 3 additions & 1 deletion forestatrisk/data/country_download.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,8 @@ def country_download(
``get_fcc()`` from Python package ``geefcc``. For example:
``{"aoi": "MTQ", "buff": 0.08983152841195216 , "years": [2000,
2010, 2020], "source": "tmf", "perc": 75, "tile_size": 1,
"ncpu": None, "output_file": "forest_MTQ.tiff"}``.
"parallel": True, "ncpu": None, "output_file":
"forest_MTQ.tiff"}``.
:param iso3: Country iso code used to download GADM, OSM, SRTM,
and WDPA data. The iso code should correspond to the country
Expand Down Expand Up @@ -80,6 +81,7 @@ def country_download(
source=get_fcc_args.get("source", "tmf"),
perc=get_fcc_args.get("perc", 75),
tile_size=get_fcc_args.get("tile_size", 1),
parallel=get_fcc_args.get("parallel", True),
ncpu=get_fcc_args.get("ncpu", None),
output_file=get_fcc_args.get("output_file", "fcc.tif")
)
Expand Down
3 changes: 2 additions & 1 deletion forestatrisk/plot/niceplot.py
Original file line number Diff line number Diff line change
Expand Up @@ -176,7 +176,8 @@ def nice_plot_prob(
fig = plt.figure(figsize=figsize, dpi=dpi)
plt.subplot(111, projection=projection)
# Raster data
plt.imshow(ov_arr, cmap=color_map, extent=extent, vmin=0.01, vmax=65535)
plt.imshow(ov_arr, cmap=color_map, extent=extent,
vmin=0.01, vmax=65535, resample=False)
if borders is not None:
_plot_layer(borders, symbol="k-", **kwargs)

Expand Down
25 changes: 13 additions & 12 deletions forestatrisk/plot/plot.py
Original file line number Diff line number Diff line change
Expand Up @@ -303,7 +303,7 @@ def fcc(
ax1.set_frame_on(False)
ax1.set_xticks([])
ax1.set_yticks([])
plt.imshow(ov_arr, cmap=color_map, extent=extent)
plt.imshow(ov_arr, cmap=color_map, extent=extent, resample=False)
if borders is not None:
plot_layer(borders, symbol="k-", **kwargs)
plt.axis("off")
Expand All @@ -313,7 +313,7 @@ def fcc(
)
ax1.add_patch(z)
ax2 = plt.subplot(222)
plt.imshow(ov_arr, cmap=color_map, extent=extent)
plt.imshow(ov_arr, cmap=color_map, extent=extent, resample=False)
plt.xlim(zoom[0], zoom[1])
plt.ylim(zoom[2], zoom[3])
ax2.set_xticks([])
Expand Down Expand Up @@ -421,7 +421,7 @@ def fcc12345(
ax1.set_frame_on(False)
ax1.set_xticks([])
ax1.set_yticks([])
plt.imshow(ov_arr, cmap=color_map, extent=extent)
plt.imshow(ov_arr, cmap=color_map, extent=extent, resample=False)
if borders is not None:
plot_layer(borders, symbol="k-", **kwargs)
plt.axis("off")
Expand All @@ -431,7 +431,7 @@ def fcc12345(
)
ax1.add_patch(z)
ax2 = plt.subplot(222)
plt.imshow(ov_arr, cmap=color_map, extent=extent)
plt.imshow(ov_arr, cmap=color_map, extent=extent, resample=False)
plt.xlim(zoom[0], zoom[1])
plt.ylim(zoom[2], zoom[3])
ax2.set_xticks([])
Expand Down Expand Up @@ -533,7 +533,7 @@ def fcc123(
ax1.set_frame_on(False)
ax1.set_xticks([])
ax1.set_yticks([])
plt.imshow(ov_arr, cmap=color_map, extent=extent)
plt.imshow(ov_arr, cmap=color_map, extent=extent, resample=False)
if borders is not None:
plot_layer(borders, symbol="k-", **kwargs)
plt.axis("off")
Expand All @@ -543,7 +543,7 @@ def fcc123(
)
ax1.add_patch(z)
ax2 = plt.subplot(222)
plt.imshow(ov_arr, cmap=color_map, extent=extent)
plt.imshow(ov_arr, cmap=color_map, extent=extent, resample=False)
plt.xlim(zoom[0], zoom[1])
plt.ylim(zoom[2], zoom[3])
ax2.set_xticks([])
Expand Down Expand Up @@ -645,7 +645,7 @@ def forest(
ax1.set_frame_on(False)
ax1.set_xticks([])
ax1.set_yticks([])
plt.imshow(ov_arr, cmap=color_map, extent=extent)
plt.imshow(ov_arr, cmap=color_map, extent=extent, resample=False)
if borders is not None:
plot_layer(borders, symbol="k-", **kwargs)
plt.axis("off")
Expand All @@ -655,7 +655,7 @@ def forest(
)
ax1.add_patch(z)
ax2 = plt.subplot(222)
plt.imshow(ov_arr, cmap=color_map, extent=extent)
plt.imshow(ov_arr, cmap=color_map, extent=extent, resample=False)
plt.xlim(zoom[0], zoom[1])
plt.ylim(zoom[2], zoom[3])
ax2.set_xticks([])
Expand Down Expand Up @@ -758,7 +758,8 @@ def prob(
# Plot raster
fig = plt.figure(figsize=figsize, dpi=dpi)
plt.subplot(111)
plt.imshow(ov_arr, cmap=color_map, extent=extent, vmin=0.01, vmax=65535)
plt.imshow(ov_arr, cmap=color_map, extent=extent,
vmin=0.01, vmax=65535, resample=False)
if borders is not None:
plot_layer(borders, symbol="k-", **kwargs)

Expand Down Expand Up @@ -852,7 +853,7 @@ def obs(
ax1.set_yticks([])
plt.axis("off")
# Raster
plt.imshow(ov_arr, cmap=color_map, extent=extent)
plt.imshow(ov_arr, cmap=color_map, extent=extent, resample=False)
# Points
f = name_forest_var
x_defor = sample[sample[f] == 0]["X"]
Expand Down Expand Up @@ -950,7 +951,7 @@ def differences(
ax1.set_frame_on(False)
ax1.set_xticks([])
ax1.set_yticks([])
plt.imshow(ov_arr, cmap=color_map, extent=extent)
plt.imshow(ov_arr, cmap=color_map, extent=extent, resample=False)
if borders is not None:
plot_layer(borders, symbol="k-", **kwargs)
plt.axis("off")
Expand All @@ -960,7 +961,7 @@ def differences(
)
ax1.add_patch(z)
ax2 = plt.subplot(222)
plt.imshow(ov_arr, cmap=color_map, extent=extent)
plt.imshow(ov_arr, cmap=color_map, extent=extent, resample=False)
plt.xlim(zoom[0], zoom[1])
plt.ylim(zoom[2], zoom[3])
ax2.set_xticks([])
Expand Down

0 comments on commit bad3b33

Please sign in to comment.