1 | | Tested in 2.0 and 2.1 (windows & linux). |
2 | | |
3 | | 1. create a testfile |
4 | | |
5 | | {{{ |
6 | | cat <<EOF > input.csv |
7 | | WKT,ID |
8 | | "POLYGON ((6.973057788614954 50.946219022286115,6.97388932516517 50.946219022286115,6.97388932516517 50.945682432460977,6.973057788614954 50.945682432460977,6.973057788614954 50.946219022286115))",0 |
9 | | "POLYGON ((8.112847375416614 51.564542835246336,8.113188401592302 51.564542835246336,8.113188401592302 51.564275470724596,8.112847375416614 51.564275470724596,8.112847375416614 51.564542835246336))",1 |
10 | | EOF |
11 | | }}} |
12 | | |
13 | | 2. convert it to SHP |
14 | | {{{ |
15 | | ogr2ogr -a_srs EPSG:4326 -F "ESRI Shapefile" buildings.shp input.csv |
16 | | }}} |
17 | | |
18 | | 3. check the shapefile |
19 | | {{{ |
20 | | ogrinfo buildings.shp -al -so |
21 | | }}} |
22 | | |
23 | | 4. setup WMS server using XML & VRT |
24 | | {{{ |
25 | | gdal_translate "WMS:http://www.wms.nrw.de/geobasis/wms_nw_alkis?LAYERS=adv_alkis_gebaeude&FORMAT=image/png" adv_alkis_gebaeude.xml -of WMS |
26 | | gdal_translate -of VRT adv_alkis_gebaeude.xml adv_alkis_gebaeude.vrt |
27 | | }}} |
28 | | |
29 | | 5. verify that the WMS returns the correct values (it does so) |
30 | | {{{ |
31 | | gdal_translate -projwin_srs "EPSG:4326" -projwin 6.973057788614954 50.946219022286115 6.97388932516517 50.945682432460977 -outsize 500 500 adv_alkis_gebaeude.xml -of GTiff output_0a.tif |
32 | | gdal_translate -projwin_srs "EPSG:4326" -projwin 8.112847375416614 51.564542835246336 8.113188401592302 51.564275470724596 -outsize 500 500 adv_alkis_gebaeude.xml -of GTiff output_1a.tif |
33 | | }}} |
34 | | |
35 | | 6. get data from WMS using cutlines |
36 | | {{{ |
37 | | gdalwarp adv_alkis_gebaeude.vrt -cutline buildings.shp -cwhere "ID='0'" -crop_to_cutline -ts 100 100 -of GTiff output_0.tif |
38 | | gdalwarp adv_alkis_gebaeude.vrt -cutline buildings.shp -cwhere "ID='1'" -crop_to_cutline -ts 100 100 -of GTiff output_1.tif |
39 | | }}} |
40 | | |
41 | | 7. be disappointed about the result :( |
42 | | GDAL_HTTP_PROXY and --debug on show that no. 6 requests this URL: |
43 | | {{{ |
44 | | http://www.wms.nrw.de/geobasis/wms_nw_alkis?service=WMS&request=GetMap&version=1.1.1&layers=adv_alkis_gebaeude&styles=&srs=EPSG:4326&transparent=FALSE&format=image/png&width=1024&height=512&bbox=-180.00000000,-90.00000000,180.00000000,90.00000000 |
45 | | }}} |
46 | | |
47 | | Seems like the BBOX doesn't comply with the extent of the selected cutline. |
| 1 | [can be removed] |