In a rmarkdown document, it can normally show the plot generated by matplotlib
inline.
However, when it comes to the basemap generated by contextily
, there's no inline output:
```{r setup}
library(reticulate)
# conda_create("r-reticulate")
use_condaenv("r-reticulate")
```
```{python}
import contextily as cx
import geopandas
import rasterio
from rasterio.plot import show as rioshow
import matplotlib.pyplot as plt
data_url = "https://ndownloader.figshare.com/files/20232174"
db = geopandas.read_file(data_url)
```
```{python}
ax = db.plot(color="red", figsize=(9, 9))
cx.add_basemap(ax, crs=db.crs.to_string())
```
May I ask how to solve this issue? My python version is 3.10.4.
Your kind guidance is much appreciated!
cderv
April 27, 2022, 8:20am
2
It is possible that there is a different support needed for contextily
output.
You can probably open an issue in GitHub - rstudio/reticulate: R Interface to Python posting a reproducible example for the developer to check this.
Thanks for your quick response @cderv ! Issue opened.
1 Like
cderv
April 28, 2022, 7:55am
4
Great. For reference, this has been opened here
opened 01:56AM - 28 Apr 22 UTC
In a rmarkdown document, it can normally show the plot generated by `matplotlib`… inline.
However, when it comes to maps generated by GIS packages such as `geopandas` and `contextily`, there's no inline output:
``````
```{r setup}
library(reticulate)
# conda_create("r-reticulate")
use_condaenv("r-reticulate")
```
``````
``````
```{python}
import contextily as cx
import geopandas
import rasterio
from rasterio.plot import show as rioshow
import matplotlib.pyplot as plt
data_url = "https://ndownloader.figshare.com/files/20232174"
db = geopandas.read_file(data_url)
```
``````
``````
```{python}
db.plot(color="red", figsize=(9, 9))
# there should be an inline map
```
``````
``````
```{python}
ax = db.plot(color="red", figsize=(9, 9))
cx.add_basemap(ax, crs=db.crs.to_string())
# there should be an inline map
```
``````
May I ask how to solve this issue? My python version is 3.10.4.
Your kind guidance is much appreciated!
system
Closed
May 19, 2022, 7:56am
5
This topic was automatically closed 21 days after the last reply. New replies are no longer allowed. If you have a query related to it or one of the replies, start a new topic and refer back with a link.