Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
36 changes: 18 additions & 18 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ import prettymaps
plot = prettymaps.plot('Stad van de Zon, Heerhugowaard, Netherlands')
```

Fetching geodataframes took 13.76 seconds
Fetching geodataframes took 13.61 seconds



Expand All @@ -94,7 +94,7 @@ plot = prettymaps.plot(
)
```

Fetching geodataframes took 4.71 seconds
Fetching geodataframes took 6.24 seconds



Expand Down Expand Up @@ -369,7 +369,7 @@ plot = prettymaps.plot(
)
```

Fetching geodataframes took 28.29 seconds
Fetching geodataframes took 29.71 seconds



Expand All @@ -393,7 +393,7 @@ plot = prettymaps.plot(
)
```

Fetching geodataframes took 10.83 seconds
Fetching geodataframes took 12.37 seconds



Expand All @@ -413,7 +413,7 @@ plot = prettymaps.plot('Centro Histórico, Porto Alegre', show = False)
plot.geodataframes['building']
```

Fetching geodataframes took 11.94 seconds
Fetching geodataframes took 16.02 seconds



Expand Down Expand Up @@ -741,7 +741,7 @@ plot.geodataframes['building'][
].geometry[0]
```

/opt/hostedtoolcache/Python/3.11.12/x64/lib/python3.11/site-packages/geopandas/geoseries.py:648: FutureWarning: Series.__getitem__ treating keys as positions is deprecated. In a future version, integer keys will always be treated as labels (consistent with DataFrame behavior). To access a value by position, use `ser.iloc[pos]`
/opt/hostedtoolcache/Python/3.11.13/x64/lib/python3.11/site-packages/geopandas/geoseries.py:648: FutureWarning: Series.__getitem__ treating keys as positions is deprecated. In a future version, integer keys will always be treated as labels (consistent with DataFrame behavior). To access a value by position, use `ser.iloc[pos]`
val = getattr(super(), mtd)(*args, **kwargs)


Expand Down Expand Up @@ -788,7 +788,7 @@ for ax,building in zip(np.concatenate(axes),buildings):
ax.autoscale(); ax.axis('off'); ax.axis('equal')
```

Fetching geodataframes took 12.50 seconds
Fetching geodataframes took 13.25 seconds



Expand Down Expand Up @@ -819,7 +819,7 @@ _ = plot.ax.set_title(
)
```

Fetching geodataframes took 12.74 seconds
Fetching geodataframes took 13.47 seconds


