-1

Are there any website online-converters to upload a WMS layer URL and convert it on a KMZ/KML file that works without internet connection?

I am working with a specific WMS layers loading them to Google Earth as "Images Overlays" linked to public available WMS layers though URL links of the form:

https://geoserver.exploradorenergia.cl/geoserver/wms?SERVICE=WMS&VERSION=1.1.1&REQUEST=GetMap&SRS=EPSG:4326&WIDTH=512&HEIGHT=512&LAYERS=api_vector:SEC_DistroTM&STYLES=api_vector:api_sec_distro_tm_media_tension&TRANSPARENT=TRUE&FORMAT=image/gif&

But my internet connection is really unstable, and many times I cannot be able to load the layers on Google Earth because of that, so I would like to put the URL on a website that downloads the full layer on a .kmz file that works as an overlay that doesn't require of internet to work with (saved as an image or polygon, etc, hope you get the idea).

5
  • 1
    Most web technologies are either online or offline. If offline, you need to cache locally before you lose connectivity. Making a fundamental format change like this is probably the topic of multiple questions, as you work through the challenges, or in the domain of Software Recommendations if you want a recommendation.
    – Vince
    Nov 16 '21 at 12:15
  • @Vince actually I found on Google this site that says it do exactly what I am asking for <edac.unm.edu/cgi-bin/wms2kml.kml> but unfortunately it looks to be outdated since the download file looks corrupted, but with this, I believe is not as hard as you explain, so hopefully someone could share a functional site that does the same.
    – Joako
    Nov 16 '21 at 13:53
  • 2
    @Joako I think you are probably thinking of KML as a vector only format, it is not. You can have a KML file that provides the connection details for a WMS; you still need to be connected to use it. I think that's what the ESIP tool does/did. OneGeology portal does something similar
    – nmtoken
    Nov 16 '21 at 14:00
  • 2
    For the service you reference, you can access the data as a WFS, so you could use GDAL tools to convert the output to vector data (including KML) and use that instead
    – nmtoken
    Nov 16 '21 at 14:03
  • @nmtoken thanks for answer, but I am at user-level of Google Earth so I don´t understand what are the things you mention... to see if I am following you: there is a tool/software named "GDAL tools" which allows you to download the layer on KML to be used later through Google Earth without internet connection?
    – Joako
    Nov 16 '21 at 14:06
1

KML is not a vector only format, it can be used for images too using, for example, a link by reference to a Web Map Service. The ESIP - WMS to KML converter tool you reference, creates this sort of KML.

You say

but unfortunately it looks to be outdated since the download file looks corrupted,

