Merge pull request #135 from marceloprates/pr/Milziade/134
Pr/milziade/134
36
README.md
@@ -71,7 +71,7 @@ import prettymaps
|
|||||||
plot = prettymaps.plot('Stad van de Zon, Heerhugowaard, Netherlands')
|
plot = prettymaps.plot('Stad van de Zon, Heerhugowaard, Netherlands')
|
||||||
```
|
```
|
||||||
|
|
||||||
Fetching geodataframes took 13.76 seconds
|
Fetching geodataframes took 13.61 seconds
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@@ -94,7 +94,7 @@ plot = prettymaps.plot(
|
|||||||
)
|
)
|
||||||
```
|
```
|
||||||
|
|
||||||
Fetching geodataframes took 4.71 seconds
|
Fetching geodataframes took 6.24 seconds
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@@ -369,7 +369,7 @@ plot = prettymaps.plot(
|
|||||||
)
|
)
|
||||||
```
|
```
|
||||||
|
|
||||||
Fetching geodataframes took 28.29 seconds
|
Fetching geodataframes took 29.71 seconds
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@@ -393,7 +393,7 @@ plot = prettymaps.plot(
|
|||||||
)
|
)
|
||||||
```
|
```
|
||||||
|
|
||||||
Fetching geodataframes took 10.83 seconds
|
Fetching geodataframes took 12.37 seconds
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@@ -413,7 +413,7 @@ plot = prettymaps.plot('Centro Histórico, Porto Alegre', show = False)
|
|||||||
plot.geodataframes['building']
|
plot.geodataframes['building']
|
||||||
```
|
```
|
||||||
|
|
||||||
Fetching geodataframes took 11.94 seconds
|
Fetching geodataframes took 16.02 seconds
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@@ -741,7 +741,7 @@ plot.geodataframes['building'][
|
|||||||
].geometry[0]
|
].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)
|
val = getattr(super(), mtd)(*args, **kwargs)
|
||||||
|
|
||||||
|
|
||||||
@@ -788,7 +788,7 @@ for ax,building in zip(np.concatenate(axes),buildings):
|
|||||||
ax.autoscale(); ax.axis('off'); ax.axis('equal')
|
ax.autoscale(); ax.axis('off'); ax.axis('equal')
|
||||||
```
|
```
|
||||||
|
|
||||||
Fetching geodataframes took 12.50 seconds
|
Fetching geodataframes took 13.25 seconds
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@@ -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)
|
Use **plotter** mode to export a pen plotter-compatible SVG (thanks to abey79's amazing [vsketch](https://github.com/abey79/vsketch) library)
|
||||||
@@ -838,7 +838,7 @@ plot = prettymaps.plot(
|
|||||||
)
|
)
|
||||||
```
|
```
|
||||||
|
|
||||||
Fetching geodataframes took 3.91 seconds
|
Fetching geodataframes took 4.21 seconds
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@@ -862,7 +862,7 @@ plot = prettymaps.plot(
|
|||||||
)
|
)
|
||||||
```
|
```
|
||||||
|
|
||||||
Fetching geodataframes took 26.94 seconds
|
Fetching geodataframes took 29.60 seconds
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@@ -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
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@@ -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'
|
make: Entering directory '/home/runner/work/prettymaps/prettymaps/notebooks/SRTM1'
|
||||||
@@ -1014,11 +1014,11 @@ plot = prettymaps.plot(
|
|||||||
gdalbuildvrt -q -overwrite SRTM1.vrt cache/N21/N21W158.tif
|
gdalbuildvrt -q -overwrite SRTM1.vrt cache/N21/N21W158.tif
|
||||||
make: Leaving directory '/home/runner/work/prettymaps/prettymaps/notebooks/SRTM1'
|
make: Leaving directory '/home/runner/work/prettymaps/prettymaps/notebooks/SRTM1'
|
||||||
make: Entering 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: Leaving directory '/home/runner/work/prettymaps/prettymaps/notebooks/SRTM1'
|
||||||
make: Entering 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
|
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.286507e05dd14c97a364976914d44158.vrt
|
rm -f SRTM1.cccd6d23120f43349362779587d61590.vrt
|
||||||
make: Leaving directory '/home/runner/work/prettymaps/prettymaps/notebooks/SRTM1'
|
make: Leaving directory '/home/runner/work/prettymaps/prettymaps/notebooks/SRTM1'
|
||||||
|
|
||||||
|
|
||||||
@@ -1052,7 +1052,7 @@ plot = prettymaps.plot(
|
|||||||
)
|
)
|
||||||
```
|
```
|
||||||
|
|
||||||
Fetching geodataframes took 18.23 seconds
|
Fetching geodataframes took 21.24 seconds
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
56
app.py
@@ -5,6 +5,16 @@ import sys
|
|||||||
import os
|
import os
|
||||||
import io
|
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
|
# Set Streamlit to use the wide layout
|
||||||
st.set_page_config(layout="wide")
|
st.set_page_config(layout="wide")
|
||||||
|
|
||||||
@@ -65,7 +75,9 @@ with cols[0]:
|
|||||||
page_size_col, dpi_col = st.columns(2)
|
page_size_col, dpi_col = st.columns(2)
|
||||||
with page_size_col:
|
with page_size_col:
|
||||||
page_size = st.selectbox(
|
page_size = st.selectbox(
|
||||||
"Page Size", ["A4", "A5", "Square"], index = 0
|
"Page Size",
|
||||||
|
["A4", "A5", "Square"],
|
||||||
|
index=0,
|
||||||
# , "A3", "A2", "A1", "Custom"], index=0
|
# , "A3", "A2", "A1", "Custom"], index=0
|
||||||
)
|
)
|
||||||
with dpi_col:
|
with dpi_col:
|
||||||
@@ -130,7 +142,7 @@ with cols[1]:
|
|||||||
use_container_width=True,
|
use_container_width=True,
|
||||||
)
|
)
|
||||||
|
|
||||||
if button: # or "last_image" in st.session_state:
|
if button:
|
||||||
hillshade_params = (
|
hillshade_params = (
|
||||||
{
|
{
|
||||||
"azdeg": azdeg,
|
"azdeg": azdeg,
|
||||||
@@ -166,23 +178,43 @@ with cols[1]:
|
|||||||
with open(fig_path, "wb") as f:
|
with open(fig_path, "wb") as f:
|
||||||
f.write(st.session_state.last_image.getbuffer())
|
f.write(st.session_state.last_image.getbuffer())
|
||||||
|
|
||||||
# Provide a download button
|
# Save SVG for persistent download
|
||||||
with open(fig_path, "rb") as file:
|
svg_path = download_svg()
|
||||||
btn = st.download_button(
|
st.session_state.last_png_path = fig_path
|
||||||
label="Download Map",
|
st.session_state.last_svg_path = svg_path
|
||||||
data=file,
|
|
||||||
|
# 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",
|
file_name=f"{query}.png",
|
||||||
mime="image/png",
|
mime="image/png",
|
||||||
use_container_width=True,
|
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,
|
||||||
)
|
)
|
||||||
|
|
||||||
st.image(st.session_state.last_image, use_container_width=True)
|
# Always show image (generated or placeholder)
|
||||||
|
if st.session_state.get("last_image"):
|
||||||
else:
|
|
||||||
if st.session_state.last_image:
|
|
||||||
st.image(st.session_state.last_image, use_container_width=True)
|
st.image(st.session_state.last_image, use_container_width=True)
|
||||||
else:
|
else:
|
||||||
st.image(
|
st.image(
|
||||||
"https://github.com/marceloprates/prettymaps/blob/main/prints/app_placeholder.png?raw=true",
|
"https://github.com/marceloprates/prettymaps/blob/main/pictures/app_placeholder.png?raw=true",
|
||||||
use_container_width=True,
|
use_container_width=True,
|
||||||
)
|
)
|
||||||
|
Before Width: | Height: | Size: 3.6 MiB After Width: | Height: | Size: 3.6 MiB |
Before Width: | Height: | Size: 1.1 MiB After Width: | Height: | Size: 1.1 MiB |
Before Width: | Height: | Size: 2.4 MiB After Width: | Height: | Size: 2.4 MiB |
Before Width: | Height: | Size: 1.6 MiB After Width: | Height: | Size: 1.6 MiB |
Before Width: | Height: | Size: 779 KiB After Width: | Height: | Size: 779 KiB |
Before Width: | Height: | Size: 6.2 MiB After Width: | Height: | Size: 6.3 MiB |
Before Width: | Height: | Size: 2.3 MiB After Width: | Height: | Size: 2.3 MiB |
Before Width: | Height: | Size: 2.2 MiB After Width: | Height: | Size: 2.2 MiB |
Before Width: | Height: | Size: 1.1 MiB After Width: | Height: | Size: 1.1 MiB |
BIN
pictures/app_placeholder.png
Normal file
After Width: | Height: | Size: 913 KiB |