Use **plotter** mode to export a pen plotter-compatible SVG (thanks to abey79's amazing [vsketch](https://github.com/abey79/vsketch) library)
Expand All @@ -838,7 +838,7 @@ plot = prettymaps.plot(
)
```

Fetching geodataframes took 3.91 seconds
Fetching geodataframes took 4.21 seconds



Expand All @@ -862,7 +862,7 @@ plot = prettymaps.plot(
)
```

Fetching geodataframes took 26.94 seconds
Fetching geodataframes took 29.60 seconds



Expand Down Expand Up @@ -963,13 +963,13 @@ plot = prettymaps.multiplot(
)
```

Fetching geodataframes took 8.62 seconds
Fetching geodataframes took 8.72 seconds


Fetching geodataframes took 5.93 seconds
Fetching geodataframes took 7.96 seconds


Fetching geodataframes took 8.74 seconds
Fetching geodataframes took 8.96 seconds



Expand Down Expand Up @@ -997,7 +997,7 @@ plot = prettymaps.plot(
)
```

Fetching geodataframes took 47.61 seconds
Fetching geodataframes took 49.74 seconds


make: Entering directory '/home/runner/work/prettymaps/prettymaps/notebooks/SRTM1'
Expand All @@ -1014,11 +1014,11 @@ plot = prettymaps.plot(
gdalbuildvrt -q -overwrite SRTM1.vrt cache/N21/N21W158.tif
make: Leaving directory '/home/runner/work/prettymaps/prettymaps/notebooks/SRTM1'
make: Entering directory '/home/runner/work/prettymaps/prettymaps/notebooks/SRTM1'
cp SRTM1.vrt SRTM1.286507e05dd14c97a364976914d44158.vrt
cp SRTM1.vrt SRTM1.cccd6d23120f43349362779587d61590.vrt
make: Leaving directory '/home/runner/work/prettymaps/prettymaps/notebooks/SRTM1'
make: Entering directory '/home/runner/work/prettymaps/prettymaps/notebooks/SRTM1'
gdal_translate -q -co TILED=YES -co COMPRESS=DEFLATE -co ZLEVEL=9 -co PREDICTOR=2 -projwin -157.90125854957773 21.364471426268267 -157.81006761682832 21.244615177105388 SRTM1.286507e05dd14c97a364976914d44158.vrt /home/runner/work/prettymaps/prettymaps/notebooks/elevation.tif
rm -f SRTM1.286507e05dd14c97a364976914d44158.vrt
gdal_translate -q -co TILED=YES -co COMPRESS=DEFLATE -co ZLEVEL=9 -co PREDICTOR=2 -projwin -157.90125854957773 21.364471426268267 -157.81006761682832 21.244615177105388 SRTM1.cccd6d23120f43349362779587d61590.vrt /home/runner/work/prettymaps/prettymaps/notebooks/elevation.tif
rm -f SRTM1.cccd6d23120f43349362779587d61590.vrt
make: Leaving directory '/home/runner/work/prettymaps/prettymaps/notebooks/SRTM1'


Expand Down Expand Up @@ -1052,7 +1052,7 @@ plot = prettymaps.plot(
)
```

Fetching geodataframes took 18.23 seconds
Fetching geodataframes took 21.24 seconds



Expand Down
72 changes: 52 additions & 20 deletions app.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,16 @@
import os
import io


def download_svg():
"""
Creates additional map in SVG format
"""
fig_path = "/tmp/generated_map_download.svg"
plt.savefig(fig_path, format="svg", bbox_inches="tight", dpi=150)
return fig_path


# Set Streamlit to use the wide layout
st.set_page_config(layout="wide")

Expand Down Expand Up @@ -65,8 +75,10 @@
page_size_col, dpi_col = st.columns(2)
with page_size_col:
page_size = st.selectbox(
"Page Size", ["A4", "A5", "Square"], index = 0
#, "A3", "A2", "A1", "Custom"], index=0
"Page Size",
["A4", "A5", "Square"],
index=0,
# , "A3", "A2", "A1", "Custom"], index=0
)
with dpi_col:
dpi = st.number_input("DPI", min_value=50, max_value=300, value=100, step=50)
Expand Down Expand Up @@ -130,7 +142,7 @@
use_container_width=True,
)

if button: # or "last_image" in st.session_state:
if button:
hillshade_params = (
{
"azdeg": azdeg,
Expand Down Expand Up @@ -166,23 +178,43 @@
with open(fig_path, "wb") as f:
f.write(st.session_state.last_image.getbuffer())

# Provide a download button
with open(fig_path, "rb") as file:
btn = st.download_button(
label="Download Map",
data=file,
file_name=f"{query}.png",
mime="image/png",
use_container_width=True,
)
# Save SVG for persistent download
svg_path = download_svg()
st.session_state.last_png_path = fig_path
st.session_state.last_svg_path = svg_path

st.image(st.session_state.last_image, use_container_width=True)
# Always show download buttons (disabled if no image)
png_ready = "last_png_path" in st.session_state and os.path.exists(
st.session_state["last_png_path"]
)
svg_ready = "last_svg_path" in st.session_state and os.path.exists(
st.session_state["last_svg_path"]
)
btn_cols = st.columns(2)
with btn_cols[0]:
st.download_button(
label="Download PNG",
data=open(st.session_state["last_png_path"], "rb") if png_ready else b"",
file_name=f"{query}.png",
mime="image/png",
use_container_width=True,
disabled=not png_ready,
)
with btn_cols[1]:
st.download_button(
label="Download SVG",
data=open(st.session_state["last_svg_path"], "rb") if svg_ready else b"",
file_name=f"{query}.svg",
mime="image/svg",
use_container_width=True,
disabled=not svg_ready,
)

# Always show image (generated or placeholder)
if st.session_state.get("last_image"):
st.image(st.session_state.last_image, use_container_width=True)
else:
if st.session_state.last_image:
st.image(st.session_state.last_image, use_container_width=True)
else:
st.image(
"https://github.com/marceloprates/prettymaps/blob/main/prints/app_placeholder.png?raw=true",
use_container_width=True,
)
st.image(
"https://github.com/marceloprates/prettymaps/blob/main/pictures/app_placeholder.png?raw=true",
use_container_width=True,
)
184 changes: 92 additions & 92 deletions notebooks/examples.ipynb

Large diffs are not rendered by default.

Binary file modified pictures/README/temp_readme_files/temp_readme_15_1.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified pictures/README/temp_readme_files/temp_readme_17_1.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified pictures/README/temp_readme_files/temp_readme_27_1.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified pictures/README/temp_readme_files/temp_readme_29_1.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified pictures/README/temp_readme_files/temp_readme_33_3.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified pictures/README/temp_readme_files/temp_readme_35_5.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified pictures/README/temp_readme_files/temp_readme_37_1.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified pictures/README/temp_readme_files/temp_readme_7_1.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified pictures/README/temp_readme_files/temp_readme_9_1.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added pictures/app_placeholder.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.