在測繪中和地理信息系統(tǒng)中坐標(biāo)投影的重要性不言而喻。 在Geopandas中是使用 proj4 strings來定義坐標(biāo)系的,而坐標(biāo)系的代碼編號我們可以在www.中找到。 在geopandas中坐標(biāo)系統(tǒng)的可用多種方式引用相同的坐標(biāo)系,例如WGS84中 1."+proj=longlat +ellps=WGS84 +datum=WGS84 +no_defs" 2. EPSG codes 3. proj4 string 設(shè)置投影當(dāng)由于某種原因,地理數(shù)據(jù)具有坐標(biāo)數(shù)據(jù)(xy值)時(shí),可能需要設(shè)置投影,但是沒有關(guān)于這些坐標(biāo)如何引用現(xiàn)實(shí)世界中的位置的信息。設(shè)置投影是指如何告訴geopandas如何解釋坐標(biāo)。如果未設(shè)置CRS,則geopandas幾何操作仍將起作用,但是無法進(jìn)行坐標(biāo)轉(zhuǎn)換,并且其他軟件可能無法正確解釋導(dǎo)出的文件。當(dāng)數(shù)據(jù)無坐標(biāo)系統(tǒng)時(shí)我們需要設(shè)置坐標(biāo)系統(tǒng): GeoDataFrame.crs = {'init' :'epsg:4326'} # 給地理數(shù)據(jù)設(shè)置坐標(biāo)系,使用的EPSG代碼方法。還可以用上述proj4 string 方法, 重新投影 重新投影是將位置表示從一個(gè)坐標(biāo)系更改為另一個(gè)坐標(biāo)系的過程。地球上位置到二維平面的所有投影都是扭曲的,最適合您應(yīng)用的投影可能與您導(dǎo)入的數(shù)據(jù)相關(guān)的投影不同。在這些情況下,可以使用以下 舉例: import geopandas world = geopandas.read_file(geopandas.datasets.get_path('naturalearth_lowres')) world.crs # 輸出結(jié)果為{'init': 'epsg:4326'} ax = world.plot();ax.set_title("WGS84 (lat/lon)") world = world[(world.name != "Antarctica") & (world.name != "Fr. S. Antarctic Lands")] world = world.to_crs({'init': 'epsg:3395'}) # 坐標(biāo)轉(zhuǎn)換為墨卡托投影 ax = world.plot();ax.set_title("Mercator");
|
|