Python之geopandas

1、查询点是否在geojson内

import geopandas as gpd
from shapely.geometry import Point

	logger.info('开始')
    lon = np.linspace(73, 134.9, 6200)
    lat = np.linspace(54.2, 12.21, 4200)
    shape = gpd.read_file(config.ROOT_PATH / 'nanjing.json')
    region_shape = shape['geometry'][0]
    in_shape_xy = []
    for x in lon:
        for y in lat:
            if region_shape.contains(Point([x,y])):
                in_shape_xy.append([x,y])
    region_xy = np.array(in_shape_xy)
    logger.info('结束')
    print(region_xy.shape)

缺点,较慢

你可能感兴趣的:(Python,geopandas)