1

I am trying to download a Geoserver layer as KML using the KML Reflector. I actually use Leaflet and a plugin (leaflet-area-draw) in order to let the user design a rectangle and then pass the BB to the URL. The URL request I make is WMS and it looks like this:

http://localhost:8080/geoserver/wms/kml?layers=my_workspace:my_layer&bbox=-124.73,24.96,-66.97,49.37

I face two issues. First the whole layer is downloaded although I restrict it with the BBox. I wonder if this is related cause its a WMS request and maybe I should try to make a WFS one. Is it possible to make a WFS request to get KML?

The second issue appears when the projetion of the layer in geoserver is other than EPSG:4326. Then I get nothing back. What is the right approach to this? Should I use a Leaflet plugin to convert the BBOX coordinates from EPSG:4326 to the layer's srs?

EDIT

I tried using KML scoring in order to get the data as vectors with the hope, that they will be rendered correctly and only the ones in BB will be shown. But it didn't work. I get all the features back.

http://localhost:8080/geoserver/wms/kml?layers=geonode:afg_wfp_acces_byair__byroad_20161801_1&mode=refresh&kmscore=100&bbox=68.0712890625,32.24997445586331,72.4658203125,35.88905007936091

  • 2
    Your example seems to be from the documentation docs.geoserver.org/2.6.x/en/user/googleearth/features/… which is good. Have you played with KML_Scoring, KML_Regionation, and superoverlay_subtype? The second issue in not an issue at all because KML by specification uses only a single projection, EPSG:4326. – user30184 May 17 '16 at 6:30
  • Thanks. So if KML uses only one projection, does it mean that I have to transform my geoserver layer to 4326? – user1919 May 17 '16 at 6:49
  • 2
    If you use KML reflector Geoserver is automatically reprojecting data if needed. If you use standard WMS GetMap requests with KML as format you must always use &SRS=4326. – user30184 May 17 '16 at 7:17
  • I use KML reflector but this is not the case at all. Geoserver doesn't reproject the data. I actually get nothing back. And provably this is a bigger issue cause I also try to get CSV and geoJSON files and I also get nothing back. – user1919 May 17 '16 at 9:32
  • Also, when my layer is originally in 4326 and I get some data back, for some reason they are not filtered based on BB. I just get the whole layer back. Unlike the CSV, shapefile and geojson case where they return data correctly. – user1919 May 17 '16 at 9:34

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.