简体   繁体   English

了解我的shapefile的坐标点(不是纬度/经度)以及为什么空间连接不起作用

[英]Understanding my shapefile's coordinate points (not lat/lon) and why spatial joins own't work

I downloaded a shapefile of Postal Codes in Mexico City here . 在此处下载了墨西哥城邮政编码 shapefile。

I'm trying to do a spatial join to see which zip codes intersect with a particular zone I'm interested in. 我正在尝试进行空间连接,以查看哪些邮政编码与我感兴趣的特定区域相交。

But when I load the postal codes: 但是当我加载邮政编码时:

codigos = gpd.read_file('/Users/jaehakyu/Documents/Shapefiles/Mexico Postal Codes/CP_CdMx/CP_09CDMX_v4.shp')
codigos.head()

I notice strange output in the polygons for these postal codes. 我注意到这些邮政编码在多边形中产生了奇怪的输出。 They're not comprised of lat/lon coordinates. 它们不包含纬度/经度坐标。 Instead, they look like this: 相反,它们看起来像这样:

POLYGON ((2794650.259300001 819469.0967999995, 2794601.180299997 819320.3825999983, 2794595.038099997 819303.2646000013, 2794581.846100003 819266.4985000007, 2794552.451700002 819177.5449000001, 2794539.257799998 819142.9415000007, 2794490.202399999 819013.9316000007, 2794461.8829 819006.0326999985, 2794333.362800002 818970.185899999, 2794287.639799997 818974.6688000001, 2794223.908 818980.9173000008, 2794210.812299997 818904.4486999999, 2794187.823399998 818901.436999999, 2794164.019500002 818896.5203000009, 2794128.538500004 818896.0044, 2794122.643299997 818895.9186999984, 2794077.665700004 818894.2122999988, 2794066.248400003 818891.7342999987, 2794046.369499996 818886.5003999993, 2794006.863200001 818880.5144000016, 2793988.908100002 818882.2074999996, 2793965.905199997 818887.1242000014, 2793955.3869 818892.3366999999, 2793903.004799999 818932.752799999, 2793796.985100001 818913.691399999, 2793741.294 818906.6301999986, 2793596.247299999 818889.4554999992, 2793571.957000002 81903 POLYGON((2794650.259300001 819469.0967999995,2794601.180299997 819320.3825999983,2794595.038099997 819303.2646000013,2794581.846100003 819266.4985000007,2794552.451700002 819177.5449000001,2794539.257799998 819142.9415000007,2794490.202399999 819013.9316000007,2794461.8829 819006.0326999985,2794333.362800002 818970.185899999,2794287.639799997 818974.6688000001,2794223.908 818980.9173000008,2794210.812299997 818904.4486999999,2794187.823399998 818901.436999999,2794164.019500002 818896.5203​​000009,2794128.538500004 818896.0044,2794122.643299997 818895.9186999984 ,2794077.665700004 818894.2122999988,2794066.248400003 818891.7342999987,2794046.369499996 818886.5003999993,2794006.863200001 818880.5144000016,2793988.908100002 818882.2074999996,2793965.905199997 818887.1242000014,2793955.3869 818892.3366999999,2793903.004799999 818932.752799999,2793796.985100001 818913.691399999,2793741.294 818906.6301999986,2793596.247299999 818889.4554999992,2793571.957000002 81903 3.999499999, 2793552.235299997 819034.7226999998, 2793527.926200002 819036.2868999988, 2793444.091899998 818973.02, 2793442.978699997 819118.5722999983, 2793437.997699998 819133.6957999989, 2793430.251699999 819144.4745000005, 2793414.9217 819147.9660999998, 2793334.550800003 819163.0062999986, 2793290.008699998 819170.9169000015, 2793213.590499997 819263.4613000005, 2793110.11 819265.5681000017, 2793117.498800002 819308.4505000003, 2793146.486199997 819475.7197000012, 2793186.218999997 819462.5135999992, 2793249.972900003 819441.3235000001, 2793345.965300001 819414.0322999991, 2793436.257799998 819398.3966999985, 2793517.804700002 819384.2754999995, 2793565.4133 819377.8266999982, 2793601.6972 819374.2901000008, 2793787.7729 819356.7437000014, 2793841.170500003 819343.5784999989, 2793848.679399997 819336.9222000018, 2793862.701300003 819415.7888999991, 2793896.867299996 819558.6755999997, 2793912.430100001 819623.6581000015, 2793934.3768 819672.3953000009, 2793959.285499997 819765.170 3.999499999,2793552.235299997 819034.7226999998,2793527.926200002 819036.2868999988,2793444.091899998 818973.02,2793442.978699997 819118.5722999983,2793437.997699998 819133.6957999989,2793430.251699999 819144.4745000005,2793414.9217 819147.9660999998,2793334.550800003 819163.0062999986,2793290.008699998 819170.9169000015,2793213.590499997 819263.4613000005,2793110.11 819265.5681000017,2793117.498800002 819308.4505000003,2793146.486199997 819475.7197000012,2793186.218999997 819462.5135999992,2793249.972900003 819441.3235000001,2793345.965300001 819414.0322999991, 2793436.257799998 819398.3966999985,2793517.804700002 819384.2754999995,2793565.4133 819377.8266999982,2793601.6972 819374.2901000008,2793787.7729 819356.7437000014,2793841.170500003 819343.5784999989,2793848.679399997 819336.9222000018,2793862.701300003 819415.7888999991,2793896.867299996 819558.6755999997,2793912.430100001 819623.6581000015,2793934.3768 819672.3953000009,2793959.285499997 819765.170 0000018, 2793964.056900002 819787.6761000007, 2793984.413400002 819883.6871000007, 2793997.486699998 819948.0406999998, 2794004.954099998 819981.5982000008, 2794111.821699999 819973.7314999998, 2794230.936700001 819964.9633999988, 2794347.152999997 819955.9384000003, 2794343.185599998 819899.5188000016, 2794458.9071 819890.1013999991, 2794764.265699998 819868.1314000003, 2794762.4494 819852.9858999997, 2794736.8922 819766.9114000015, 2794727.679099999 819735.4631999992, 2794672.272100002 819545.7978999987, 2794650.259300001 819469.0967999995)) 0000018,2793964.056900002 819787.6761000007,2793984.413400002 819883.6871000007,2793997.486699998 819948.0406999998,2794004.954099998 819981.5982000008,2794111.821699999 819973.7314999998,2794230.936700001 819964.9633999988,2794347.152999997 819955.9384000003,2794343.185599998 819899.5188000016,2794458.9071 819890.1013999991,2794764.265699998 819868.1314000003,2794762.4494 819852.9858999997,2794736.8922 819766.9114000015,2794727.679099999 819735.4631999992,2794672.272100002 819545.7978999987,2794650.259300001 819469.0967999995))