I tried it (using https://geoserver.exploradorenergia.cl/geoserver/wms?SERVICE=WMS&VERSION=1.1.1&REQUEST=GetCapabilities), and the file output is not corrupted, it is valid KML. It creates a KML with 197 layers (all the layers in the WMS), but if you wanted just api_vector:SEC_DistroTM the file would look like:

<?xml version="1.0" encoding="UTF-8"?>
<kml xmlns="http://earth.google.com/kml/2.2">
  <Folder xmlns="">
    <name>GeoServer Web Map Service</name>
    <visibility/>
    <description>A compliant implementation of WMS plus most of the SLD extension (dynamic styling).
      Can also generate PDF, SVG, KML, GeoRSS</description>
    <LookAt>
      <longitude>295879.962987068</longitude>
      <latitude>3987151.82788241</latitude>
      <altitude>0</altitude>
      <range>1000000</range>
      <tilt>0</tilt>
      <heading>0</heading>
    </LookAt>
    <Style>
      <ListStyle>
        <listItemType>check</listItemType>
        <bgColor>00ffffff</bgColor>
        <maxSnippetLines>2</maxSnippetLines>
      </ListStyle>
    </Style>
    <GroundOverlay>
      <name>SEC_DistroTM</name>
      <visibility>0</visibility>
      <snippet/>
      <Snippet maxLines="0"/>
      <description/>
      <LookAt>
        <longitude>332802.32155</longitude>
        <latitude>5942425.32325</latitude>
        <altitude>0</altitude>
        <range>1000000</range>
        <tilt>0</tilt>
        <heading>0</heading>
      </LookAt>
      <drawOrder>2</drawOrder>
      <Icon>
        <href>https://geoserver.exploradorenergia.cl/geoserver/wms?SERVICE=WMS&amp;VERSION=1.1.1&amp;REQUEST=GetMap&amp;SRS=EPSG:4326&amp;WIDTH=1024&amp;HEIGHT=1024&amp;LAYERS=api_vector:SEC_DistroTM&amp;TRANSPARENT=TRUE&amp;FORMAT=image/png</href>
        <viewRefreshMode>onStop</viewRefreshMode>
      </Icon>
      <LatLonBox>
        <north>7974395.6129</north>
        <south>3910455.0336</south>
        <east>591871.7315999996</east>
        <west>73732.9115000004</west>
      </LatLonBox>
    </GroundOverlay>
  </Folder>
</kml>

This doesn't help you though, as you need to be connected to the WMS.

Luckily for you in this case there is a WFS too:

https://geoserver.exploradorenergia.cl/geoserver/wfs?service=WFS&request=GetCapabilities

and even luckier it supports KML as an output so you can get your vector KML with a GetFeature request like:

https://geoserver.exploradorenergia.cl/geoserver/wfs?service=WFS&request=GetFeature&typenames=api_vector:SEC_DistroTM&outputformat=KML&version=2.0.0

If you had a WFS but no KML output format, you could have used a tool like ogr2ogr to do the transformation something like:

ogr2ogr -f KML SEC_DistroTM.kml WFS:https://geoserver.exploradorenergia.cl/geoserver/wfs?TYPENAME=api_vector:SEC_DistroTM

References for more info on ogr2ogr and the WFS driver are: https://gdal.org/drivers/vector/wfs.html#vector-wfs and https://gdal.org/programs/ogr2ogr.html

9
  • Thanks for the detailed answer. I tried to install ogr2ogr unsecessfully. What I was doing is to access to the webpage <geoserver.exploradorenergia.cl/geoserver/web/wicket/…> and where says "Select One" downloading the KML files but no one really works, even the SHP file only shows a few "lines" only in Google Earth... in one KML I plug the code you paste and works better in PNG (I have a GIF being called), but I still without having a "unplugged" version.
    – Joako
    Nov 16 '21 at 23:26
  • I find other website tying to use ogr2ogr online, and tried to plug the required info here <ogre.adc4gis.com> but I don't really understand what they are asking me to do (All I know about GIS is by searching in Google so there is a lot I don't understand)... Is this site doing what I want to do?
    – Joako
    Nov 16 '21 at 23:29
  • 1
    To get the vector data using the layer preview links, you use the WFS options. The preview downloads use WFS GetFeature requests limited to 50 features, for example the GeoJSON(JSONP) request is: https://geoserver.exploradorenergia.cl/geoserver/api_vector/ows?service=WFS&version=1.0.0&request=GetFeature&typeName=api_vector%3ASEC_DistroTM&maxFeatures=50&outputFormat=text%2Fjavascript if you want all features then you need to remove the maxFeatures=50& parameter, but note this may result in a very large download. You will have to hand craft the WFS request and paste in a browser
    – nmtoken
    Nov 17 '21 at 10:40
  • Alternatively use a GIS like QGIS, to manage the WFS access for you, and the conversion to the format of your choice
    – nmtoken
    Nov 17 '21 at 10:41
  • With your tip about erasing the maxFeatures I have download the whole KML file, but it weight 2GB and now I can´t open it on Google Earth, so now I am trying to make the same with the SHP format since it can be imported by parts into Google Earth, but unfortunately the same trick doesn´t work for the SHP format... I tried online converters but the file weight too much, so now I am trying to make a KML that instead of linking from a website it could load this heavy-KML by views as is done with image overlays or Network Links... but I did not find how to do it on Google.... any ideas?
    – Joako
    Nov 17 '21 at 17:01

Your Answer

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

Not the answer you're looking for? Browse other questions tagged or ask your own question.