김지영
김지영

Reputation: 359

geopandas projection problems

I'm handling shp files now and I encountered problems with the projections. Let me give you my code below.

import pandas as pd import geopandas as gpd from geopandas import GeoSeries, GeoDataFrame import os

Aelly = gpd.read_file(r'C:\Users\Hyun Mo\Downloads\조인 (1)\after_join.shp', encoding = 'utf-8') 
base_map = gpd.read_file(r'C:\Users\Hyun Mo\Downloads\11000 (3)\TL_SCCO_SIG.shp', encoding = 'ANSI')
Aelly_to_crs = Aelly.to_crs(base_map.crs)
Aelly_to_crs.plot(ax=base_map.plot())

And here is my data construction

print(base_map.head())

data construction

print(Aelly.head())

data construction

When I executed print(base_map.crs), print(Aelly_to_crs.crs), I got the results like below.

results

Aelly_to_crs.plot(ax=base_map.plot())

data construction

The above picture is the result of executing Aelly.plot(ax=base_map.plot()) And you can see that the two pictures don't match each other. How can I solve this problems??

-----------edit

My desired output is below picture.

enter image description here

Here are my data links: http://blog.naver.com/khm2963/220929301892

below pictures are procedure for downloading my flie

enter image description here enter image description here

Upvotes: 4

Views: 1014

Answers (1)

Marjan Moderc
Marjan Moderc

Reputation: 2859

From the data that you have printed it looks like everything is working as it should! The coordinates between the shapefiles are very different, but crs is the same, so the plot totally makes sense.

GeoPandas isn't able to tell you whether the data and number make sense in a real world. You gave it two shapefiles with well defined projection (EPSG: 32652) and with hardcoded coordinates and GeoPandas is happy with that.

If you know that in reality both shapefiles represent the same area, then you are the one that has to realize that datasource is somehow corrupt. I think that one of the shapefiles accidentally got a different crs definition as a metadata (imagine it as a wrong text encoding, for instance).

The easiest way to figure that out and correct it is by using ArcGIS or QGIS software, where you can play with different projections in order to figure out, what the correct projection was. Then you can save the shapefile with new projection metadata and the rest will work out of the box.

Upvotes: 1

Related Questions