I tried doing a spatial join anyway, but no luck. 我仍然尝试进行空间连接,但是没有运气。 I've also tried mapping these polygons using CartoDB, but they do not show up. 我也尝试过使用CartoDB映射这些多边形,但是它们没有显示出来。 I'm not sure what I'm dealing with and would love some help understanding: 我不确定自己要处理的内容,希望了解一些帮助:

(1) What the coordinate points here are. (1)这里的坐标点是什么。 (2) How to get them to lat/lon so that a spatial join can work (2)如何使它们达到经/纬度,以便空间连接可以工作

Thank you! 谢谢! I am working on this using geopandas and shapely in Python, by the way. 顺便说一下,我正在使用geopandas并在Python中进行匀称处理。

Perhaps it goes without saying, but to spatially join two datasets they need to be in the same coordinate system. 也许不用说,但是要在空间上合并两个数据集,它们必须处于同一坐标系中。 Latitude/longitude are coordinates in some geographic coordinate system (and there is more than one, so make sure you know which!). 纬度/经度是某些地理坐标系中的坐标(并且不止一个,因此请确保您知道哪个!)。

Shapefiles can include coordinates in a variety of coordinate systems. Shapefile可以包含各种坐标系中的坐标。 Typically there is a .prj file that is distributed with the shapefile that describes the coordinate system information. 通常,存在一个与shapefile一起分发的.prj文件,该文件描述了坐标系信息。

Looking at your data, I'd guess that it's in eastings and northings, measured in meters, in some projected coordinate system. 查看您的数据,我想它是在某些投影坐标系中的东西方向(以米为单位)。 So before you can spatially join with data in a geographic coordinate system you will first need to unproject the data (go from a projected or planar coordinate system to a spheroidal one), and then possibly perform a datum shift (adjust for differences between different geographic coordinate systems). 因此,在将数据与地理坐标系中的数据进行空间连接之前,您首先需要取消投影数据(从投影坐标系或平面坐标系到球面坐标系),然后可能需要进行数据移动 (调整不同地理区域之间的差异)坐标系)。

I don't know about geopandas or shapely, but I know the proj4 library has good Python bindings and can perform these operations. 我不了解geopandas或shapep,但是我知道proj4库具有良好的Python绑定并且可以执行这些操作。 But either way you'll need the data in the .prj file. 但是,无论哪种方式,您都需要.prj文件中的数据。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 减少拉特隆点 - reduce lat lon points 如何从1D lat lon值绘制特定坐标点的pcolormesh而不是meshgrid - How to plot pcolormesh for specific coordinate points instead of a meshgrid from 1D lat lon values 如何检查坐标网格中是否存在坐标对(纬度,经度)? - How to check if a coordinate pair (lat,lon) exists in a coordinate grid? 如何将 shapefile 中的信息从多边形转换为纬度/经度 - How to convert the information from a shapefile from polygon to lat/lon 如何执行经纬度数据点的聚类 - How to perform clustering of lat/lon data points 无法使用推文刮取地理坐标[Lat-Lon] - Not able to Scrape geo coordinate with tweets [Lat-Lon] 将纬度/经度坐标对设置为主数据集索引 - Setting lat/lon coordinate pairs to main dataset index 纬度/经度坐标点数据提取无法在 xarray 中运行 - Lat/Lon coordinate point data extraction failing to run in xarray 使用最大/最小纬度和经度以及网格点数,如何获得经纬度网格? - With max/min lat and lon and number of grid points, how to get lat/lon grid? 如何一次计算沿路径(纬度/经度点)的测地距离? - How to calculate geodesic distance along a path (lat/lon points) at once?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM