Punkte auf der Karte markieren
Dieser Post setzt voraus dass Sie einfache Karte mit Geopandas gelesen haben.
Geopandas macht es auch recht einfach Markierungspunkte auf die Karte zu setzen:
import geopandas
import matplotlib.pyplot as plt
from shapely.geometry import Point
# Read the shapefile and related data
gdf = geopandas.read_file( "swissBOUNDARIES3D_1_3_TLM_KANTONSGEBIET.shp" )
# Plot the map
ax = gdf.plot()
# Coordinates of some cities (WGS84)
cities = geopandas.GeoSeries(
[Point(8.471470,47.437788),
Point(7.436784,46.947783),
Point(7.589136,47.559559),
Point(7.987821,46.315899),
Point(8.534659,47.377623)], crs="EPSG:4326" )
# Transform the coordinates to LV95
cities = cities.to_crs( gdf.crs )
# Plot the points
cities.plot( ax=ax, color="red", markersize=5 )
# Remove axes and margins
ax.margins( 0 )
plt.axis( "off" )
# Save plot as SVG
plt.savefig( "gpsecond.svg", bbox_inches="tight", pad_inches=0.1 )
Beachten Sie cities.to_crs. Dieser Aufruf konvertiert die WGS-Koordinaten in LV95.
Im nächsten Schritt werden die Punkte beschriftet: Beschriftung der Karte