我有一张智利地图(http://labgeo.ufro.cl/fichas/chile_geo/ficha_cl_geo.html第一个链接上面写着“智利大陆”),想绘制它并添加一些我有纬度的中心点经度数据。
\n\n我是 geopandas 和 matplotlib 的新手,但我设法使用这篇文章中 matplotlib 的建议答案以不同颜色的点的形式绘制地图:Color by Column Values in Matplotlib
\n\n这是我的代码:
\n\n#Loading data, since I am making the coordinates up they won\xc2\xb4t fit the map nicely but you will get the idea\n\nmap_= gpd.read_file("cl_continental_geo.shp")\ngeo_df_ = pd.DataFrame({"id":np.random.randint(20, size=133) ,"Latitude": np.random.normal(-34.406922,7.819504, 133), "Longitud": np.random.normal(-71.243350,1.254126, 133)})\n\ngeometry =[Point(xy) for xy in zip( geo_df_["Longitud"],geo_df_["Latitude"])]\ngeo_df_ =gpd.GeoDataFrame(geo_df_, crs={"init":"epsg:4326"},geometry= geometry)\n\n# creating color map for categories\ncategories = np.unique(geo_df_["id"])\ncolors = np.linspace(0, 1, len(categories))\ncolordict = dict(zip(categories, colors))\n\n#matching it to the geopandas df\ngeo_df_["Color"] = …Run Code Online (Sandbox Code Playgroud)