├── README.md ├── download_by_polygon.py ├── download_by_rect.py ├── download_example.geojson ├── example.geojson ├── img ├── 1.png ├── 10.png ├── 11.png ├── 12.png ├── 2.png ├── 3.png ├── 4.png ├── 5.png ├── 6.png ├── 7.png ├── 8.png ├── 9.png ├── 栅格.png └── 栅格下载.png ├── requirements.txt └── yjnt.geojson /README.md: -------------------------------------------------------------------------------- 1 | # 永久基本农田查询生成geojson数据 2 | 3 | 4 | [永久基本农田查询平台](https://yncx.mnr.gov.cn/yn/#/home) 5 | 6 | 7 | ## 11-04更新 8 | 9 | 网站目前已经不在直接返回JSON数据了,查看网页使用了sm2加密,找到这个私钥直接进行模拟就可以了 10 | 11 | 请求数据中还增加了个token目前看来是个固定值 12 | 13 | ![](./img/11.png) 14 | 15 | ![](./img/12.png) 16 | 17 | 这里使用gmssl库来模拟sm2解密,传入请求的数据以及私钥 18 | 19 | ``` 20 | from gmssl import sm2 21 | def decrypt_geojson(data,key): 22 | 23 | if data and data.startswith("04"): 24 | data = data[2:] 25 | sm2_crypt = sm2.CryptSM2(public_key="", private_key=key,mode=1) 26 | features = sm2_crypt.decrypt(bytes.fromhex(data)) 27 | features=features.decode('utf-8') 28 | jsondata=json.loads(features) 29 | features=jsondata["recordsets"][0]["features"] 30 | 31 | return features 32 | 33 | ``` 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | ## 1、网页查询突破500亩限制 43 | 网站提供了点查询和范围查询,但是限制了500亩范围,直接上才艺 44 | ![](./img/1.png) 45 | 46 | 47 | 查看网页源文件发现这个限制实际是在前端进行验证的,找到这段代码直接注释掉 48 | 49 | ![](./img/2.png) 50 | 51 | 另外还有个1000个要素的限制,按需酌情修改,小心被ban 52 | 53 | ![](./img/3.png) 54 | 55 | 注意的是这里直接修改网页js是无法生效的,需要在替换文件夹中进行修改 56 | 57 | ## 2、PYTHON获取矢量数据 58 | 59 | **从网页查询就能看出来这就是一个矢量叠加影像** 60 | 61 | 分析网络请求发现范围查询返回的是一个json数据,这里面就包含了所有要素的边界坐标,只要提取这个坐标信息就可以在GIS软件中还原出来了 62 | 63 | ![](./img/6.png) 64 | 65 | ### 2.1 矩形范围查找 66 | 使用网页的绘制范围绘制一个矩形范围进行查找,可以看到网页请求携带了这4个顶点坐标,服务器根据这4个顶点坐标生成了多边形然后在数据库查找返回 67 | 68 | 由于500亩的查询范围和1000片图斑的限制都是在前端验证的,这里使用脚本可以无需验证判断 69 | 70 | #### 矩形范围查询的示例 71 | 72 | **expectCount**:默认为1000,限制了最大查询图斑数量 73 | 74 | **epsgCode**:默认为4490,坐标系为CGCS2000 75 | 76 | **spatialQueryMode**:INTERSECT使用几何相交查询 77 | 78 | **points**:在geometry对象中需要传入区域的顶点坐标,矩形直接使用两个顶点坐标即可 79 | 80 | 如果使用多边形多个顶点也是可以的,修改顶点个数即可,points属性中的id字段需要唯一生成 81 | 82 | 可以看到这里使用的是超图supermap 83 | 84 | ``` 85 | form_data = { 86 | 'queryMode': 'SpatialQuery', 87 | 'queryParameters': { 88 | 'customParams': None, 89 | 'prjCoordSys': {'epsgCode': 4490}, 90 | 'expectCount': n, 91 | 'networkType': "LINE", 92 | 'queryOption': "ATTRIBUTEANDGEOMETRY", 93 | 'queryParams': [{'name': "pro31@yndk", 'attributeFilter': "1=1", 'fields': None}], 94 | 'startRecord': 0, 95 | 'holdTime': 10, 96 | 'returnCustomResult': False, 97 | 'returnFeatureWithFieldCaption': False 98 | }, 99 | 'geometry': { 100 | 'id': 0, 101 | 'style': None, 102 | 'parts': [5], 103 | 'points': [ 104 | {'id': "SuperMap.Geometry_1", 'bounds': None, 'SRID': None, 'x': x1, 'y': y1, 'tag': None, 'type': "Point", 'geometryType': "Point"}, 105 | {'id': "SuperMap.Geometry_2", 'bounds': None, 'SRID': None, 'x': x2, 'y': y1, 'tag': None, 'type': "Point", 'geometryType': "Point"}, 106 | {'id': "SuperMap.Geometry_3", 'bounds': None, 'SRID': None, 'x': x2, 'y': y2, 'tag': None, 'type': "Point", 'geometryType': "Point"}, 107 | {'id': "SuperMap.Geometry_4", 'bounds': None, 'SRID': None, 'x': x1, 'y': y2, 'tag': None, 'type': "Point", 'geometryType': "Point"}, 108 | {'id': "SuperMap.Geometry_5", 'bounds': None, 'SRID': None, 'x': x1, 'y': y1, 'tag': None, 'type': "Point", 'geometryType': "Point"} 109 | ], 110 | 'type': "REGION", 111 | 'prjCoordSys': {'epsgCode': None} 112 | }, 113 | 'spatialQueryMode': "INTERSECT" 114 | } 115 | ``` 116 | **运行示例** 117 | 118 | ```` 119 | if __name__ == "__main__": 120 | # 默认最大查询1000片,请酌情修改,查询太多可能会被ban,按需查询 121 | expectCount=1000 122 | # 保存文件路径 123 | file_path = 'yjnt2.geojson' 124 | # 默认按矩形查找,传入左上与右下坐标,建议查询范围不要太大,爱护服务器 125 | x1=121.333167 126 | y1=32.2544 127 | x2=121.33784 128 | y2=32.25190 129 | 130 | fetures=get_features(x1,y1,x2,y2,expectCount) 131 | download_geojson(file_path,fetures) 132 | 133 | ```` 134 | 135 | 136 | 生成的geojson示例文件格式如下,可以直接导入gis软件生成矢量: 137 | ```` 138 | { 139 | "type": "FeatureCollection", 140 | "crs": { "type": "name", "properties": { "name": "urn:ogc:def:crs:EPSG::4490" } }, 141 | "features": [ 142 | { "type": "Feature", "properties": { "ID": 42025373 }, "geometry": { "type": "Polygon", "coordinates": [ [ [ 120.705093603000023, 32.419247212000073 ], [ 120.704840518000083, 32.41916201600003 ], [ 120.70477883600006, 32.419255580000026 ], [ 120.70504355300011, 32.41934593700006 ], [ 120.705092870000044, 32.419260273000077 ], [ 120.705093603000023, 32.419247212000073 ] ] ] } }, 143 | { "type": "Feature", "properties": { "ID": 42030018 }, "geometry": { "type": "Polygon", "coordinates": [ [ [ 120.705383644000108, 32.419345331000045 ], [ 120.705348222000111, 32.419333024000025 ], [ 120.705307874000027, 32.41941844400003 ], [ 120.705290340000033, 32.419430172000034 ], [ 120.705333192000012, 32.419444799000075 ], [ 120.705383644000108, 32.419345331000045 ] ] ] } }, 144 | { "type": "Feature", "properties": { "ID": 42030233 }, "geometry": { "type": "Polygon", "coordinates": [ [ [ 120.706502662000048, 32.41991253100008 ], [ 120.706718018000061, 32.419743007000079 ], [ 120.706718267000042, 32.419743225000047 ], [ 120.706721468000069, 32.419746037000039 ], [ 120.706721885000093, 32.419745719000048 ], [ 120.706754322000052, 32.419721037000045 ], [ 120.706858322000016, 32.419827102000056 ], [ 120.706878926000059, 32.419847466000078 ], [ 120.706950813000049, 32.41978406800007 ], [ 120.707091414000047, 32.419631123000045 ], [ 120.707217812000067, 32.419506703000025 ], [ 120.707376698000076, 32.419365145000029 ], [ 120.707399784000017, 32.419344203000037 ], [ 120.707219529000099, 32.419283103000055 ], [ 120.707165961000101, 32.419263827000066 ], [ 120.706993972000078, 32.419212238000057 ], [ 120.706961270000079, 32.419202429000052 ], [ 120.70696458000009, 32.41919550800003 ], [ 120.706891193000047, 32.419172772000024 ], [ 120.706887928000015, 32.41918042900005 ], [ 120.706706068000017, 32.419125878000045 ], [ 120.706709660000115, 32.419116532000032 ], [ 120.706691743000079, 32.419110981000074 ], [ 120.706518804000098, 32.419057404000057 ], [ 120.706518281000058, 32.419057242000065 ], [ 120.706571668000038, 32.418937131000064 ], [ 120.706552710000096, 32.418930988000056 ], [ 120.706451224000034, 32.419151047000071 ], [ 120.706305504000056, 32.419491846000028 ], [ 120.706329230000051, 32.419491836000077 ], [ 120.706329873000072, 32.41949173900008 ], [ 120.706420367000078, 32.419477982000046 ], [ 120.706478108000056, 32.41945774900006 ], [ 120.706546562000085, 32.419416127000034 ], [ 120.706608089000042, 32.419373227000051 ], [ 120.706681838, 32.41930201200006 ], [ 120.706750613000054, 32.419238132000032 ], [ 120.706802711000023, 32.419202142000074 ], [ 120.706825503000118, 32.419195476000027 ], [ 120.706853457000079, 32.419200999000054 ], [ 120.706884082000101, 32.41922164500005 ], [ 120.706940366000026, 32.41926817500007 ], [ 120.706960085000105, 32.419294256000057 ], [ 120.706963911000116, 32.419334998000068 ], [ 120.706934475000025, 32.419405055000027 ], [ 120.706906091000064, 32.419456009000044 ], [ 120.706891419000044, 32.419476552000049 ], [ 120.706822924000107, 32.419530982000026 ], [ 120.706633886000077, 32.419658618000028 ], [ 120.706515810000042, 32.419735610000032 ], [ 120.706406180000045, 32.419802124000057 ], [ 120.706366025000079, 32.419819037000025 ], [ 120.706343248000053, 32.419820245000039 ], [ 120.706317772000034, 32.419814306000035 ], [ 120.706208785000058, 32.419767661000037 ], [ 120.706208270000047, 32.419767441000033 ], [ 120.706190085000117, 32.419762879000075 ], [ 120.706173960000115, 32.419800744000042 ], [ 120.706191253000043, 32.419807190000029 ], [ 120.70619178700008, 32.419807371000047 ], [ 120.706502662000048, 32.41991253100008 ] ] ] } }, 145 | { "type": "Feature", "properties": { "ID": 42030615 }, "geometry": { "type": "Polygon", "coordinates": [ [ [ 120.70475009300003, 32.419245769000042 ], [ 120.704803026000036, 32.419149395000034 ], [ 120.704580951000025, 32.419074637000051 ], [ 120.704458063000061, 32.419034037000074 ], [ 120.704341199000055, 32.418994068000075 ], [ 120.704321636000032, 32.419032475000051 ], [ 120.704165036000063, 32.419354257000066 ], [ 120.704164905000084, 32.419354526000063 ], [ 120.704258741000103, 32.419387862000065 ], [ 120.704378140000017, 32.419436434000033 ], [ 120.704378267000038, 32.419436135000069 ], [ 120.70449330200006, 32.41916597900007 ], [ 120.7045225170001, 32.419175689000042 ], [ 120.704526057000066, 32.419169297000053 ], [ 120.704526537000106, 32.419169461000024 ], [ 120.70475009300003, 32.419245769000042 ] ] ] } }, 146 | { "type": "Feature", "properties": { "ID": 42031511 }, "geometry": { "type": "Polygon", "coordinates": [ [ [ 120.705124238000053, 32.419257525000035 ], [ 120.705093603000023, 32.419247212000073 ], [ 120.705092870000044, 32.419260273000077 ], [ 120.70504355300011, 32.41934593700006 ], [ 120.705078595000032, 32.419357898000044 ], [ 120.705124238000053, 32.419257525000035 ] ] ] } }, 147 | { "type": "Feature", "properties": { "ID": 42034186 }, "geometry": { "type": "Polygon", "coordinates": [ [ [ 120.704748065000103, 32.417127809000078 ], [ 120.704530099000067, 32.417055692000076 ], [ 120.704485675000114, 32.417230032000077 ], [ 120.704415253000093, 32.417408431000069 ], [ 120.704307275000019, 32.417583810000053 ], [ 120.704165913000111, 32.417880797000066 ], [ 120.70418307500006, 32.417887275000055 ], [ 120.704183562000026, 32.417887445000076 ], [ 120.704650187000084, 32.418049736000057 ], [ 120.705117301000087, 32.418212194000034 ], [ 120.705574998000088, 32.418380102000071 ], [ 120.705637780000075, 32.418402041000036 ], [ 120.705886355000075, 32.418488901000046 ], [ 120.705892211000105, 32.41847795800004 ], [ 120.706609520000029, 32.418720575000066 ], [ 120.706781805000105, 32.418320688000051 ], [ 120.706961983000042, 32.417902479000077 ], [ 120.706970731000069, 32.417882180000049 ], [ 120.706975420000049, 32.417871295000054 ], [ 120.706937584000116, 32.417858304000049 ], [ 120.706930137000086, 32.417875133000052 ], [ 120.705753636000054, 32.417474133000042 ], [ 120.705732521000073, 32.417519681000044 ], [ 120.705708107000078, 32.417572341000039 ], [ 120.705679939000106, 32.417633102000025 ], [ 120.705676109000024, 32.417641361000051 ], [ 120.705605720000108, 32.417793192000033 ], [ 120.705605592000097, 32.417793471000039 ], [ 120.705545700000016, 32.41777258500008 ], [ 120.705542144000106, 32.417781233000028 ], [ 120.705237717000045, 32.417683406000037 ], [ 120.705225849000044, 32.41767959200007 ], [ 120.705251781000015, 32.417712298000026 ], [ 120.705287852000083, 32.417767946000026 ], [ 120.705307449000088, 32.417830141000024 ], [ 120.705306064000069, 32.417875279000043 ], [ 120.70528859500007, 32.417918279000048 ], [ 120.705253768000034, 32.417971737000073 ], [ 120.70523641300008, 32.417979882000054 ], [ 120.705212891000087, 32.417981927000028 ], [ 120.70514976100003, 32.417984928000067 ], [ 120.705121295000026, 32.417985911000073 ], [ 120.705094097000028, 32.417976400000043 ], [ 120.70503979800003, 32.417928399000061 ], [ 120.704940819000058, 32.41784397300006 ], [ 120.704854437000108, 32.41776797700004 ], [ 120.704735918000097, 32.417679514000042 ], [ 120.70462085500003, 32.417594419000068 ], [ 120.704555590000041, 32.417542043000026 ], [ 120.704538002000049, 32.417450526000039 ], [ 120.704571286000032, 32.417390216000058 ], [ 120.704665198000043, 32.41730709400008 ], [ 120.704748065000103, 32.417127809000078 ] ] ] } }, 148 | { "type": "Feature", "properties": { "ID": 42034708 }, "geometry": { "type": "Polygon", "coordinates": [ [ [ 120.709031671000048, 32.419561434000059 ], [ 120.708355728000015, 32.419323015000032 ], [ 120.708192303000033, 32.419263640000054 ], [ 120.707748975000072, 32.419111649000058 ], [ 120.7075860220001, 32.419058358000029 ], [ 120.706660311000064, 32.418739165000034 ], [ 120.707022356000039, 32.417912337000075 ], [ 120.707021854000118, 32.41791216300004 ], [ 120.706999114000041, 32.417903810000041 ], [ 120.706816960000083, 32.418329973000027 ], [ 120.706634803000043, 32.418756134000034 ], [ 120.70665081900006, 32.418764456000076 ], [ 120.706898217000116, 32.418849198000032 ], [ 120.707305552000093, 32.418998242000043 ], [ 120.707874496000045, 32.419182600000056 ], [ 120.70840738000004, 32.419367158000057 ], [ 120.709027988000116, 32.419569753000076 ], [ 120.709031536000111, 32.419561743000031 ], [ 120.709031671000048, 32.419561434000059 ] ] ] } }, 149 | { "type": "Feature", "properties": { "ID": 42034831 }, "geometry": { "type": "Polygon", "coordinates": [ [ [ 120.704840518000083, 32.41916201600003 ], [ 120.704803026000036, 32.419149395000034 ], [ 120.70475009300003, 32.419245769000042 ], [ 120.70477883600006, 32.419255580000026 ], [ 120.704840518000083, 32.41916201600003 ] ] ] } }, 150 | { "type": "Feature", "properties": { "ID": 42035651 }, "geometry": { "type": "Polygon", "coordinates": [ [ [ 120.705822774000012, 32.419648083000027 ], [ 120.705892845000108, 32.419522244000063 ], [ 120.705383644000108, 32.419345331000045 ], [ 120.705333192000012, 32.419444799000075 ], [ 120.705369668000117, 32.41945725000005 ], [ 120.705271702000118, 32.419742982000059 ], [ 120.705399778000015, 32.419787377000034 ], [ 120.70539989800011, 32.419787088000078 ], [ 120.705472382000039, 32.419612442000073 ], [ 120.705472530000065, 32.419612492000056 ], [ 120.705472907000058, 32.419612621000056 ], [ 120.705659070000024, 32.419675915000028 ], [ 120.705659222, 32.419675638000058 ], [ 120.70569988200009, 32.419601319000037 ], [ 120.705822272000091, 32.419647908000059 ], [ 120.705822774000012, 32.419648083000027 ] ] ] } }, 151 | { "type": "Feature", "properties": { "ID": 42037177 }, "geometry": { "type": "Polygon", "coordinates": [ [ [ 120.704341199000055, 32.418994068000075 ], [ 120.704458063000061, 32.419034037000074 ], [ 120.704580951000025, 32.419074637000051 ], [ 120.704803026000036, 32.419149395000034 ], [ 120.704840518000083, 32.41916201600003 ], [ 120.705093603000023, 32.419247212000073 ], [ 120.705124238000053, 32.419257525000035 ], [ 120.705339047000052, 32.419329837000078 ], [ 120.705348222000111, 32.419333024000025 ], [ 120.705383644000108, 32.419345331000045 ], [ 120.705892845000108, 32.419522244000063 ], [ 120.705923436000035, 32.419532872000048 ], [ 120.706206122000026, 32.419631085000049 ], [ 120.706210970000029, 32.419619496000053 ], [ 120.705590567000058, 32.419405414000039 ], [ 120.704970168000045, 32.419191329000057 ], [ 120.704349770000022, 32.41897724100005 ], [ 120.704341199000055, 32.418994068000075 ] ] ] } }, 152 | { "type": "Feature", "properties": { "ID": 42037791 }, "geometry": { "type": "Polygon", "coordinates": [ [ [ 120.707022356000039, 32.417912337000075 ], [ 120.706660311000064, 32.418739165000034 ], [ 120.7075860220001, 32.419058358000029 ], [ 120.707748975000072, 32.419111649000058 ], [ 120.708192303000033, 32.419263640000054 ], [ 120.708355728000015, 32.419323015000032 ], [ 120.709031671000048, 32.419561434000059 ], [ 120.709211628000048, 32.419147018000047 ], [ 120.709391718, 32.418732292000072 ], [ 120.708799248000105, 32.418527264000033 ], [ 120.708206780000069, 32.418322233000026 ], [ 120.707614316000104, 32.41811720000004 ], [ 120.707022356000039, 32.417912337000075 ] ] ] } }, 153 | { "type": "Feature", "properties": { "ID": 42041119 }, "geometry": { "type": "Polygon", "coordinates": [ [ [ 120.706365395000034, 32.419267350000041 ], [ 120.706590184000106, 32.418765119000057 ], [ 120.706392157000096, 32.418695873000047 ], [ 120.706391643000075, 32.418695693000075 ], [ 120.706305035000014, 32.418906541000069 ], [ 120.706304913000054, 32.418906838000055 ], [ 120.706290946000081, 32.418901884000036 ], [ 120.706290616000047, 32.41890271300008 ], [ 120.705985744000031, 32.418814747000056 ], [ 120.705993629000091, 32.418796436000036 ], [ 120.705610661000037, 32.418660609000028 ], [ 120.705621199, 32.41862851500008 ], [ 120.705620047000025, 32.418628162000061 ], [ 120.705513137000025, 32.418868810000049 ], [ 120.705501992000109, 32.418886478000047 ], [ 120.705473194000092, 32.418912653000064 ], [ 120.705467249000094, 32.418913682000039 ], [ 120.705451645000039, 32.418916384000056 ], [ 120.70544165900003, 32.418916032000027 ], [ 120.705406848000052, 32.418914807000078 ], [ 120.705220355000051, 32.418871746000036 ], [ 120.705070015000047, 32.418824572000062 ], [ 120.704988929000024, 32.41879351700004 ], [ 120.704926419000117, 32.418758517000072 ], [ 120.704892125000015, 32.418724424000061 ], [ 120.704884761000017, 32.418705510000052 ], [ 120.704880981000088, 32.418625921000057 ], [ 120.704880465000087, 32.418615076000037 ], [ 120.704880364000019, 32.418612907000067 ], [ 120.704885048000051, 32.418599952000079 ], [ 120.704919583000105, 32.418504451000047 ], [ 120.704974244000027, 32.418367267000065 ], [ 120.705010642000047, 32.418288619000066 ], [ 120.705026297000018, 32.418270390000032 ], [ 120.705047888000081, 32.418253013000026 ], [ 120.705066686, 32.418240396000044 ], [ 120.704616304000069, 32.418083757000034 ], [ 120.704166412000063, 32.417927284000029 ], [ 120.704165925000098, 32.417927115000055 ], [ 120.704148136000072, 32.417922339000029 ], [ 120.703971259000014, 32.418335715000069 ], [ 120.703794382000069, 32.418749090000063 ], [ 120.703806625000084, 32.418752932000075 ], [ 120.704237221000085, 32.418896265000058 ], [ 120.704667818000075, 32.419039597000051 ], [ 120.704674739000097, 32.419041913000058 ], [ 120.704679664000082, 32.419043613000042 ], [ 120.705195841000091, 32.419221850000042 ], [ 120.705712020000078, 32.419400083000028 ], [ 120.706228200000055, 32.419578315000024 ], [ 120.706228331000034, 32.419578019000028 ], [ 120.706356518, 32.419287186000076 ], [ 120.706360664000044, 32.41927792000007 ], [ 120.706365395000034, 32.419267350000041 ] ] ] } }, 154 | { "type": "Feature", "properties": { "ID": 42041505 }, "geometry": { "type": "Polygon", "coordinates": [ [ [ 120.705348222000111, 32.419333024000025 ], [ 120.705339047000052, 32.419329837000078 ], [ 120.705124238000053, 32.419257525000035 ], [ 120.705078595000032, 32.419357898000044 ], [ 120.705290340000033, 32.419430172000034 ], [ 120.705307874000027, 32.41941844400003 ], [ 120.705348222000111, 32.419333024000025 ] ] ] } }, 155 | { "type": "Feature", "properties": { "ID": 42043082 }, "geometry": { "type": "Polygon", "coordinates": [ [ [ 120.706609520000029, 32.418720575000066 ], [ 120.705892211000105, 32.41847795800004 ], [ 120.705886355000075, 32.418488901000046 ], [ 120.705988716000093, 32.418524668000032 ], [ 120.706020107000086, 32.418535636000058 ], [ 120.706402435000086, 32.41866923200007 ], [ 120.706601625000076, 32.418738897000026 ], [ 120.706609520000029, 32.418720575000066 ] ] ] } } 156 | ] 157 | } 158 | 159 | ```` 160 | 161 | #### 成果展示 162 | 163 | 直接在GIS软件中加载,可以叠加谷歌影像等查看,能够缩放到更高的比例 164 | 165 | 166 | ![](/img/7.png) 167 | 168 | 169 | #### 10-11更新 170 | 感谢[salierib](https://github.com/salierib)的提醒,原先生成的geojson没有考虑面要素内部孔洞的问题 171 | 172 | ![](./img/10.png) 173 | 174 | 获取到的json数据中partTopo和parts对象区分了外部和内部顶点 175 | 176 | ![](./img/9.png) 177 | 178 | 这里修改判断是否存在孔洞使用polygon的holes传参 179 | 180 | ``` 181 | for part in parts: 182 | end_index = start_index + part 183 | ring = [(points[i]['x'], points[i]['y']) for i in range(start_index, end_index)] 184 | 185 | if not exterior_ring: # 如果外部边界尚未设置,则这是外部边界 186 | exterior_ring = ring 187 | else: # 否则,这是一个内部边界 188 | interior_rings.append(ring) 189 | start_index = end_index 190 | 191 | # 如果没有内部边界,Polygon 只需要外部边界 192 | if not interior_rings: 193 | polygon = Polygon(exterior_ring) 194 | else: 195 | # 创建Polygon对象,第一个参数是外部边界,第二个参数是一个内部边界的列表 196 | polygon = Polygon(exterior_ring, holes=interior_rings) 197 | ``` 198 | ### 2.2多边形查询 199 | 200 | 由于网页端设置了500亩和1000片的查询限制,我们直接突破限制查询可能会带来不必要的麻烦 201 | 202 | 建议还是按照网页端查询的规则来,模拟更真实的请求 203 | 204 | 另外网页端对每天的查询次数,每个IP的查询次数都是有限制的,虽然都是在前端完成的 205 | 206 | 但是这些措施都是为了防止请多过多、数据量过大给服务器带来压力 207 | 208 | 按照500亩的范围来查询,想要获得一个较大的区域如何来实现呢 209 | 210 | 你可能已经想到了,直接切割为更小的单元来进行 211 | 212 | - 获取给定多边形的最大坐标边界,计算出宽和高,按照最小的粒度计算需要切割的瓦片数(500亩大概是577*577的网格) 213 | 214 | - 计算出每个瓦片对应的度数 215 | 216 | - 根据行列号遍历获取每个网格顶点坐标,使用2.1的矩形下载 217 | 218 | ![](./img/栅格.png) 219 | 220 | #### 示例代码 221 | 222 | 这里通过读取geojson文件的几何来获取多边形的边界 223 | 224 | ``` 225 | if __name__ == '__main__': 226 | # 读取GeoJSON文件,获取第一个多边形,多个自行遍历 227 | file_path = 'example.geojson' 228 | gdf = gpd.read_file(file_path) 229 | polygon = gdf.geometry.iloc[0] 230 | 231 | # 定义栅格大小,限制面积500亩,这里设置为500*500米 232 | grid_size = 500 233 | 234 | # 设置保存路径 235 | savefile_path = 'download_example.geojson' 236 | 237 | #下载栅格 238 | failure_grids=download_by_girds(polygon, grid_size, savefile_path) 239 | 240 | #保存下载失败栅格坐标,后续可以直接使用矩形查找增加 241 | with open('failure_girds', 'w') as file: 242 | json.dump(failure_grids, file) 243 | 244 | ``` 245 | #### 成果展示 246 | 247 | 完整的下载后可以按需裁剪为范围内 248 | 249 | ![](./img/栅格下载.png) 250 | 251 | 252 | ## 免责声明 253 | 254 | 本爬虫脚本仅用于个人学习和研究目的。使用者应遵守当地法律法规,尊重网站的使用规定,并对使用本脚本所产生的任何法律责任自行承担。作者不对因滥用本脚本而产生的任何后果负责。 255 | 使用本脚本即代表您同意以上免责申明。 -------------------------------------------------------------------------------- /download_by_polygon.py: -------------------------------------------------------------------------------- 1 | import time 2 | import random 3 | import geopandas as gpd 4 | from shapely.geometry import box 5 | import numpy as np 6 | from geopy.distance import geodesic 7 | import download_by_rect 8 | import json 9 | 10 | #传入多边形,按最大边界坐标切割为指定大小格网分别下载 11 | def download_by_girds(polygon,grid_size,savefile_path): 12 | 13 | # 计算多边形的边界 14 | min_x, min_y, max_x, max_y = polygon.bounds 15 | 16 | # 计算栅格的数量 17 | width=geodesic((min_y, min_x), (min_y, max_x)).meters 18 | height=geodesic((min_y,min_x),(max_y,min_x)).meters 19 | num_cols = int(np.ceil(width/ grid_size)) 20 | num_rows = int(np.ceil(height / grid_size)) 21 | 22 | #计算每个栅格的宽度和高度,换算为度数 23 | width_per_grid = (max_x-min_x) / num_cols 24 | height_per_grid = (max_y-min_y) / num_rows 25 | 26 | failure_grids=[] 27 | for row in range(num_rows): 28 | for col in range(num_cols): 29 | # 计算当前栅格的左上角和右下角坐标 30 | x1 = min_x + col * width_per_grid 31 | y1 = max_y - row * height_per_grid 32 | x2 = x1 + width_per_grid 33 | y2 = y1 - height_per_grid 34 | 35 | 36 | # 检查栅格和多边形是否相交 37 | rectangle=box(x1,y1,x2,y2) 38 | is_intersect = rectangle.intersects(polygon) 39 | 40 | if is_intersect: 41 | max_retries = 3 42 | retries = 0 43 | while retries < max_retries: 44 | try: 45 | fetures = download_by_rect.get_features(x1, y1, x2, y2, 1000) 46 | download_by_rect.download_geojson(savefile_path,fetures) 47 | print(f'栅格总数{num_rows}行X{num_cols}列,{row + 1}行{col + 1}列下载成功') 48 | break 49 | except Exception as e: 50 | print(f'栅格总数{num_rows}行X{num_cols}列,{row + 1}行{col + 1}列下载失败,第{retries + 1}次重试: {e}') 51 | retries += 1 52 | if retries < max_retries: 53 | time.sleep(5) # 等待5秒后重试 54 | else: 55 | failure_grids.append([x1, y1, x2, y2]) 56 | 57 | time.sleep(random.randint(3, 5)) 58 | 59 | return failure_grids 60 | 61 | if __name__ == '__main__': 62 | # 读取GeoJSON文件,获取第一个多边形,多个自行遍历 63 | file_path = 'example.geojson' 64 | gdf = gpd.read_file(file_path) 65 | polygon = gdf.geometry.iloc[0] 66 | 67 | # 定义栅格大小,限制面积500亩,这里设置为500*500米 68 | grid_size = 500 69 | 70 | # 设置保存路径 71 | savefile_path = 'download_example.geojson' 72 | 73 | #下载栅格 74 | failure_grids=download_by_girds(polygon, grid_size, savefile_path) 75 | 76 | #保存下载失败栅格坐标,后续可以直接使用矩形查找增加 77 | with open('failure_girds', 'w') as file: 78 | json.dump(failure_grids, file) 79 | 80 | 81 | -------------------------------------------------------------------------------- /download_by_rect.py: -------------------------------------------------------------------------------- 1 | import requests 2 | import fiona 3 | from shapely.geometry import mapping 4 | import os 5 | from shapely.geometry import Polygon 6 | from fiona.crs import from_epsg 7 | import json 8 | 9 | headers = {"User-Agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/126.0.0.0 Safari/537.36 Edg/126.0.0.0", 10 | } 11 | url = "https://yncx.mnr.gov.cn/dist-app-yn/map/queryResults.json" 12 | 13 | params = {"returnContent": "true", 14 | 'token':'Whe67hpdoYaBsTRmdzFkEfWcUyHkFuwQOuKgXDHEOv2deNvj0VbufUWA2w0297kDBDa5T_1V6__VvI1lHY7_fMwl'} 15 | def get_features(x1,y1,x2,y2,n): 16 | form_data = { 17 | 'queryMode': 'SpatialQuery', 18 | 'queryParameters': { 19 | 'prjCoordSys': {'epsgCode': 4490}, 20 | 'expectCount': n, 21 | 'queryParams': [{'name': "pro31@yndk", 'attributeFilter': "1=1", 'fields': ['yjjbntmj','yjjbnttbbh']}], 22 | 'startRecord': 0, 23 | }, 24 | 'geometry': { 25 | 'id': None, 26 | 'style': None, 27 | 'parts': [5], 28 | 'points': [ 29 | {'CLASS_NAME':'SuperMap.Geometry.Point','id': "SuperMap.Geometry_1", 'bounds': None, 'SRID': None, 'x': x1, 'y': y1, 'tag': None, 'type': "Point", 'geometryType': "Point"}, 30 | {'CLASS_NAME':'SuperMap.Geometry.Point','id': "SuperMap.Geometry_2", 'bounds': None, 'SRID': None, 'x': x2, 'y': y1, 'tag': None, 'type': "Point", 'geometryType': "Point"}, 31 | {'CLASS_NAME':'SuperMap.Geometry.Point','id': "SuperMap.Geometry_3", 'bounds': None, 'SRID': None, 'x': x2, 'y': y2, 'tag': None, 'type': "Point", 'geometryType': "Point"}, 32 | {'CLASS_NAME':'SuperMap.Geometry.Point','id': "SuperMap.Geometry_4", 'bounds': None, 'SRID': None, 'x': x1, 'y': y2, 'tag': None, 'type': "Point", 'geometryType': "Point"}, 33 | {'CLASS_NAME':'SuperMap.Geometry.Point','id': "SuperMap.Geometry_5", 'bounds': None, 'SRID': None, 'x': x1, 'y': y1, 'tag': None, 'type': "Point", 'geometryType': "Point"} 34 | ], 35 | 'type': "REGION", 36 | 'prjCoordSys': {'epsgCode': 4490} 37 | }, 38 | 'spatialQueryMode': "INTERSECT" 39 | } 40 | 41 | response = requests.post(url, headers=headers, params=params, json=form_data) 42 | jsondata=response.json() 43 | # features=jsondata["recordsets"][0]["features"] 44 | 45 | data=jsondata['data'] 46 | 47 | 48 | 49 | return data 50 | 51 | 52 | from gmssl import sm2 53 | 54 | def decrypt_geojson(data,key): 55 | 56 | if data and data.startswith("04"): 57 | data = data[2:] 58 | sm2_crypt = sm2.CryptSM2(public_key="", private_key=key,mode=1) 59 | features = sm2_crypt.decrypt(bytes.fromhex(data)) 60 | features=features.decode('utf-8') 61 | jsondata=json.loads(features) 62 | features=jsondata["recordsets"][0]["features"] 63 | 64 | return features 65 | 66 | 67 | 68 | def download_geojson(file_path,features): 69 | def create_polygon(feature): #处理单个几何 70 | parts = feature['geometry']['parts'] 71 | points = feature['geometry']['points'] 72 | start_index = 0 73 | exterior_ring = [] 74 | interior_rings = [] 75 | 76 | for part in parts: 77 | end_index = start_index + part 78 | ring = [(points[i]['x'], points[i]['y']) for i in range(start_index, end_index)] 79 | 80 | if not exterior_ring: # 如果外部边界尚未设置,则这是外部边界 81 | exterior_ring = ring 82 | else: # 否则,这是一个内部边界 83 | interior_rings.append(ring) 84 | start_index = end_index 85 | 86 | # 如果没有内部边界,Polygon 只需要外部边界 87 | if not interior_rings: 88 | polygon = Polygon(exterior_ring) 89 | else: 90 | # 创建Polygon对象,第一个参数是外部边界,第二个参数是一个内部边界的列表 91 | polygon = Polygon(exterior_ring, holes=interior_rings) 92 | 93 | return polygon 94 | 95 | # 检查文件是否存在,如果不存在则创建文件并写入初始数据 96 | if not os.path.exists(file_path): 97 | with fiona.open(file_path, 'w', driver='GeoJSON', crs='EPSG:4490', schema={'geometry': 'Polygon', 'properties': {'ID': 'int'}}) as file: 98 | for feature in features: 99 | file.write({ 100 | 'properties': {'ID': feature['ID']}, 101 | 'geometry': mapping(create_polygon(feature)) 102 | }) 103 | 104 | # 如果文件已经存在则增量保存,通过ID去重 105 | else: 106 | existing_ids = [] 107 | with fiona.open(file_path, 'r') as file: 108 | for feature in file: 109 | existing_ids.append(feature['properties']['ID']) 110 | with fiona.open(file_path, 'a') as file: 111 | for feature in features: 112 | if feature['ID'] not in existing_ids: 113 | file.write({ 114 | 'properties': {'ID': feature['ID']}, 115 | 'geometry': mapping(create_polygon(feature)) 116 | }) 117 | def convert_geojson_to_shapefile(input_geojson, output_shapefile): 118 | with fiona.open(input_geojson, 'r') as source: 119 | with fiona.open( 120 | output_shapefile, 'w', 121 | driver='ESRI Shapefile', 122 | crs=from_epsg(4490), # 设置坐标系,根据实际情况修改 123 | schema=source.schema 124 | ) as sink: 125 | for feature in source: 126 | sink.write(feature) 127 | 128 | 129 | if __name__ == "__main__": 130 | # 默认最大查询1000片,建议不要修改 131 | expectCount=1000 132 | 133 | # 保存文件路径 134 | file_path_geojson = '2.geojson' 135 | 136 | # 默认按矩形查找,传入左上与右下坐标,建议查询范围不要太大,爱护服务器 137 | x1=120.63954 138 | y1=32.43703 139 | x2=120.6456 140 | y2=32.43089 141 | 142 | key='' #请自行网页中查找 143 | 144 | fetures=get_features(x1,y1,x2,y2,expectCount) 145 | 146 | fetures=decrypt_geojson(fetures,key) 147 | 148 | download_geojson(file_path_geojson,fetures) 149 | 150 | #输出为shp格式 151 | # file_path_shp='1.shp' 152 | # convert_geojson_to_shapefile(file_path_geojson, file_path_shp) 153 | 154 | -------------------------------------------------------------------------------- /example.geojson: -------------------------------------------------------------------------------- 1 | {"type":"FeatureCollection","features":[{"type":"Feature","id":333,"geometry":{"type":"Polygon","coordinates":[[[120.30830616999999,32.43712438],[120.31355617,32.437181379999998],[120.31704717,32.437220379999999],[120.31704717,32.438004360000001],[120.31836817,32.438101359999997],[120.31792817,32.440329300000002],[120.31849416999999,32.440204309999999],[120.31927917,32.440426299999999],[120.32327217,32.440559299999997],[120.32393217000001,32.440340300000003],[120.32437217,32.4403413],[120.32437217,32.441785269999997],[120.32704416999999,32.441790269999998],[120.32748417000001,32.441445280000003],[120.32893017000001,32.441228279999997],[120.32871016999999,32.4405693],[120.32971417,32.440380300000001],[120.32996617000001,32.44065629],[120.33176517,32.440989289999997],[120.33221317,32.440111309999999],[120.33221317,32.43977332],[120.33154517,32.439662319999996],[120.33187517,32.43894134],[120.33235817000001,32.439095330000001],[120.33503116999999,32.439194329999999],[120.33516417,32.444695199999998],[120.33538417,32.444695199999998],[120.33610717000001,32.444917189999998],[120.33826417,32.445061189999997],[120.34048516999999,32.44525419],[120.34170317,32.445649179999997],[120.34170317,32.445311189999998],[120.34251217000001,32.445258189999997],[120.34256717,32.445619180000001],[120.34245717,32.446231160000004],[120.34262217,32.44617616],[120.34267817,32.447306140000002],[120.34292917000001,32.447339139999997],[120.34298416999999,32.447558129999997],[120.34320417000001,32.447559130000002],[120.34322717000001,32.447810130000001],[120.34298416999999,32.447864119999998],[120.34303917,32.449026099999998],[120.34198617,32.448969099999999],[120.34190017,32.449636079999998],[120.34253617,32.449605079999998],[120.34253617,32.449888080000001],[120.34220617,32.449888080000001],[120.34215116999999,32.451355040000003],[120.34401917,32.451382039999999],[120.34418417000001,32.451492039999998],[120.34417917,32.45065906],[120.34483917,32.450606059999998],[120.34500417,32.45068406],[120.34512117,32.450379069999997],[120.34528717000001,32.45044206],[120.34531017,32.450355070000001],[120.34641817000001,32.450326070000003],[120.34628517,32.45068706],[120.34647317,32.450742060000003],[120.34611817,32.451367040000001],[120.34696317,32.45163204],[120.34615717,32.453984980000001],[120.34715516999999,32.454456970000003],[120.34767017,32.453653989999999],[120.34797716999999,32.453724989999998],[120.34850317,32.452619009999999],[120.34952117,32.452924000000003],[120.35024017000001,32.451299040000002],[120.35050317,32.451343039999998],[120.35006017000001,32.452448019999999],[120.35026817000001,32.452547010000004],[120.35084917,32.451437040000002],[120.35146017,32.451633030000004],[120.35161816999999,32.451241039999999],[120.35295317000001,32.451918030000002],[120.35322017,32.451526039999997],[120.35472917,32.451968030000003],[120.35545217000001,32.451639030000003],[120.35567217000001,32.451530040000002],[120.35578217,32.450588060000001],[120.35600217,32.450526060000001],[120.35600217,32.451138049999997],[120.35661414,32.451139050000002],[120.35661414,32.449868080000002],[120.35699117,32.449868080000002],[120.35705417,32.449539080000001],[120.35733716999999,32.44975908],[120.35777717000001,32.44969708],[120.35782417,32.450089069999997],[120.35828017,32.450090070000002],[120.35850017,32.449698079999997],[120.36015017,32.45026507],[120.36087216999999,32.450424060000003],[120.36165817,32.450755059999999],[120.36332317,32.451039049999999],[120.36337017,32.449705080000001],[120.36409317,32.449879080000002],[120.36437617,32.449816079999998],[120.36431317,32.449330089999997],[120.36503517,32.449331090000001],[120.36503517,32.449111090000002],[120.36536517,32.449159090000002],[120.36569517,32.449551079999999],[120.36818217,32.450519059999998],[120.36607917000001,32.455412950000003],[120.36360417,32.461543800000001],[120.36166016999999,32.46635569],[120.35752217,32.476603439999998],[120.35142517,32.475243480000003],[120.35085917000001,32.475681469999998],[120.35010517000001,32.47568047],[120.34931917,32.476024459999998],[120.35032517,32.476465449999999],[120.34953917,32.478347399999997],[120.34963417,32.480356350000001],[120.34655417,32.481105339999999],[120.34633417000001,32.48232831],[120.34322217,32.4826683],[120.34011117,32.484201259999999],[120.34067616999999,32.484861250000002],[120.34111717,32.487750179999999],[120.34143117000001,32.490513110000002],[120.34111717,32.492082080000003],[120.34055217,32.496067979999999],[120.34077216999999,32.496820960000001],[120.34287817000001,32.498394930000003],[120.34800117,32.496833959999996],[120.35010717,32.497402950000001],[120.35130117,32.498503919999997],[120.35551417000001,32.504380779999998],[120.35791116999999,32.505562759999997],[120.35875617000001,32.505978749999997],[120.36305517,32.508096700000003],[120.36541217,32.5081007],[120.36962217,32.509675659999999],[120.37471017,32.510905630000003],[120.37460016999999,32.511191619999998],[120.37317217,32.514890540000003],[120.37150717,32.514417549999997],[120.37059617,32.515640519999998],[120.37182317,32.523082340000002],[120.36861817,32.524271310000003],[120.36839917,32.526374259999997],[120.36651417,32.530045180000002],[120.36607417,32.532712109999999],[120.36462517,32.538659969999998],[120.36397117,32.541342909999997],[120.36262017,32.542659880000002],[120.36240017,32.544542829999997],[120.36108016999999,32.54466583],[120.36064017,32.545324809999997],[120.36064017,32.546863780000002],[120.36098617,32.547566760000002],[120.36152017000001,32.548653729999998],[120.36230617,32.548874730000001],[120.36485217000001,32.554968580000001],[120.36513117,32.558061510000002],[120.36666017,32.572254170000001],[120.36679417000001,32.574005130000003],[120.36225517,32.57428213],[120.35546816999999,32.57383214],[120.35204217,32.574831109999998],[120.34910216999999,32.575154099999999],[120.34820917,32.5752521],[120.34650617,32.575439099999997],[120.34528517,32.575573089999999],[120.32823917,32.577737040000002],[120.32843817,32.575250099999998],[120.32877817000001,32.570154219999999],[120.32657817,32.569899229999997],[120.32588617,32.569270240000002],[120.32437717000001,32.568325270000003],[120.32456517,32.565249340000001],[120.32480916999999,32.562840399999999],[120.32465117,32.561458430000002],[120.32491917,32.561286430000003],[120.32454117,32.559512480000002],[120.32502817,32.559512480000002],[120.32458817,32.557910509999999],[120.32375517,32.558082509999998],[120.32370817,32.55786252],[120.32287517,32.558190510000003],[120.32254517,32.55796951],[120.32237216999999,32.558079509999999],[120.32265517,32.557075529999999],[120.32186917,32.557073529999997],[120.32081617,32.556852540000001],[120.31954317,32.556849540000002],[120.31993516999999,32.552345649999999],[120.31837917,32.552232650000001],[120.31716917,32.551727659999997],[120.31644617000001,32.551616660000001],[120.31572317,32.550610689999999],[120.31544017,32.549730709999999],[120.31511017,32.54918172],[120.31456016999999,32.548505740000003],[120.31488917,32.546010799999998],[120.31199817,32.546067800000003],[120.31212417,32.55071469],[120.31050617,32.550883679999998],[120.31061617,32.553207630000003],[120.30752017,32.553814610000003],[120.30313617,32.551530669999998],[120.30258617,32.551812660000003],[120.30169017,32.551700660000002],[120.30030717,32.552687640000002],[120.29853217,32.554238599999998],[120.29870517000001,32.555290579999998],[120.30008917000001,32.558777489999997],[120.30002517,32.559342479999998],[120.29616117,32.559273480000002],[120.29072517,32.557602520000003],[120.28706617,32.557220530000002],[120.28406617,32.555489569999999],[120.28717517,32.553390620000002],[120.28734817,32.552448640000001],[120.28706517000001,32.551569669999999],[120.28734717,32.550674690000001],[120.28734717,32.550062699999998],[120.28844717,32.54874573],[120.28767716999999,32.548524739999998],[120.28739417,32.547363769999997],[120.28423816999999,32.547359759999999],[120.28277817,32.547906750000003],[120.28155317,32.548188750000001],[120.28072117000001,32.548124749999999],[120.27745417,32.546849780000002],[120.27751216999999,32.546718779999999],[120.27767417,32.546347789999999],[120.27973117000001,32.545297810000001],[120.27623017000001,32.541323910000003],[120.27606016999999,32.540835919999999],[120.27572717,32.539878940000001],[120.27511517000001,32.539045960000003],[120.27423616999999,32.538652970000001],[120.27412517,32.538322979999997],[120.27467516999999,32.537773989999998],[120.27434517,32.537492],[120.27329317,32.537381000000003],[120.27262317,32.536776019999998],[120.27090717,32.535228050000001],[120.27090717,32.534836060000003],[120.27046817,32.534898060000003],[120.27029517,32.536217030000003],[120.26991916999999,32.536939009999998],[120.27046917,32.538931959999999],[120.26952717,32.539104960000003],[120.26869517,32.538648969999997],[120.26836517,32.538600969999997],[120.26431717,32.539038959999999],[120.26332816999999,32.538880970000001],[120.26241417,32.539021959999999],[120.26216217,32.53707601],[120.26126216999999,32.534595070000002],[120.26041217,32.529214199999998],[120.26007117,32.526053269999998],[120.25978216999999,32.524692299999998],[120.25943117,32.522162360000003],[120.25903017,32.520120409999997],[120.25892617,32.519360429999999],[120.25874116999999,32.51878044],[120.25899117,32.518630450000003],[120.25994117,32.518501450000002],[120.26011117,32.51786147],[120.26015117,32.517161479999999],[120.26008117000001,32.515720520000002],[120.26019017,32.515350529999999],[120.26008016999999,32.513960560000001],[120.26010017,32.512510589999998],[120.26002017,32.512289600000003],[120.26008016999999,32.509499660000003],[120.26228917,32.509730660000002],[120.26226917,32.509140670000001],[120.26246917,32.50842969],[120.26233917,32.507679709999998],[120.26349917,32.504829770000001],[120.26354917,32.504499780000003],[120.26338917,32.504409780000003],[120.26148917,32.504138789999999],[120.25860016999999,32.504047790000001],[120.25735017,32.5039078],[120.25732017,32.503297809999999],[120.25723017,32.503047819999999],[120.25696117,32.502966819999997],[120.25659116999999,32.502936820000002],[120.25438217,32.50315681],[120.25431116999999,32.503016819999999],[120.25414216999999,32.501436849999997],[120.25393217,32.498755920000001],[120.25347117,32.495764989999998],[120.25340117,32.494875010000001],[120.25349117,32.493965029999998],[120.25368116999999,32.49347504],[120.25452117,32.49302505],[120.25495117,32.493015049999997],[120.25558017,32.493045049999999],[120.25714917000001,32.492915060000001],[120.25764916999999,32.492765060000004],[120.26025817,32.489346140000002],[120.26075717000001,32.488415160000002],[120.26174717000001,32.486046219999999],[120.26217717,32.484346260000002],[120.26239717,32.483736270000001],[120.26280617,32.48295529],[120.26328617,32.481806319999997],[120.26364617,32.481196339999997],[120.26441017,32.479439380000002],[120.26481117,32.478475400000001],[120.26519517,32.47726643],[120.26536517,32.476306450000003],[120.26557517000001,32.475706459999998],[120.26593517000001,32.475346469999998],[120.26715517,32.47449649],[120.26751517,32.474047499999998],[120.26751517,32.473707509999997],[120.26711517,32.471426569999998],[120.26726017,32.470639579999997],[120.26741517000001,32.47019659],[120.26709517,32.46888663],[120.26720517,32.468245639999999],[120.26709517,32.467485660000001],[120.26712417,32.467185669999999],[120.26754416999999,32.465985699999997],[120.26849417,32.464476730000001],[120.26859417,32.463925740000001],[120.26857416999999,32.463695749999999],[120.26796417,32.46234578],[120.26779417,32.461645799999999],[120.26773817,32.461007809999998],[120.26814317,32.45839488],[120.26967417,32.451256039999997],[120.27060217,32.446445160000003],[120.27077317,32.445135190000002],[120.27087217,32.441025289999999],[120.27106216999999,32.440635299999997],[120.27227216999999,32.439656319999997],[120.27452817,32.438382349999998],[120.27592117,32.438383350000002],[120.27705116999999,32.438698340000002],[120.27727117000001,32.440581299999998],[120.27946917,32.4404903],[120.27959516999999,32.443346230000003],[120.28889217,32.443044239999999],[120.28857816999999,32.443922219999997],[120.29011717,32.44405021],[120.29055717,32.443265230000002],[120.29121617,32.443141240000003],[120.29112216999999,32.442607250000002],[120.29043117000001,32.442261260000002],[120.29043117000001,32.441821269999998],[120.29099617,32.440723290000001],[120.28967717,32.4402823],[120.28911117,32.439716320000002],[120.28989617000001,32.437740359999999],[120.29288117,32.436960380000002],[120.30830616999999,32.43712438]]]},"properties":{"FID":333,"gml_id":"layer_township_pg.19379","Name":"曲塘镇","layer":"乡镇","code":"320685102000","grade":4}}]} -------------------------------------------------------------------------------- /img/1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tangffntr/yncx/60451c5cc1868e774e8dc8254707a4d9daeb96ef/img/1.png -------------------------------------------------------------------------------- /img/10.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tangffntr/yncx/60451c5cc1868e774e8dc8254707a4d9daeb96ef/img/10.png -------------------------------------------------------------------------------- /img/11.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tangffntr/yncx/60451c5cc1868e774e8dc8254707a4d9daeb96ef/img/11.png -------------------------------------------------------------------------------- /img/12.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tangffntr/yncx/60451c5cc1868e774e8dc8254707a4d9daeb96ef/img/12.png -------------------------------------------------------------------------------- /img/2.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tangffntr/yncx/60451c5cc1868e774e8dc8254707a4d9daeb96ef/img/2.png -------------------------------------------------------------------------------- /img/3.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tangffntr/yncx/60451c5cc1868e774e8dc8254707a4d9daeb96ef/img/3.png -------------------------------------------------------------------------------- /img/4.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tangffntr/yncx/60451c5cc1868e774e8dc8254707a4d9daeb96ef/img/4.png -------------------------------------------------------------------------------- /img/5.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tangffntr/yncx/60451c5cc1868e774e8dc8254707a4d9daeb96ef/img/5.png -------------------------------------------------------------------------------- /img/6.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tangffntr/yncx/60451c5cc1868e774e8dc8254707a4d9daeb96ef/img/6.png -------------------------------------------------------------------------------- /img/7.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tangffntr/yncx/60451c5cc1868e774e8dc8254707a4d9daeb96ef/img/7.png -------------------------------------------------------------------------------- /img/8.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tangffntr/yncx/60451c5cc1868e774e8dc8254707a4d9daeb96ef/img/8.png -------------------------------------------------------------------------------- /img/9.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tangffntr/yncx/60451c5cc1868e774e8dc8254707a4d9daeb96ef/img/9.png -------------------------------------------------------------------------------- /img/栅格.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tangffntr/yncx/60451c5cc1868e774e8dc8254707a4d9daeb96ef/img/栅格.png -------------------------------------------------------------------------------- /img/栅格下载.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tangffntr/yncx/60451c5cc1868e774e8dc8254707a4d9daeb96ef/img/栅格下载.png -------------------------------------------------------------------------------- /requirements.txt: -------------------------------------------------------------------------------- 1 | Fiona==1.8.21 2 | requests==2.18.4 3 | Shapely==1.8.1.post1 4 | -------------------------------------------------------------------------------- /yjnt.geojson: -------------------------------------------------------------------------------- 1 | { 2 | "type": "FeatureCollection", 3 | "crs": { "type": "name", "properties": { "name": "urn:ogc:def:crs:EPSG::4490" } }, 4 | "features": [ 5 | { "type": "Feature", "properties": { "ID": 42025373 }, "geometry": { "type": "Polygon", "coordinates": [ [ [ 120.705093603000023, 32.419247212000073 ], [ 120.704840518000083, 32.41916201600003 ], [ 120.70477883600006, 32.419255580000026 ], [ 120.70504355300011, 32.41934593700006 ], [ 120.705092870000044, 32.419260273000077 ], [ 120.705093603000023, 32.419247212000073 ] ] ] } }, 6 | { "type": "Feature", "properties": { "ID": 42030018 }, "geometry": { "type": "Polygon", "coordinates": [ [ [ 120.705383644000108, 32.419345331000045 ], [ 120.705348222000111, 32.419333024000025 ], [ 120.705307874000027, 32.41941844400003 ], [ 120.705290340000033, 32.419430172000034 ], [ 120.705333192000012, 32.419444799000075 ], [ 120.705383644000108, 32.419345331000045 ] ] ] } }, 7 | { "type": "Feature", "properties": { "ID": 42030233 }, "geometry": { "type": "Polygon", "coordinates": [ [ [ 120.706502662000048, 32.41991253100008 ], [ 120.706718018000061, 32.419743007000079 ], [ 120.706718267000042, 32.419743225000047 ], [ 120.706721468000069, 32.419746037000039 ], [ 120.706721885000093, 32.419745719000048 ], [ 120.706754322000052, 32.419721037000045 ], [ 120.706858322000016, 32.419827102000056 ], [ 120.706878926000059, 32.419847466000078 ], [ 120.706950813000049, 32.41978406800007 ], [ 120.707091414000047, 32.419631123000045 ], [ 120.707217812000067, 32.419506703000025 ], [ 120.707376698000076, 32.419365145000029 ], [ 120.707399784000017, 32.419344203000037 ], [ 120.707219529000099, 32.419283103000055 ], [ 120.707165961000101, 32.419263827000066 ], [ 120.706993972000078, 32.419212238000057 ], [ 120.706961270000079, 32.419202429000052 ], [ 120.70696458000009, 32.41919550800003 ], [ 120.706891193000047, 32.419172772000024 ], [ 120.706887928000015, 32.41918042900005 ], [ 120.706706068000017, 32.419125878000045 ], [ 120.706709660000115, 32.419116532000032 ], [ 120.706691743000079, 32.419110981000074 ], [ 120.706518804000098, 32.419057404000057 ], [ 120.706518281000058, 32.419057242000065 ], [ 120.706571668000038, 32.418937131000064 ], [ 120.706552710000096, 32.418930988000056 ], [ 120.706451224000034, 32.419151047000071 ], [ 120.706305504000056, 32.419491846000028 ], [ 120.706329230000051, 32.419491836000077 ], [ 120.706329873000072, 32.41949173900008 ], [ 120.706420367000078, 32.419477982000046 ], [ 120.706478108000056, 32.41945774900006 ], [ 120.706546562000085, 32.419416127000034 ], [ 120.706608089000042, 32.419373227000051 ], [ 120.706681838, 32.41930201200006 ], [ 120.706750613000054, 32.419238132000032 ], [ 120.706802711000023, 32.419202142000074 ], [ 120.706825503000118, 32.419195476000027 ], [ 120.706853457000079, 32.419200999000054 ], [ 120.706884082000101, 32.41922164500005 ], [ 120.706940366000026, 32.41926817500007 ], [ 120.706960085000105, 32.419294256000057 ], [ 120.706963911000116, 32.419334998000068 ], [ 120.706934475000025, 32.419405055000027 ], [ 120.706906091000064, 32.419456009000044 ], [ 120.706891419000044, 32.419476552000049 ], [ 120.706822924000107, 32.419530982000026 ], [ 120.706633886000077, 32.419658618000028 ], [ 120.706515810000042, 32.419735610000032 ], [ 120.706406180000045, 32.419802124000057 ], [ 120.706366025000079, 32.419819037000025 ], [ 120.706343248000053, 32.419820245000039 ], [ 120.706317772000034, 32.419814306000035 ], [ 120.706208785000058, 32.419767661000037 ], [ 120.706208270000047, 32.419767441000033 ], [ 120.706190085000117, 32.419762879000075 ], [ 120.706173960000115, 32.419800744000042 ], [ 120.706191253000043, 32.419807190000029 ], [ 120.70619178700008, 32.419807371000047 ], [ 120.706502662000048, 32.41991253100008 ] ] ] } }, 8 | { "type": "Feature", "properties": { "ID": 42030615 }, "geometry": { "type": "Polygon", "coordinates": [ [ [ 120.70475009300003, 32.419245769000042 ], [ 120.704803026000036, 32.419149395000034 ], [ 120.704580951000025, 32.419074637000051 ], [ 120.704458063000061, 32.419034037000074 ], [ 120.704341199000055, 32.418994068000075 ], [ 120.704321636000032, 32.419032475000051 ], [ 120.704165036000063, 32.419354257000066 ], [ 120.704164905000084, 32.419354526000063 ], [ 120.704258741000103, 32.419387862000065 ], [ 120.704378140000017, 32.419436434000033 ], [ 120.704378267000038, 32.419436135000069 ], [ 120.70449330200006, 32.41916597900007 ], [ 120.7045225170001, 32.419175689000042 ], [ 120.704526057000066, 32.419169297000053 ], [ 120.704526537000106, 32.419169461000024 ], [ 120.70475009300003, 32.419245769000042 ] ] ] } }, 9 | { "type": "Feature", "properties": { "ID": 42031511 }, "geometry": { "type": "Polygon", "coordinates": [ [ [ 120.705124238000053, 32.419257525000035 ], [ 120.705093603000023, 32.419247212000073 ], [ 120.705092870000044, 32.419260273000077 ], [ 120.70504355300011, 32.41934593700006 ], [ 120.705078595000032, 32.419357898000044 ], [ 120.705124238000053, 32.419257525000035 ] ] ] } }, 10 | { "type": "Feature", "properties": { "ID": 42034186 }, "geometry": { "type": "Polygon", "coordinates": [ [ [ 120.704748065000103, 32.417127809000078 ], [ 120.704530099000067, 32.417055692000076 ], [ 120.704485675000114, 32.417230032000077 ], [ 120.704415253000093, 32.417408431000069 ], [ 120.704307275000019, 32.417583810000053 ], [ 120.704165913000111, 32.417880797000066 ], [ 120.70418307500006, 32.417887275000055 ], [ 120.704183562000026, 32.417887445000076 ], [ 120.704650187000084, 32.418049736000057 ], [ 120.705117301000087, 32.418212194000034 ], [ 120.705574998000088, 32.418380102000071 ], [ 120.705637780000075, 32.418402041000036 ], [ 120.705886355000075, 32.418488901000046 ], [ 120.705892211000105, 32.41847795800004 ], [ 120.706609520000029, 32.418720575000066 ], [ 120.706781805000105, 32.418320688000051 ], [ 120.706961983000042, 32.417902479000077 ], [ 120.706970731000069, 32.417882180000049 ], [ 120.706975420000049, 32.417871295000054 ], [ 120.706937584000116, 32.417858304000049 ], [ 120.706930137000086, 32.417875133000052 ], [ 120.705753636000054, 32.417474133000042 ], [ 120.705732521000073, 32.417519681000044 ], [ 120.705708107000078, 32.417572341000039 ], [ 120.705679939000106, 32.417633102000025 ], [ 120.705676109000024, 32.417641361000051 ], [ 120.705605720000108, 32.417793192000033 ], [ 120.705605592000097, 32.417793471000039 ], [ 120.705545700000016, 32.41777258500008 ], [ 120.705542144000106, 32.417781233000028 ], [ 120.705237717000045, 32.417683406000037 ], [ 120.705225849000044, 32.41767959200007 ], [ 120.705251781000015, 32.417712298000026 ], [ 120.705287852000083, 32.417767946000026 ], [ 120.705307449000088, 32.417830141000024 ], [ 120.705306064000069, 32.417875279000043 ], [ 120.70528859500007, 32.417918279000048 ], [ 120.705253768000034, 32.417971737000073 ], [ 120.70523641300008, 32.417979882000054 ], [ 120.705212891000087, 32.417981927000028 ], [ 120.70514976100003, 32.417984928000067 ], [ 120.705121295000026, 32.417985911000073 ], [ 120.705094097000028, 32.417976400000043 ], [ 120.70503979800003, 32.417928399000061 ], [ 120.704940819000058, 32.41784397300006 ], [ 120.704854437000108, 32.41776797700004 ], [ 120.704735918000097, 32.417679514000042 ], [ 120.70462085500003, 32.417594419000068 ], [ 120.704555590000041, 32.417542043000026 ], [ 120.704538002000049, 32.417450526000039 ], [ 120.704571286000032, 32.417390216000058 ], [ 120.704665198000043, 32.41730709400008 ], [ 120.704748065000103, 32.417127809000078 ] ] ] } }, 11 | { "type": "Feature", "properties": { "ID": 42034708 }, "geometry": { "type": "Polygon", "coordinates": [ [ [ 120.709031671000048, 32.419561434000059 ], [ 120.708355728000015, 32.419323015000032 ], [ 120.708192303000033, 32.419263640000054 ], [ 120.707748975000072, 32.419111649000058 ], [ 120.7075860220001, 32.419058358000029 ], [ 120.706660311000064, 32.418739165000034 ], [ 120.707022356000039, 32.417912337000075 ], [ 120.707021854000118, 32.41791216300004 ], [ 120.706999114000041, 32.417903810000041 ], [ 120.706816960000083, 32.418329973000027 ], [ 120.706634803000043, 32.418756134000034 ], [ 120.70665081900006, 32.418764456000076 ], [ 120.706898217000116, 32.418849198000032 ], [ 120.707305552000093, 32.418998242000043 ], [ 120.707874496000045, 32.419182600000056 ], [ 120.70840738000004, 32.419367158000057 ], [ 120.709027988000116, 32.419569753000076 ], [ 120.709031536000111, 32.419561743000031 ], [ 120.709031671000048, 32.419561434000059 ] ] ] } }, 12 | { "type": "Feature", "properties": { "ID": 42034831 }, "geometry": { "type": "Polygon", "coordinates": [ [ [ 120.704840518000083, 32.41916201600003 ], [ 120.704803026000036, 32.419149395000034 ], [ 120.70475009300003, 32.419245769000042 ], [ 120.70477883600006, 32.419255580000026 ], [ 120.704840518000083, 32.41916201600003 ] ] ] } }, 13 | { "type": "Feature", "properties": { "ID": 42035651 }, "geometry": { "type": "Polygon", "coordinates": [ [ [ 120.705822774000012, 32.419648083000027 ], [ 120.705892845000108, 32.419522244000063 ], [ 120.705383644000108, 32.419345331000045 ], [ 120.705333192000012, 32.419444799000075 ], [ 120.705369668000117, 32.41945725000005 ], [ 120.705271702000118, 32.419742982000059 ], [ 120.705399778000015, 32.419787377000034 ], [ 120.70539989800011, 32.419787088000078 ], [ 120.705472382000039, 32.419612442000073 ], [ 120.705472530000065, 32.419612492000056 ], [ 120.705472907000058, 32.419612621000056 ], [ 120.705659070000024, 32.419675915000028 ], [ 120.705659222, 32.419675638000058 ], [ 120.70569988200009, 32.419601319000037 ], [ 120.705822272000091, 32.419647908000059 ], [ 120.705822774000012, 32.419648083000027 ] ] ] } }, 14 | { "type": "Feature", "properties": { "ID": 42037177 }, "geometry": { "type": "Polygon", "coordinates": [ [ [ 120.704341199000055, 32.418994068000075 ], [ 120.704458063000061, 32.419034037000074 ], [ 120.704580951000025, 32.419074637000051 ], [ 120.704803026000036, 32.419149395000034 ], [ 120.704840518000083, 32.41916201600003 ], [ 120.705093603000023, 32.419247212000073 ], [ 120.705124238000053, 32.419257525000035 ], [ 120.705339047000052, 32.419329837000078 ], [ 120.705348222000111, 32.419333024000025 ], [ 120.705383644000108, 32.419345331000045 ], [ 120.705892845000108, 32.419522244000063 ], [ 120.705923436000035, 32.419532872000048 ], [ 120.706206122000026, 32.419631085000049 ], [ 120.706210970000029, 32.419619496000053 ], [ 120.705590567000058, 32.419405414000039 ], [ 120.704970168000045, 32.419191329000057 ], [ 120.704349770000022, 32.41897724100005 ], [ 120.704341199000055, 32.418994068000075 ] ] ] } }, 15 | { "type": "Feature", "properties": { "ID": 42037791 }, "geometry": { "type": "Polygon", "coordinates": [ [ [ 120.707022356000039, 32.417912337000075 ], [ 120.706660311000064, 32.418739165000034 ], [ 120.7075860220001, 32.419058358000029 ], [ 120.707748975000072, 32.419111649000058 ], [ 120.708192303000033, 32.419263640000054 ], [ 120.708355728000015, 32.419323015000032 ], [ 120.709031671000048, 32.419561434000059 ], [ 120.709211628000048, 32.419147018000047 ], [ 120.709391718, 32.418732292000072 ], [ 120.708799248000105, 32.418527264000033 ], [ 120.708206780000069, 32.418322233000026 ], [ 120.707614316000104, 32.41811720000004 ], [ 120.707022356000039, 32.417912337000075 ] ] ] } }, 16 | { "type": "Feature", "properties": { "ID": 42041119 }, "geometry": { "type": "Polygon", "coordinates": [ [ [ 120.706365395000034, 32.419267350000041 ], [ 120.706590184000106, 32.418765119000057 ], [ 120.706392157000096, 32.418695873000047 ], [ 120.706391643000075, 32.418695693000075 ], [ 120.706305035000014, 32.418906541000069 ], [ 120.706304913000054, 32.418906838000055 ], [ 120.706290946000081, 32.418901884000036 ], [ 120.706290616000047, 32.41890271300008 ], [ 120.705985744000031, 32.418814747000056 ], [ 120.705993629000091, 32.418796436000036 ], [ 120.705610661000037, 32.418660609000028 ], [ 120.705621199, 32.41862851500008 ], [ 120.705620047000025, 32.418628162000061 ], [ 120.705513137000025, 32.418868810000049 ], [ 120.705501992000109, 32.418886478000047 ], [ 120.705473194000092, 32.418912653000064 ], [ 120.705467249000094, 32.418913682000039 ], [ 120.705451645000039, 32.418916384000056 ], [ 120.70544165900003, 32.418916032000027 ], [ 120.705406848000052, 32.418914807000078 ], [ 120.705220355000051, 32.418871746000036 ], [ 120.705070015000047, 32.418824572000062 ], [ 120.704988929000024, 32.41879351700004 ], [ 120.704926419000117, 32.418758517000072 ], [ 120.704892125000015, 32.418724424000061 ], [ 120.704884761000017, 32.418705510000052 ], [ 120.704880981000088, 32.418625921000057 ], [ 120.704880465000087, 32.418615076000037 ], [ 120.704880364000019, 32.418612907000067 ], [ 120.704885048000051, 32.418599952000079 ], [ 120.704919583000105, 32.418504451000047 ], [ 120.704974244000027, 32.418367267000065 ], [ 120.705010642000047, 32.418288619000066 ], [ 120.705026297000018, 32.418270390000032 ], [ 120.705047888000081, 32.418253013000026 ], [ 120.705066686, 32.418240396000044 ], [ 120.704616304000069, 32.418083757000034 ], [ 120.704166412000063, 32.417927284000029 ], [ 120.704165925000098, 32.417927115000055 ], [ 120.704148136000072, 32.417922339000029 ], [ 120.703971259000014, 32.418335715000069 ], [ 120.703794382000069, 32.418749090000063 ], [ 120.703806625000084, 32.418752932000075 ], [ 120.704237221000085, 32.418896265000058 ], [ 120.704667818000075, 32.419039597000051 ], [ 120.704674739000097, 32.419041913000058 ], [ 120.704679664000082, 32.419043613000042 ], [ 120.705195841000091, 32.419221850000042 ], [ 120.705712020000078, 32.419400083000028 ], [ 120.706228200000055, 32.419578315000024 ], [ 120.706228331000034, 32.419578019000028 ], [ 120.706356518, 32.419287186000076 ], [ 120.706360664000044, 32.41927792000007 ], [ 120.706365395000034, 32.419267350000041 ] ] ] } }, 17 | { "type": "Feature", "properties": { "ID": 42041505 }, "geometry": { "type": "Polygon", "coordinates": [ [ [ 120.705348222000111, 32.419333024000025 ], [ 120.705339047000052, 32.419329837000078 ], [ 120.705124238000053, 32.419257525000035 ], [ 120.705078595000032, 32.419357898000044 ], [ 120.705290340000033, 32.419430172000034 ], [ 120.705307874000027, 32.41941844400003 ], [ 120.705348222000111, 32.419333024000025 ] ] ] } }, 18 | { "type": "Feature", "properties": { "ID": 42043082 }, "geometry": { "type": "Polygon", "coordinates": [ [ [ 120.706609520000029, 32.418720575000066 ], [ 120.705892211000105, 32.41847795800004 ], [ 120.705886355000075, 32.418488901000046 ], [ 120.705988716000093, 32.418524668000032 ], [ 120.706020107000086, 32.418535636000058 ], [ 120.706402435000086, 32.41866923200007 ], [ 120.706601625000076, 32.418738897000026 ], [ 120.706609520000029, 32.418720575000066 ] ] ] } } 19 | ] 20 | } 21 | --------------------------------------------------------------------------------