Hello,
I'm trying to use a sample notebook to generate a report from a feature layer in Arc Online/Field Maps, and run into trouble when I try to import Carotpy. I get ModuleNotFoundError: No module named "Cartopy'. After looking around it seems like one solution would be installing conda, though I'm not sure how to do that with an online Notbook and the sample I have does not mention anything about that. I'm new to python and any direction would be greatly appreciated. The code for this is:
import cartopy.crs as ccrs
%matplotlib agg
import cartopy.crs as ccrs
import matplotlib.pyplot as plt
from cartopy.io.img_tiles import GoogleTiles
def create_map(feature):
fig=plt.figure(figsize=(5,5))
url = 'https://server.arcgisonline.com/ArcGIS/rest/services/World_Street_Map/MapServer/tile/{z}/{y}/{x}.jpg'
image = GoogleTiles(url=url)
ax = fig.add_subplot(1,1,1, projection=image.crs)
ax.add_image(image, 15)
xmin = feature["geometry"]["x"] - 500
xmax = feature["geometry"]["x"] + 500
ymin = feature["geometry"]["y"] - 500
ymax = feature["geometry"]["y"] + 500
ax.set_extent([xmin, xmax, ymin, ymax], crs=image.crs)
ax.scatter(feature["geometry"]["x"], feature["geometry"]["y"],
color='green', linewidth=2, marker='o'
)
io_bytes = io.BytesIO()
plt.savefig(io_bytes, format='jpeg', bbox_inches='tight')
io_bytes.seek(0)
return base64.b64encode(io_bytes.read()).decode()
---------------------------------------------------------------------------
ModuleNotFoundError Traceback (most recent call last)
Input In [6], in <cell line: 2>()
1 get_ipython().run_line_magic('matplotlib', 'agg')
----> 2 import cartopy.crs as ccrs
3 import matplotlib.pyplot as plt
4 from cartopy.io.img_tiles import GoogleTiles
ModuleNotFoundError: No module named 'cartopy'